Sets a cookie to the response containing the CRSF token.

@param FilterResponseEvent $event
177674
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (
            HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
            ||
            !$this->routeMatcher->match($event->getRequest(), $this->routes)
        ) {
            return;
        }
        $event->getResponse()->headers->setCookie(new Cookie(
            $this->cookieName,
            $this->angularCsrfTokenManager->getToken()->getValue(),
            0 === $this->cookieExpire ? $this->cookieExpire : time() + $this->cookieExpire,
            $this->cookiePath,
            $this->cookieDomain,
            $this->cookieSecure,
            false
        ));
    }
1154953
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($event->isMasterRequest()
            || $event->getRequest()->attributes->get('_controller') !== $this->exceptionController) {
            return;
        }

        // Status code is not set by the exception controller but only by the
        // kernel at the very end.
        // So lets use the status code from the flatten exception instead.
        $statusCode = $event->getRequest()->attributes->get('exception')->getStatusCode();

        $dir = $this->getGifDir($statusCode);
        $gif = $this->getRandomGif($dir);
        $url = $this->getGifUrl($dir, $gif);

        $content = $event->getResponse()->getContent();

        if (version_compare(Kernel::VERSION, '3.2', '<')) {
            $content = preg_replace(
                '/<img alt="Exception detected!" src=".*" \/>/',
                sprintf('<img alt="Exception detected!" src="%s" data-gif style="width:145px" />', $url),
                $content
            );
        } elseif (version_compare(Kernel::VERSION, '3.3', '<')) {
            $content = preg_replace(
                '@<svg xmlns="http://www.w3.org/2000/svg" width="112"(.*?)</svg>@ims',
                sprintf('<img alt="Exception detected!" src="%s" data-gif style="width:145px" />', $url),
                $content
            );
        } else {
            $content = preg_replace(
                '@<div class="exception-illustration hidden-xs-down">(.*?)</div>@ims',
                sprintf('<div class="exception-illustration hidden-xs-down" style="opacity:1"><img alt="Exception detected!" src="%s" data-gif style="height:66px" /></div>', $url),
                $content
            );
        }

        $event->getResponse()->setContent($content);
    }
458930
public function onKernelResponse(FilterResponseEvent $event): void
    {
        $request = $event->getRequest();
        $response = $event->getResponse();

        if (
            !$request->isMethodCacheable()
            || !$response->isCacheable()
            || (!$attributes = RequestAttributesExtractor::extractAttributes($request))
        ) {
            return;
        }

        $resources = $request->attributes->get('_resources');
        if (isset($attributes['collection_operation_name']) || ($attributes['subresource_context']['collection'] ?? false)) {
            // Allows to purge collections
            $iri = $this->iriConverter->getIriFromResourceClass($attributes['resource_class']);
            $resources[$iri] = $iri;
        }

        if (!$resources) {
            return;
        }

        $response->headers->set('Cache-Tags', implode(',', $resources));
    }
994988
public function onResponseLate(FilterResponseEvent $event)
    {
        if (!$this->eventRequestMatches($event)) {
            return;
        }
        $this->responseTransformer->transformLate($event->getRequest(), $event->getResponse());
    }
411409
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if (Zone::get($request)) {
            return;
        }

        $this->setZone($request);
    }
364481
public function doResponse(FilterResponseEvent $event)
    {
        // Skip if the default thelia prefix is used
        if (!$event->getRequest()->attributes->get(BackOfficePath::IS_CUSTOM_ADMIN_PATH)) {
            return;
        }

        // Replace default admin url by custom one
        $prefix = ConfigQuery::read(BackOfficePath::CONFIG_PATH);

        $pathInfo = $event->getRequest()->getPathInfo();

        if (BackOfficePath::matchPath($pathInfo, BackOfficePath::DEFAULT_THELIA_PREFIX)
            && $prefix !== null
            && $prefix !== ''
        ) {
            $response = $event->getResponse();

            if ($response instanceof RedirectResponse) {
                $targetUrl = $response->getTargetUrl();

                if (BackOfficePath::matchUrl($targetUrl, BackOfficePath::DEFAULT_THELIA_PREFIX)) {
                    $newUrl = BackOfficePath::replaceUrl($targetUrl, BackOfficePath::DEFAULT_THELIA_PREFIX, $prefix);
                    $response->setTargetUrl($newUrl);
                }
            } elseif (! ($response instanceof BinaryFileResponse || $response instanceof StreamedResponse)) {
                // We can't change response content for Binary or Streamed Response
                try {
                    $content = BackOfficePath::replaceUrl(
                        $response->getContent(),
                        BackOfficePath::DEFAULT_THELIA_PREFIX,
                        $prefix
                    );

                    $response->setContent($content);
                } catch (\LogicException $ex) {
                    // Ignore LogicExceptions, thrown when response content cannot be set
                }
            }
        }
    }
