本文整理汇总了PHP中Zend\Mvc\Router\Http\TreeRouteStack::setRoutePluginManager方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeRouteStack::setRoutePluginManager方法的具体用法?PHP TreeRouteStack::setRoutePluginManager怎么用?PHP TreeRouteStack::setRoutePluginManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\Http\TreeRouteStack
的用法示例。
在下文中一共展示了TreeRouteStack::setRoutePluginManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createService
/**
* Create and return the router
*
* Retrieves the "router" key of the Config service, and uses it
* to instantiate the router. Uses the TreeRouteStack implementation by
* default.
*
* @param ServiceLocatorInterface $serviceLocator
* @param string|null $cName
* @param string|null $rName
* @return \Zend\Mvc\Router\RouteStackInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
{
$config = $serviceLocator->get('Config');
$routePluginManager = $serviceLocator->get('RoutePluginManager');
if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) {
// We are in a console, use console router.
if (isset($config['console']) && isset($config['console']['router'])) {
$routerConfig = $config['console']['router'];
} else {
$routerConfig = array();
}
$router = new ConsoleRouter($routePluginManager);
} else {
// This is an HTTP request, so use HTTP router
$router = new HttpRouter($routePluginManager);
$routerConfig = isset($config['router']) ? $config['router'] : array();
}
if (isset($routerConfig['route_plugins'])) {
$router->setRoutePluginManager($routerConfig['route_plugins']);
}
if (isset($routerConfig['routes'])) {
$router->addRoutes($routerConfig['routes']);
}
if (isset($routerConfig['default_params'])) {
$router->setDefaultParams($routerConfig['default_params']);
}
return $router;
}