/** * Prepares the controller * @param Controller $controller The controller to prepare * @param Request $request The request for the controller * @param Response $response The response for the controller * @param string $actionName The method which will be invoked * @param array $parameters The parameters for that method * @return null */ protected function prepareController(Controller $controller, Request $request, Response $response, $actionName, array $parameters) { if (!$this->passRequestParameters) { $request = new Request($request->getBaseUrl(), $request->getBasePath(), $request->getControllerName(), Dispatcher::ACTION_INDEX); } $this->widget->setRequest($request); $this->widget->setResponse($response); }
/** * Gets the controller of a request. If the controller class name is the same as the clasa name * of the controller which is set through setController, the set controller will be used instead * of creating a new one. * @param Request $request * @return Controller * @throws zibo\ZiboException when no object factory has been set * @throws zibo\ZiboException when the controller could not be created */ protected function getController(Request $request) { try { $controller = $this->objectFactory->create($request->getControllerName(), self::INTERFACE_CONTROLLER); } catch (ZiboException $exception) { throw new ZiboException('Could not create controller ' . $request->getControllerName(), 0, $exception); } return $controller; }
/** * Gets the controller of a request. If the controller class name is the same as the clasa name * of the controller which is set through setController, the set controller will be used instead * of creating a new one. * @param Request $request * @return Controller * @throws zibo\ZiboException when no object factory has been set * @throws zibo\ZiboException when the controller could not be created */ protected function getController(Request $request) { if ($this->controller && $request->getControllerName() == get_class($this->controller)) { return $this->controller; } if ($this->objectFactory === null) { throw new ZiboException('Could not create controller ' . $request->getControllerName() . ': no ObjectFactory set'); } try { $controller = $this->objectFactory->create($request->getControllerName(), self::INTERFACE_CONTROLLER); } catch (ZiboException $e) { throw new ZiboException('Could not create controller ' . $request->getControllerName(), 0, $e); } return $controller; }