Back to ConsoleApplication class

Method getRouter

public static \Joomla\CMS\Router\Router
getRouter
(mixed $name = null, array $options = array())
Returns the application Router object.
Parameters
  • string $name The name of the application.
  • array $options An optional associative array of configuration settings.
Returns
  • \Joomla\CMS\Router\Router
Since
  • 4.0.6
-
  • \InvalidArgumentException

Method getRouter - Source code

/**
 * Returns the application Router object.
 *
 * @param   string  $name     The name of the application.
 * @param   array   $options  An optional associative array of configuration settings.
 *
 * @return  Router
 *
 * @since   4.0.6
 * @throws  \InvalidArgumentException
 */
public static function getRouter($name = null, array $options = array())
{
    if (empty($name)) {
        throw new InvalidArgumentException('A router name must be set in console application.');
    }
    $options['mode'] = Factory::getApplication()->get('sef');
    return Router::getInstance($name, $options);
}