Filter the `core.response` event to decorate the action.

@param FilterResponseEvent $event

@throws InternalErrorException
555163
public function onCoreResponse(FilterResponseEvent $event)
    {
        $cms = $this->cmsSelector->retrieve();

        $response = $event->getResponse();
        $request = $event->getRequest();

        if ($this->cmsSelector->isEditor()) {
            $response->setPrivate();

            if (!$request->cookies->has('sonata_page_is_editor')) {
                $response->headers->setCookie(new Cookie('sonata_page_is_editor', '1'));
            }
        }

        $page = $cms->getCurrentPage();

        // display a validation page before redirecting, so the editor can edit the current page
        if (
            $page && $response->isRedirection() &&
            $this->cmsSelector->isEditor() &&
            !$request->get('_sonata_page_skip') &&
            !$this->skipRedirection
        ) {
            $response = new Response($this->templating->render('@SonataPage/Page/redirect.html.twig', [
                'response' => $response,
                'page' => $page,
            ]));

            $response->setPrivate();

            $event->setResponse($response);

            return;
        }

        if (!$this->decoratorStrategy->isDecorable($event->getRequest(), $event->getRequestType(), $response)) {
            return;
        }

        if (!$this->cmsSelector->isEditor() && $request->cookies->has('sonata_page_is_editor')) {
            $response->headers->clearCookie('sonata_page_is_editor');
        }

        if (!$page) {
            throw new InternalErrorException('No page instance available for the url, run the sonata:page:update-core-routes and sonata:page:create-snapshots commands');
        }

        // only decorate hybrid page or page with decorate = true
        if (!$page->isHybrid() || !$page->getDecorate()) {
            return;
        }

        $parameters = [
            'content' => $response->getContent(),
        ];

        $response = $this->pageServiceManager->execute($page, $request, $parameters, $response);

        if (!$this->cmsSelector->isEditor() && $page->isCms()) {
            $response->setTtl($page->getTtl());
        }

        $event->setResponse($response);
    }
253831
public function onEvent(Event $event): void
    {
        if (!$event instanceof GetResponseEvent || !$this->injected) {
            if (null !== ($filter = $this->getFilter())) {
                $this->injectParameters($filter);
            }
        }
    }
1126318
public function onResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        if (Zone::isAsync($request) || $request->isXmlHttpRequest()) {
            return;
        }

        $response = $event->getResponse();
        if ($response->isRedirection() || $response->isEmpty() || $response->isInformational()) {
            return;
        }
        if (strpos($response->headers->get('Content-Type'), 'text/html') === false) {
            return;
        }

        $this->addSnippets();

        foreach ($this->queues as $queue) {
            $queue->process($request, $response);
        }
    }
145589
public function setJsonRedirection(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();

        // no handle with ajax (except turbolinks)
        if ($event->getResponse() instanceof RedirectResponse && $request->isXmlHttpRequest()) {
            $uri = rtrim(explode('?', $request->getUri())[0], '/');
            $target = rtrim(explode('?', $targetUrl = $event->getResponse()->getTargetUrl())[0], '/');

            // when just sf route `/` matching redirect
            // most of index route end with `/` but we just enter `resources`
            // eg. `/users` may redirect to `/users/`
            if ($uri === $target) {
                return;
            }

            /** @var FlashBagInterface $flashes */
            $flashes = $event->getRequest()->getSession()->getFlashBag();
            $headers = array(
                'x-location' => $targetUrl,
                'x-flashes' => $flashes ? json_encode($flashes->all()) : null
            );

            $event->setResponse(new Response(null, 204, $headers));
        }
    }
1081428
private function send(Response $response, $type = self::MASTER_REQUEST)
    {
        if (null !== $this->application && null !== $this->application->getEventDispatcher()) {
            $event = new FilterResponseEvent($this, $this->getRequest(), $type, $response);
            $this->application->getEventDispatcher()->dispatch('frontcontroller.response', $event);
            $this->application->getEventDispatcher()->dispatch(KernelEvents::RESPONSE, $event);
        }

        $response->send();
        $this->response = $response;
        $this->application->stop();
    }
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);
            }
        }
    }
