Configures the caching headers on tag view.

@param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
349646
public function configureCache(FilterResponseEvent $event)
    {
        $view = $event->getRequest()->attributes->get('view');
        if (!$view instanceof CachableView || !$view instanceof TagView) {
            return;
        }

        if (!$this->enableViewCache || !$view->isCacheEnabled()) {
            return;
        }

        $tag = $view->getTag();
        $response = $event->getResponse();

        $response->setPublic();
        $response->headers->set('X-Tag-Id', $tag->id, false);

        if ($this->enableTtlCache && !$response->headers->hasCacheControlDirective('s-maxage')) {
            $response->setSharedMaxAge($this->defaultTtl);
        }
    }
753662
public function addTargetGroupHitScript(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $response = $event->getResponse();

        if ($this->preview
            || 0 !== strpos($response->headers->get('Content-Type'), 'text/html')
            || Request::METHOD_GET !== $request->getMethod()
        ) {
            return;
        }

        $script = $this->twig->render('SuluAudienceTargetingBundle:Template:hit-script.html.twig', [
            'url' => $this->targetGroupHitUrl,
            'urlHeader' => $this->urlHeader,
            'refererHeader' => $this->referrerHeader,
            'uuidHeader' => $this->uuidHeader,
            'uuid' => $request->attributes->has('structure') ? $request->attributes->get('structure')->getUuid() : null,
        ]);

        $response->setContent(str_replace(
            '</body>',
            $script . '</body>',
            $response->getContent()
        ));
    }
795628
public function onKernelResponse(FilterResponseEvent $event)
    {
        $lockName = $event->getRequest()->attributes->get('writeLockOn', null);
        if (!is_null($lockName)) {
            $this->cache->delete($lockName);
            $this->logger->info("LOCK REMOVED = ".$lockName);
        }
    }
434208
public function onKernelResponse(FilterResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $blockView = $event->getRequest()->attributes->get('ngbmView');
        if (!$blockView instanceof BlockViewInterface) {
            return;
        }

        $this->tagger->tagBlock($event->getResponse(), $blockView->getBlock());
    }
295116
public function replaceMarkup(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $response = $event->getResponse();
        $format = $request->getRequestFormat();
        $content = $response->getContent();

        if (!$content || !array_key_exists($format, $this->markupParser)) {
            return;
        }

        $response->setContent(
            $this->markupParser[$format]->parse($content, $request->getLocale())
        );
    }
1078820
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->encryptionService->isPerUserEncryptionEnabled()) {
            $request = $event->getRequest();

            // Check if this is one of the security_check routes
            $securityCheckRoutes = $this->settings['security_check_routes'];
            $route = $request->attributes->get('_route');
            if ($route && in_array($route, $securityCheckRoutes)) {
                $user = $this->getUser();

                if ($user) {
                    $password = $request->request->get('_password');
                    $privateKey = $this->keyManager->getUserPrivateKey($user, array('password' => $password));
                    if ($privateKey) {
                        $request->getSession()->set(KeyManager::SESSION_PRIVATE_KEY_PARAM, $privateKey);
                    }
                    else {
                        throw new EncryptionException('Could not load user\'s key');
                    }
                }
            }
        }
    }
768940
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (
            'html' !== $request->getRequestFormat('') ||
            !($request->attributes->has('_api_resource_class') || $request->attributes->getBoolean('_api_respond', false))
        ) {
            return;
        }

        $request->attributes->set('_controller', 'api_platform.swagger.action.ui');
    }
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
        ));
    }
473547
public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        if ($response) {
            $date = $response->getDate();
            if (empty($date)) {
                $response->setDate(new \DateTime());
            }
        }
    }
1063060
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->handleResponse && $this->http_code !== null) {
            $response = $event->getResponse();
            $response->setStatusCode($this->http_code, $this->http_status);
        }
    }
161034
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        foreach ($this->requestMatchers as $requestMatcher) {
            if ($requestMatcher->matches($request)) {
                $request->attributes->set(FOSRestBundle::ZONE_ATTRIBUTE, true);

                return;
            }
        }

        $request->attributes->set(FOSRestBundle::ZONE_ATTRIBUTE, false);
    }
239204
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->mustLog) {

            /**
             * Only logs before controller execution if EXEC_POST or EXEC_BOTH.
             */
            if (in_array($this->execute, [AnnotationLog::EXEC_POST, AnnotationLog::EXEC_BOTH])) {
                $this->logMessage(
                    $this->logger,
                    $this->level,
                    $this->value
                );
            }
        }
    }
1159115
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $this->turbolinks->decorateResponse($event->getRequest(), $event->getResponse());
    }
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);
    }
214318
public function onKernelResponse(FilterResponseEvent $event)
    {
        $locale = $this->localeProvider->determinePreferredLocale();

        // Unable to determine preferred locale? No need to hand out a cookie then.
        if (empty($locale)) {
            return;
        }

        // Did the request already contain the proper cookie value? No need to hand out a cookie then.
        $requestCookie = $this->cookieHelper->read($event->getRequest());
        if ($requestCookie && $requestCookie->getValue() === $locale) {
            $this->logger->debug(sprintf(
                'Locale cookie already set to "%s", nothing to do here',
                $locale
            ));
            return;
        }

        $this->cookieHelper->write($event->getResponse(), $locale);
        $this->logger->notice(sprintf("Set locale cookie to %s", $locale));
    }
588009
public function onCoreController(FilterControllerEvent $event)
    {
        // do not capture admin cms urls
        if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
            return;
        }

        if (!$this->tokenStorage->getToken()) {
            return;
        }

        $user = $this->tokenStorage->getToken()->getUser();
        if ($user instanceof UserInterface) {

            //here we can update the user as necessary
            if (method_exists($user, 'setLastActivity')) {
                try {
                    $user->setLastActivity(new \DateTime('now'));
                    $this->em->persist($user);
                    $this->em->flush($user);
                } catch (\Doctrine\ORM\ORMException $e) {
                    //do nothing, entity manager is closed
                }
            }
        }
    }
1311225
public function onResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $response = $event->getResponse();
        if (!$response->isRedirect() || !$response instanceof RedirectResponse) {
            return;
        }

        $this->handleNoBackendAccess($response);
        $this->handleLoginRetreat($request, $response);
    }