Example #1
0
 private function process()
 {
     $info = self::get_info();
     /*
      * rotas
      */
     if ($routes = Route::get_routes()) {
         if (array_key_exists($info, $routes)) {
             $route = $routes[$info];
             if (is_object($route)) {
                 $route();
             } elseif (is_array($route)) {
                 $module = isset($route['module']) ? $route['module'] : NULL;
                 $controller = isset($route['controller']) ? $route['controller'] : NULL;
                 $method = isset($route['method']) ? $route['method'] : NULL;
                 $this->dispache($module, $controller, $method);
             }
             return true;
         }
     }
     /*
      * rota padrão caso info seja vazio 
      */
     if (empty($info)) {
         $route_default = Route::get_route_default();
         if (!empty($route_default)) {
             $info = $route_default;
         }
     }
     /*
      * explode info
      */
     if (isset($info)) {
         $url_string = explode('/', strtolower(trim($info, '/')));
         if ($url_string[0] == '') {
             $url_string = null;
         }
     }
     /*
      * valida e dispara método
      */
     $module = isset($url_string[0]) ? $url_string[0] : null;
     $controller = isset($url_string[1]) ? str_replace(' ', '', ucwords(str_replace('-', ' ', $url_string[1]))) : null;
     $method = isset($url_string[2]) ? str_replace('-', '_', $url_string[2]) : null;
     $this->dispache($module, $controller, $method);
 }