87104
public function onKernelResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        if ($request->attributes->get('schemaRequest', false)) {
            $response = $event->getResponse();
            $linkHeader = LinkHeader::fromResponse($response);

            $routeName = SchemaUtils::getSchemaRouteName($request->get('_route'));
            $url = $this->router->generate($routeName, [], UrlGeneratorInterface::ABSOLUTE_URL);

            // append rel=canonical link to link headers
            $linkHeader->add(new LinkHeaderItem($url, array('rel' => 'canonical')));

            // overwrite link headers with new headers
            $response->headers->set('Link', (string) $linkHeader);

            $event->setResponse($response);
        }
    }
1261887
public function onResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();

        if ($request->isMethodSafe(false)) {
            return;
        }

        // In case we're using 'preview', the `_route` has been set to `contentlink`, because we're
        // viewing a single page, but `_original_route` will be `preview`, which should take
        // precedence, if set. See PR https://github.com/bolt/bolt/pull/7458
        /** @deprecated since 3.4 to be removed in 4.0 */
        $route = $request->attributes->get('_internal_route', $request->attributes->get('_route'));

        if (!in_array($route, $this->routes)) {
            return;
        }

        $response = $event->getResponse();

        if ($response->isRedirection() || $response->isEmpty() || $response->isInformational()) {
            return;
        }

        $response->headers->set('X-XSS-Protection', 0);
    }
297829
private function allowRender(FilterResponseEvent $event)
    {
        // not configured to append automatically
        if (!$this->autoAppend) {
            return false;
        }

        // only append to HTML responses
        if (!in_array($event->getResponse()->headers->get('content-type'), array('text/html', null))) {
            return false;
        }

        // only append to master request
        if (!$event->isMasterRequest()) {
            return false;
        }

        return true;
    }
501798
public function onKernelResponse(FilterResponseEvent $event)
	{
		$result = parent::onKernelResponse($event);
		$content = ob_get_contents();

		if ($this->request_stack->getCurrentRequest()->getMethod() === 'POST' && empty($content))
		{
			$event->stopPropagation();
		}

		return $result;
	}
1329522
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $response = $event->getResponse();
        $request = $event->getRequest();

        // do not capture redirects or modify XML HTTP Requests
        if ($request->isXmlHttpRequest()) {
            return;
        }

        // do not capture admin cms urls
        if (preg_match('/.*\/admin\/.*/', $request->getRequestUri())) {
            return;
        }

        // do not capture profiler urls
        if (preg_match('/.*\/_profiler\/.*/', $request->getRequestUri())) {
            return;
        }

        try {
            if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
                return;
            }
        } catch (AuthenticationCredentialsNotFoundException $e) {
            return;
        }

        if (self::DISABLED === $this->mode
            || $response->isRedirection()
            || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
            || 'html' !== $request->getRequestFormat()
        ) {
            return;
        }

        $this->injectToolbar($response, $request);
    }
1364774
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $response = $event->getResponse();

        if (null === $response->getCharset()) {
            $response->setCharset($this->charset);
        }

        $response->prepare($event->getRequest());
    }
135763
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        foreach ($this->formats as $format => $mimeTypes) {
            $request->setFormat($format, $mimeTypes);
        }
    }
870462
public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        if (!$event->isMasterRequest() || !$response->isRedirect()) {
            return;
        }

        if (!$this->isPlatformUIRequest($event->getRequest())) {
            return;
        }

        $response->setStatusCode(Response::HTTP_RESET_CONTENT);
        $response->headers->set('PJAX-Location', $response->headers->get('Location'));
        $response->headers->remove('Location');
    }
384454
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $kernel = $event->getKernel();
        $surrogate = $this->surrogate;
        if ($kernel instanceof HttpCache) {
            $surrogate = $kernel->getSurrogate();
            if (null !== $this->surrogate && $this->surrogate->getName() !== $surrogate->getName()) {
                $surrogate = $this->surrogate;
            }
        }

        if (null === $surrogate) {
            return;
        }

        $surrogate->addSurrogateControl($event->getResponse());
    }
629843
public function onResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest() || !$this->session->isStarted()) {
            return;
        }
        $this->session->save();
        $cookie = $this->generateCookie();
        $event->getResponse()->headers->setCookie($cookie);
    }
1343274
public function onRequestEarly(GetResponseEvent $event)
    {
        $validator = $this->app['config.validator'];
        $response = $validator->checks();
        if ($response instanceof Response) {
            $event->setResponse($response);
        }
    }