Beispiel #1
0
 /**
  * Execute controller method
  *
  * @throws \Arbor\Exception\ActionNotFoundException
  * @since 0.1.0
  */
 protected function callMethod()
 {
     $this->resources->registerPresenter($this->getPresenter());
     $response = new Response();
     $response->setPresenter($this->resources->getPresenter());
     $event = new ExecuteActionEvent($this->request);
     $this->eventManager->fire('executeAction', $event);
     if (!$event->getResponse()) {
         $controllerName = $this->request->getClass();
         $controller = new $controllerName($this->request, $this->resources);
         if (!is_callable(array($controller, $this->request->getMethod()))) {
             throw new ActionNotFoundException($controllerName, $this->request->getMethod());
         }
         $controllerData = call_user_func_array(array($controller, $this->request->getMethod()), $this->request->getArguments());
         if ($controllerData instanceof Response) {
             $response = $controllerData;
             if (!$response->getPresenter()) {
                 $response->setPresenter($this->resources->getPresenter());
             } else {
                 $this->resources->registerPresenter($response->getPresenter());
             }
         } else {
             $response->setContent($controllerData);
         }
         $event = new ExecutedActionEvent($this->request, $response);
         $this->eventManager->fire('executedAction', $event);
     } else {
         $response = $event->getResponse();
     }
     $this->resources->registerResponse($response);
     $this->prepareView($this->request, $this->resources->getPresenter(), $response);
 }