Example #1
0
 public function run()
 {
     $route = $this->router->match($this->request);
     if ($route === false) {
         $actionName = self::ACTION_NOT_FOUND;
     } else {
         $actionName = $route->getName();
     }
     if (!$this->actions->has($actionName)) {
         throw new \Exception(sprintf('Action %s not found', $actionName));
     }
     $this->store->setFileName($actionName);
     if ($this->request->isAjax()) {
         $this->view->setRenderType(View::RENDER_JSON);
     } else {
         $this->view->setContentView('error');
     }
     $action = $this->actions->get($actionName);
     call_user_func_array($action, array($this));
     if (is_callable($this->postAction)) {
         call_user_func_array($this->postAction, array($this));
     }
     $this->response->setContent($this->view->render());
     $this->response->send();
 }