public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();
        if (!$configuration = $request->attributes->get('_cache')) {
            return;
        }

        $response = new Response();

        $lastModifiedDate = '';
        if ($configuration->getLastModified()) {
            $lastModifiedDate = $this->getExpressionLanguage()->evaluate($configuration->getLastModified(), $request->attributes->all());
            $response->setLastModified($lastModifiedDate);
        }

        $etag = '';
        if ($configuration->getEtag()) {
            $etag = hash('sha256', $this->getExpressionLanguage()->evaluate($configuration->getEtag(), $request->attributes->all()));
            $response->setEtag($etag);
        }

        if ($response->isNotModified($request)) {
            $event->setController(function () use ($response) {
                return $response;
            });
            $event->stopPropagation();
        } else {
            if ($etag) {
                $this->etags[$request] = $etag;
            }
            if ($lastModifiedDate) {
                $this->lastModifiedDates[$request] = $lastModifiedDate;
            }
        }
    }
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();
        if (!$configuration = $request->attributes->get('_cache')) {
            return;
        }

        $response = new Response();

        $lastModifiedDate = '';
        if ($configuration->getLastModified()) {
            $lastModifiedDate = $this->getExpressionLanguage()->evaluate($configuration->getLastModified(), $request->attributes->all());
            $response->setLastModified($lastModifiedDate);
        }

        $etag = '';
        if ($configuration->getEtag()) {
            $etag = hash('sha256', $this->getExpressionLanguage()->evaluate($configuration->getEtag(), $request->attributes->all()));
            $response->setEtag($etag);
        }

        if ($response->isNotModified($request)) {
            $event->setController(function () use ($response) {
                return $response;
            });
            $event->stopPropagation();
        } else {
            if ($etag) {
                $this->etags[$request] = $etag;
            }
            if ($lastModifiedDate) {
                $this->lastModifiedDates[$request] = $lastModifiedDate;
            }
        }
    }
public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ configuration = $ request -> attributes -> get ( '_cache' ) ) { return ; } $ response = new Response ( ) ; $ lastModifiedDate = '' ; if ( $ configuration -> getLastModified ( ) ) { $ lastModifiedDate = $ this -> getExpressionLanguage ( ) -> evaluate ( $ configuration -> getLastModified ( ) , $ request -> attributes -> all ( ) ) ; $ response -> setLastModified ( $ lastModifiedDate ) ; } $ etag = '' ; if ( $ configuration -> getEtag ( ) ) { $ etag = hash ( 'sha256' , $ this -> getExpressionLanguage ( ) -> evaluate ( $ configuration -> getEtag ( ) , $ request -> attributes -> all ( ) ) ) ; $ response -> setEtag ( $ etag ) ; } if ( $ response -> isNotModified ( $ request ) ) { $ event -> setController ( function ( ) use ( $ response ) { return $ response ; } ) ; $ event -> stopPropagation ( ) ; } else { if ( $ etag ) { $ this -> etags [ $ request ] = $ etag ; } if ( $ lastModifiedDate ) { $ this -> lastModifiedDates [ $ request ] = $ lastModifiedDate ; } } }
Handles HTTP validation headers.
Handles HTTP validation headers .