Пример #1
0
 public function routing()
 {
     $live = Live::getInstance();
     // Getting arguments
     if (!empty($live->_request[2])) {
         for ($i = 2; $i < count($live->_request); $i++) {
             $live->_args[] = $live->_request[$i];
         }
     }
     // Finding modules actions
     if (!empty($live->_request[0])) {
         $controller_name = $live->_request[0];
         $controller_name[0] = strtoupper($controller_name[0]);
         $action_name = !empty($live->_request[1]) ? $live->_request[1] : 'index';
         $module = new \Modules\Module($controller_name, true);
         if ($module->checkActionExists($action_name . 'Action')) {
             $live->_controllers[] = $controller_name;
             $live->_actions[] = $action_name;
         }
     }
     // Finding routes
     $router = new \Router\Router();
     $findRoute = $router->findByRequest($live->_request);
     if ($findRoute) {
         $live->_controllers[] = $findRoute->controller;
         $live->_actions[] = $findRoute->action;
     }
     // Finding pages
     $page = new \Pages\Page();
     $findPage = $page->findByRequest($live->_request);
     if ($findPage) {
         $live->_controllers[] = 'Pages';
         $live->_actions[] = 'index';
     }
 }