387061
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }
        if ($this->debug) {
            $this->logResponse($event->getResponse());
        }
    }
1063060
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->handleResponse && $this->http_code !== null) {
            $response = $event->getResponse();
            $response->setStatusCode($this->http_code, $this->http_status);
        }
    }
1053781
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        if (!$this->csrfTokenManager instanceof CsrfTokenManagerInterface) {
            return;
        }

        $request = $event->getRequest();

        if ($request->isMethodCacheable()) {
            return;
        }

        if ($request->attributes->get('_route') !== $this->routeName) {
            return;
        }

        $session = $event->getRequest()->getSession();
        if (!$session->isStarted()) {
            return;
        }

        if ($request->headers->get('X-CSRF-Token') !== null) {
            return;
        }

        $csrfToken = $this->csrfTokenManager->getToken($this->csrfTokenId)->getValue();

        $request->headers->set('X-CSRF-Token', $csrfToken);
    }
1343274
public function onRequestEarly(GetResponseEvent $event)
    {
        $validator = $this->app['config.validator'];
        $response = $validator->checks();
        if ($response instanceof Response) {
            $event->setResponse($response);
        }
    }
1333190
public function onRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $request->setSession($this->session);

        $this->prependBasePathToCookie($request);
        $this->appendRealmToName($request);

        $name = $this->session->getName();
        if ($request->cookies->has($name)) {
            $this->session->setId($request->cookies->get($name));
            $this->session->start();
        }
    }
295788
public function onKernelReponse(FilterResponseEvent $event)
    {
        $request  = $event->getRequest();
        $response = $event->getResponse();
        $route    = $this->routes->get($request->attributes->get('_route'));

        if ($route && $route->isMapped()) {
            $url          = $request->attributes->get('_canonical');
            $lastModified = new DateTime($response->headers->get('Last-Modified'));
            $this->sitemap->add($url, $lastModified);
        }
    }
1254785
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->configurationHandler->isRedirectOption(PlatformDefaults::$REDIRECT_OPTIONS['LAST'])) {
            $this->saveLastUri($event);
        }
    }
391086
public function tagUserContext(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        if (!$response->isCacheable()) {
            return;
        }

        if ($response->headers->get('Content-Type') !== 'application/vnd.fos.user-context-hash') {
            return;
        }

        if (!$response->getTtl()) {
            return;
        }

        // We need to set tag directly on repsonse here to make sure this does not also get applied to the main request
        // when using Symfony Proxy, as tag handler does not clear tags between requests.
        $response->headers->set($this->tagHeader, $this->repoPrefix . 'ez-user-context-hash');
    }
615892
public function onKernelResponse(FilterResponseEvent $e)
    {
        if (isset($this->log)) {
            if ($e->getRequestType() === HttpKernelInterface::MASTER_REQUEST
                && ($status = $e->getResponse()->getStatusCode()) >= 400
            ) {
                $this->log->setStatus($status);
                $this->logging->flush($this->log);
            }
        }
    }
1307104
public function onKernelResponse(FilterResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $layoutView = $event->getRequest()->attributes->get(
            $this->isExceptionResponse ?
                'ngbmExceptionLayoutView' :
                'ngbmLayoutView'
        );

        if (!$layoutView instanceof LayoutViewInterface) {
            return;
        }

        $this->tagger->tagLayout($event->getResponse(), $layoutView->getLayout());
    }
153785
public function onKernelResponse(FilterResponseEvent $event)
    {
        // Only for Sub Requests
        $subRequest = $event->getRequest();
        if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
            return;
        }

        // Check if Annotation is present
        if (!$configuration = $subRequest->attributes->get('_andres_montanez_fragment_cache', false)) {
            return;
        }

        // If Key is present, save content for that key, expiration saved in seconds retreived in minutes
        if (($key = $subRequest->attributes->get('_andres_montanez_fragment_cache_key', false)) !== false) {
            if ($this->enabled) {
                $this->cache->set(
                    $key,
                    $event->getResponse()->getContent(),
                    $configuration->getExpiration() * 60
                );

                $fragment = '';
                if ($this->debug) {
                    $fragment .= '<!-- MISS - Begin Fragment Cache for KEY: ' . $key . ' -->';
                }

                $fragment .= $event->getResponse()->getContent();

                if ($this->debug) {
                    $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->';
                }

                $event->getResponse()->setContent($fragment);

            } else if (!$this->enabled) {
                $fragment = '';
                if ($this->debug) {
                    $fragment .= '<!-- DISABLED - Begin Fragment Cache for KEY: ' . $key . ' -->';
                }

                $fragment .= $event->getResponse()->getContent();

                if ($this->debug) {
                    $fragment .= '<!-- End Fragment Cache for KEY: ' . $key . ' -->';
                }

                $event->getResponse()->setContent($fragment);
            }
        }

        return;
    }