- md5
- 313d179c568d0e4f94c666facbdd6c6d
- sha1
- 769abca361af3784ccbe7237569a8ade32982817
- sha256
- f4db121154e1f294cacf93b1ce2bff78897b87555bd5dcb5a34f8595343a6494
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
<?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.txt
*/
namespace Joomla\CMS\Component\Router;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\Database\DatabaseInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Default router factory.
*
* @since 4.0.0
*/
class RouterFactory implements RouterFactoryInterface
{
/**
* The namespace to create the categories from.
*
* @var string
* @since 4.0.0
*/
private $namespace;
/**
* The category factory
*
* @var CategoryFactoryInterface
*
* @since 4.0.0
*/
private $categoryFactory;
/**
* The db
*
* @var DatabaseInterface
*
* @since 4.0.0
*/
private $db;
/**
* The namespace must be like:
* Joomla\Component\Content
*
* @param string $namespace The namespace
* @param ?CategoryFactoryInterface $categoryFactory The category object
* @param ?DatabaseInterface $db The database object
*
* @since 4.0.0
*/
public function __construct($namespace, ?CategoryFactoryInterface $categoryFactory = null, ?DatabaseInterface $db = null)
{
$this->namespace = $namespace;
$this->categoryFactory = $categoryFactory;
$this->db = $db;
}
/**
* Creates a router.
*
* @param CMSApplicationInterface $application The application
* @param AbstractMenu $menu The menu object to work with
*
* @return RouterInterface
*
* @since 4.0.0
*/
public function createRouter(CMSApplicationInterface $application, AbstractMenu $menu): RouterInterface
{
$className = trim($this->namespace, '\\') . '\\' . ucfirst($application->getName()) . '\\Service\\Router';
if (!class_exists($className)) {
throw new \RuntimeException('No router available for this application.');
}
return new $className($application, $menu, $this->categoryFactory, $this->db);
}
}
The same content is in 114 releases, Joomla 5.2.0-beta1 to 6.2.1-rc1. See them all, or every version of this file.