CoreFiles by mySites.guru
DispatcherFactory.php84 lines, 2,010 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
d20ec6be0703c8a4ae238bdfa27955c8
sha1
8929a6ecf9f6220fc9ba25547e44fc7d765a53ad
sha256
7fd9c3bf9932d9500991a85bd25c26e5a22ea1130325fb1e160beb838dbabe60
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\CMS\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\Input\Input;
use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface;

/**
 * Namesapce based implementation of the DispatcherFactoryInterface
 *
 * @since  4.0.0
 */
class DispatcherFactory implements DispatcherFactoryInterface
{
	/**
	 * The extension namespace
	 *
	 * @var  string
	 *
	 * @since   4.0.0
	 */
	protected $namespace;

	/**
	 * The MVC factory
	 *
	 * @var  MVCFactoryFactoryInterface
	 *
	 * @since   4.0.0
	 */
	private $mvcFactoryFactory;

	/**
	 * DispatcherFactory constructor.
	 *
	 * @param   string                      $namespace          The namespace
	 * @param   MVCFactoryFactoryInterface  $mvcFactoryFactory  The MVC factory
	 *
	 * @since   4.0.0
	 */
	public function __construct(string $namespace, MVCFactoryFactoryInterface $mvcFactoryFactory)
	{
		$this->namespace         = $namespace;
		$this->mvcFactoryFactory = $mvcFactoryFactory;
	}

	/**
	 * Creates a dispatcher.
	 *
	 * @param   CMSApplicationInterface  $application  The application
	 * @param   Input                    $input        The input object, defaults to the one in the application
	 *
	 * @return  DispatcherInterface
	 *
	 * @since   4.0.0
	 */
	public function createDispatcher(CMSApplicationInterface $application, Input $input = null): DispatcherInterface
	{
		$name = 'Site';

		if ($application->isClient('administrator'))
		{
			$name = 'Administrator';
		}

		$className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher';

		if (!class_exists($className))
		{
			$className = '\\Joomla\\CMS\\Dispatcher\\Dispatcher';
		}

		return new $className($application, $input ?: $application->input, $this->mvcFactoryFactory);
	}
}

No other release has this exact content. See every version of this file.