/**
  * 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);
 }
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * 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);
 }