/** * @param IURLGenerator $urlGenerator * @param string $appName * @param \Exception $exception * * @return RedirectResponse */ public function htmlError($urlGenerator, $appName, Exception $exception) { $message = $exception->getMessage(); $code = $this->getHttpStatusCode($exception); $url = $urlGenerator->linkToRoute($appName . '.page.error_page', ['code' => $code]); $response = new RedirectResponse($url); $response->addCookie('galleryErrorMessage', $message); return $response; }
/** * Redirects the client to an error page * * @param string $message * @param int $code * * @return RedirectResponse */ private function redirectToErrorPage($message, $code) { $url = $this->urlGenerator->linkToRoute($this->appName . '.page.error_page', ['code' => $code]); $response = new RedirectResponse($url); $response->addCookie('galleryErrorMessage', $message); return $response; }
/** * @NoAdminRequired * * Sends the file matching the fileId * * @param int $fileId the ID of the file we want to download * @param string|null $filename * * @return ImageResponse */ public function download($fileId, $filename = null) { try { $download = $this->getDownload($fileId, $filename); } catch (ServiceException $exception) { $code = $this->getHttpStatusCode($exception); $url = $this->urlGenerator->linkToRoute($this->appName . '.page.error_page', ['code' => $code]); $response = new RedirectResponse($url); $response->addCookie('galleryErrorMessage', $exception->getMessage()); return $response; } // That's the only exception out of all the image media types we serve if ($download['mimetype'] === 'image/svg+xml') { $download['mimetype'] = 'text/plain'; } return new ImageResponse($download); }