Example #1
0
 /**
  * @return Response
  * @throws ActionNotFoundException
  */
 private function invokeController()
 {
     $eventManager = $this->container->getEventManager();
     $controller = new $this->className($this->request, $this->container);
     if (!is_callable([$controller, $this->methodName])) {
         throw new ActionNotFoundException($this->className, $this->methodName);
     }
     $response = null;
     $controllerData = call_user_func_array([$controller, $this->methodName], $this->request->getArguments());
     if ($controllerData instanceof Response) {
         $response = $controllerData;
     } else {
         $response = new Response();
         $response->setContent($controllerData);
     }
     if (!$response->getPresenter()) {
         $response->setPresenter($this->getPresenter());
     }
     $event = new ExecutedActionEvent($this->request, $response);
     $eventManager->fire('executedAction', $event);
     return $response;
 }