예제 #1
0
 public function execute()
 {
     $this->controller = new Controller($this->path);
     $this->static_server = new StaticServer($this->path);
     Current::$plugins->hook('prePathParse', $this->controller, $this->static_server);
     if ($this->static_server->isFile()) {
         Current::$plugins->hook('preStaticServe', $this->static_server);
         // Output the file
         $this->static_server->render();
         Current::$plugins->hook('postStaticServe', $this->static_server);
         exit;
     }
     // Parse arguments from path and call appropriate command
     Cowl::timer('cowl parse');
     $request = $this->controller->parse();
     Cowl::timerEnd('cowl parse');
     if (COWL_CLI) {
         $this->fixRequestForCLI($request);
     }
     $command = new $request->argv[0]();
     // Set template directory, which is the command directory mirrored
     $command->setTemplateDir(Current::$config->get('paths.view') . $request->app_directory);
     Current::$plugins->hook('postPathParse', $request);
     Cowl::timer('cowl command run');
     $ret = $command->run($request);
     Cowl::timerEnd('cowl command run');
     Current::$plugins->hook('postRun');
     if (is_string($ret)) {
         Cowl::redirect($ret);
     }
 }