/** * {@inheritDoc} * @return ApiProblemRenderer */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $displayExceptions = isset($config['view_manager']) && isset($config['view_manager']['display_exceptions']) && $config['view_manager']['display_exceptions']; $renderer = new ApiProblemRenderer(); $renderer->setDisplayExceptions($displayExceptions); return $renderer; }
/** * @param ContainerInterface $container * @return ApiProblemRenderer */ public function __invoke(ContainerInterface $container) { $config = $container->get('config'); $displayExceptions = isset($config['view_manager']) && isset($config['view_manager']['display_exceptions']) && $config['view_manager']['display_exceptions']; $renderer = new ApiProblemRenderer(); $renderer->setDisplayExceptions($displayExceptions); return $renderer; }
/** * Render an API-Problem result * * Creates an ApiProblemModel with the provided ApiProblem, and passes it * on to the composed ApiProblemRenderer to render. * * If a ViewEvent is composed, it passes the ApiProblemModel to it so that * the ApiProblemStrategy can be invoked when populating the response. * * @param ApiProblem $problem * @return string */ protected function renderApiProblem(ApiProblem $problem) { $model = new ApiProblemModel($problem); $event = $this->getViewEvent(); if ($event) { $event->setModel($model); } return $this->apiProblemRenderer->render($model); }