- md5
- b75b852d209e172e93ad344203e92c7f
- sha1
- aaeab7f0a60a2c2dda5730ff496fac7772549853
- sha256
- e54aa0364f8f701d2a184ffd8d8f60b29b62f3f4b797b74f8a35206eb709a23d
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<?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;
/**
* 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 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.