/**
  * @param resource $logo
  * @param string $id
  * @param int $width
  * @param int $height
  * @param Request $request
  * @param Response $response
  */
 public function resize(Logo $logo, $width, $height, Request $request, Response $response)
 {
     $path = $this->getPath('logo_' . $logo->getId(), $width, $height);
     $response->setPublic();
     $response->setContentType($logo->getMimeType());
     $response->setLastModified($logo->getCreatedAt());
     if ($response->isNotModified($request)) {
         return;
     }
     if (file_exists($path)) {
         return file_get_contents($path);
     }
     $image = $this->factory->createFromResource($logo->getImage());
     return $this->getImageContent($image, $path, $width, $height, array($this->resizer, 'scale'));
 }
Example #2
0
 /**
  * Handle the exception (converting to internal server error if needed) and
  * showing a the error content
  *
  * @param Exception $error
  */
 public function handle(Exception $error)
 {
     if (!$error instanceof HttpException) {
         $error = new InternalServerError($error->getMessage(), null, $error);
     }
     $this->response->setStatusCode($error->getStatusCode());
     $this->response->setContent($this->getErrorContent($error));
     $this->logError($error);
 }