private function buildResponseFromImage(
        Request $request,
        ImageInterface $image
    ) {
        $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())
            ->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->setStatusCode(304);
        }

        $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([
                'Content-Type' => $image->getContentType(),
            ]);

        return $response;
    }
private function buildResponseFromImage(
        Request $request,
        ImageInterface $image
    ) {
        $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())
            ->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->setStatusCode(304);
        }

        $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([
                'Content-Type' => $image->getContentType(),
            ]);

        return $response;
    }
private function buildResponseFromImage ( Request $ request , ImageInterface $ image ) { $ 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 ( ) ) -> 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 -> setStatusCode ( 304 ) ; } $ 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 ( [ 'Content-Type' => $ image -> getContentType ( ) , ] ) ; return $ response ; }
Create new response given a request and an image.

Fill some data to this response given some Image properties and check if
created Response has changed.

@param Request        $request Request
@param ImageInterface $image   Image

@return Response Created response
Create new response given a request and an image .