/**
  * Resizes an image
  *
  * @return Response
  *
  * @throws EntityNotFoundException Requested image does not exist
  */
 public function resizeAction()
 {
     $request = $this->requestStack->getCurrentRequest();
     $id = $request->get('id');
     /**
      * We retrieve image given its id
      */
     $image = $this->imageRepository->find($id);
     if (!$image instanceof ImageInterface) {
         throw new EntityNotFoundException($this->imageRepository->getClassName());
     }
     $response = new Response();
     $height = $request->get('height');
     $width = $request->get('width');
     $type = $request->get('type');
     $response->setEtag($this->imageEtagTransformer->transform($image, $height, $width, $type))->setLastModified($image->getUpdatedAt())->setStatusCode(304)->setPublic();
     /**
      * If the object has not been modified, we return the response.
      * Symfony will automatically put a 304 status in the response
      * in that case
      */
     if ($response->isNotModified($request)) {
         return $response;
     }
     $image = $this->imageManager->resize($image, $height, $width, $type);
     $imageData = $image->getContent();
     $response->setStatusCode(200)->setMaxAge($this->maxAge)->setSharedMaxAge($this->sharedMaxAge)->setContent($imageData);
     $response->headers->add(array('Content-Type' => $image->getContentType()));
     return $response;
 }
 /**
  * Resizes an image
  *
  * @return Response Response generated
  *
  * @throws RuntimeException        Request not found
  * @throws EntityNotFoundException Requested image does not exist
  */
 public function resizeAction()
 {
     $request = $this->requestStack->getCurrentRequest();
     /**
      * Request not found because this controller is not running under
      * Request scope
      */
     if (!$request instanceof Request) {
         throw new RuntimeException('Request object not found');
     }
     $id = $request->get('id');
     /**
      * We retrieve image given its id
      */
     $image = $this->imageRepository->find($id);
     if (!$image instanceof ImageInterface) {
         throw new EntityNotFoundException($this->imageRepository->getClassName());
     }
     return $this->buildResponseFromImage($request, $image);
 }