- md5
- 3e08237f9742ba539b298aa89a3985cd
- sha1
- caaf322dbdb97a94b12d377ab6098cc06f3cecb1
- sha256
- 8988cbd8ef751188f426ea2d8f0a31398637b1279044b3cee8293df20bdb7e42
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\CMS\Dispatcher;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Input\Input;
/**
* Namespace based implementation of the ComponentDispatcherFactoryInterface
*
* @since 4.0.0
*/
class ComponentDispatcherFactory implements ComponentDispatcherFactoryInterface
{
/**
* The extension namespace
*
* @var string
*
* @since 4.0.0
*/
protected $namespace;
/**
* The MVC factory
*
* @var MVCFactoryInterface
*
* @since 4.0.0
*/
private $mvcFactory;
/**
* ComponentDispatcherFactory constructor.
*
* @param string $namespace The namespace
* @param MVCFactoryInterface $mvcFactory The MVC factory
*
* @since 4.0.0
*/
public function __construct(string $namespace, MVCFactoryInterface $mvcFactory)
{
$this->namespace = $namespace;
$this->mvcFactory = $mvcFactory;
}
/**
* 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 = ucfirst($application->getName());
$className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher';
if (!class_exists($className)) {
if ($application->isClient('api')) {
$className = ApiDispatcher::class;
} else {
$className = ComponentDispatcher::class;
}
}
return new $className($application, $input ?: $application->input, $this->mvcFactory);
}
}
The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.