Ejemplo n.º 1
0
 public static function startForWebRequest($root_path = null)
 {
     try {
         Clover::$current_task_uuid = uniqid();
         Clover::LogRequest();
         if ($root_path !== null) {
             Clover::setRootPath($root_path);
         }
         $controller_name = Clover::getController($sub_paths);
         if (empty($controller_name)) {
             $controller_name = Clover::$default_controller_name;
         }
         if (class_exists($controller_name)) {
             $controller = new $controller_name();
             if (!is_a($controller, 'CloverController')) {
                 throw new Exception($controller_name, -404);
             }
         } else {
             throw new Exception($controller_name, -404);
         }
         if (!empty($sub_paths)) {
             $func_name = $sub_paths[0];
             if (method_exists($controller, $func_name)) {
                 unset($sub_paths[0]);
                 call_user_func_array(array($controller, $func_name), array_values($sub_paths));
             } else {
                 throw new Exception($controller_name . "->" . $func_name, -404);
             }
         } else {
             $controller->index();
         }
     } catch (Exception $e) {
         if ($e->getCode() == -404) {
             //Page Not Found
             Clover::displayPageNotFound();
         } else {
             Clover::displayError($e);
         }
     }
 }