logger = new NullLogger(); } public function setLogger(LoggerInterface $logger) { $this->logger = $logger; } public function setTranslator(TranslatorInterface $translator) { $this->translator = $translator; } public function createResponseBasedOnRequest(Request $request, $exception) { return parent::createResponse($exception); } public function getContent(FlattenException $exception) { if ($exception->getStatusCode() == '500') { $this->logger->error($exception->getMessage(), [ 'code' => $exception->getCode(), 'trace' => $exception->getTrace() ]); } switch (true) { case 404 === $exception->getStatusCode(): if (null !== $this->translator) { $title = $this->translator->trans('Sorry, the page you are looking for could not be found.'); } else { $title = 'Sorry, the page you are looking for could not be found.'; } break; case 403 === $exception->getStatusCode(): if (null !== $this->translator) { $title = $this->translator->trans('Sorry, you do have access to the page you are looking for.'); } else { $title = 'Sorry, you do have access to the page you are looking for.'; } break; case 500 === $exception->getStatusCode(): if (null !== $this->translator) { $title = $this->translator->trans('Whoops, looks like something went wrong.'); } else { $title = 'Whoops, looks like something went wrong.'; } break; case 503 === $exception->getStatusCode(): if (null !== $this->translator) { $title = $this->translator->trans('Sorry, site is currently undergoing maintenance, come back soon.'); } else { $title = 'Sorry, site is currently undergoing maintenance, come back soon.'; } break; case isset(Response::$statusTexts[$exception->getStatusCode()]): $title = $exception->getStatusCode() . ' : ' . Response::$statusTexts[$exception->getStatusCode()]; break; default: if (null !== $this->translator) { $title = $this->translator->trans('Whoops, looks like something went wrong.'); } else { $title = 'Whoops, looks like something went wrong.'; } } $content = parent::getContent($exception); $start = strpos($content, ''); $content = '