コード例 #1
0
ファイル: httperror.php プロジェクト: patman15/galleryplus
 /**
  * @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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * @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);
 }