Exemple #1
0
 /**
  * Will attempt to find an item based on the current URL, and route it through a controller before returning a 404 error
  * 
  * @access  public
  * @return  Response
  */
 public function action_catchall()
 {
     // Will try to find the model based on the URL
     $model = $this->model = \CMF::currentModel();
     \CMF::$routed = true;
     // Return the normal 404 error if not found
     if (is_null($model)) {
         $action = trim(\Input::uri(), '/');
         if (!empty($action)) {
             return \Request::forge('base/' . $action, false)->execute()->response();
         }
         return $this->show404();
     }
     // So the model was found - check if it has a controller to route to
     $template = \CMF::$template;
     $action = \CMF::$action;
     if (\CMF::hasController($template)) {
         $module = \CMF::$module;
         $path = \CMF::$path;
         $route = (empty($module) ? '' : $module . '/') . $path . (empty($action) ? '' : '/' . $action);
         return \Request::forge($route, false)->execute()->response();
     } else {
         if (!empty($action)) {
             return $this->show404();
         } else {
             if (\CMF::$root) {
                 return \Request::forge('base/' . $action, false)->execute()->response();
             }
         }
     }
 }