- md5
- d9b698607147597536a85d141d36f1fe
- sha1
- 5f96b4446f192fbfd127c4a22ede4cfcf8a265d2
- sha256
- 25666cfaf10182d067b4cf4c53f5fdb69a91a50170e830f7cc2cc9351372fb07
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Component\Router;
\defined('_JEXEC') or die;
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.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.