Back to RouterFactory class

Method createRouter

public \Joomla\CMS\Component\Router\RouterInterface
createRouter
(\Joomla\CMS\Application\CMSApplicationInterface $application, \Joomla\CMS\Menu\AbstractMenu $menu)
Creates a router.
Parameters
  • \Joomla\CMS\Application\CMSApplicationInterface $application The application
  • \Joomla\CMS\Menu\AbstractMenu $menu The menu object to work with
Returns
  • \Joomla\CMS\Component\Router\RouterInterface
Since
  • 4.0.0
Class: RouterFactory
Project: Joomla

Method createRouter - Source code

/**
 * 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);
}