Back to SiteRouter class

Method setComponentRouter

public bool
setComponentRouter
(mixed $component, mixed $router)
Set a router for a component
Parameters
  • string $component Component name with com_ prefix
  • object $router Component router
Returns
  • bool True if the router was accepted, false if not
Since
  • 3.3
Class: SiteRouter
Project: Joomla

Method setComponentRouter - Source code

/**
 * Set a router for a component
 *
 * @param   string  $component  Component name with com_ prefix
 * @param   object  $router     Component router
 *
 * @return  boolean  True if the router was accepted, false if not
 *
 * @since   3.3
 */
public function setComponentRouter($component, $router)
{
    $reflection = new \ReflectionClass($router);
    if (\in_array('Joomla\\CMS\\Component\\Router\\RouterInterface', $reflection->getInterfaceNames())) {
        $this->componentRouters[$component] = $router;
        return true;
    } else {
        return false;
    }
}