public \Joomla\CMS\Component\Router\RouterInterface
createRouter
(\Joomla\CMS\Application\CMSApplicationInterface $application, \Joomla\CMS\Menu\AbstractMenu $menu)
/**
* Returns the router.
*
* @param CMSApplicationInterface $application The application object
* @param AbstractMenu $menu The menu object to work with
*
* @return RouterInterface
*
* @since 4.0.0
*/
public function createRouter(CMSApplicationInterface $application, AbstractMenu $menu) : RouterInterface
{
$compname = ucfirst($this->component);
$class = $compname . 'Router';
if (!class_exists($class)) {
// Use the component routing handler if it exists
$path = JPATH_SITE . '/components/com_' . $this->component . '/router.php';
// Use the custom routing handler if it exists
if (is_file($path)) {
require_once $path;
}
}
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
if (\in_array('Joomla\\CMS\\Component\\Router\\RouterInterface', $reflection->getInterfaceNames())) {
return new $class($application, $menu);
}
}
return new RouterLegacy($compname);
}