本文整理汇总了PHP中zibo\core\Zibo::getRouter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zibo::getRouter方法的具体用法?PHP Zibo::getRouter怎么用?PHP Zibo::getRouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zibo\core\Zibo
的用法示例。
在下文中一共展示了Zibo::getRouter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* Gets a request from the provided path for request chaining
* @param string $path The path to route
* @return zibo\core\Request|null A request if the path was found, null otherwise
*/
protected function route($path)
{
$router = $this->zibo->getRouter();
if (!$router) {
return null;
}
return $router->getRequest($this->request->getBaseUrl(), $path);
}
示例2: getRoutes
/**
* Gets all the routes from Zibo
* @param zibo\core\Zibo $zibo Instance of Zibo
* @return array Array with the route as key and a Route object as value
*/
private function getRoutes(Zibo $zibo)
{
$router = $zibo->getRouter();
$routes = $router->getRoutes();
ksort($routes);
return $routes;
}
示例3: setDefaultAction
/**
* Sets the default action and controller to the router
* @param zibo\core\Zibo $zibo
* @return null
*/
private function setDefaultAction(Zibo $zibo)
{
$router = $zibo->getRouter();
if ($router === null) {
$router = new GenericRouter();
$zibo->setRouter($router);
}
if (!$router instanceof GenericRouter) {
return;
}
$defaultController = $router->getDefaultController();
if ($defaultController) {
return;
}
$defaultController = $zibo->getConfigValue(self::CONFIG_CONTROLLER_DEFAULT, self::CONTROLLER_DEFAULT);
$router->setDefaultAction($defaultController);
}