public static \Joomla\CMS\Router\Router
getInstance
(mixed $client, mixed $options = array())
/**
* Returns the global Router object, only creating it if it
* doesn't already exist.
*
* @param string $client The name of the client
* @param array $options An associative array of options
*
* @return Router A Router object.
*
* @since 1.5
* @throws \RuntimeException
*/
public static function getInstance($client, $options = array())
{
if (empty(self::$instances[$client])) {
// Create a Router object
$classname = 'JRouter' . ucfirst($client);
if (!class_exists($classname)) {
throw new \RuntimeException(Text::sprintf('JLIB_APPLICATION_ERROR_ROUTER_LOAD', $client), 500);
}
// Check for a possible service from the container otherwise manually instantiate the class
if (Factory::getContainer()->has($classname)) {
self::$instances[$client] = Factory::getContainer()->get($classname);
} else {
self::$instances[$client] = new $classname();
}
}
return self::$instances[$client];
}