This method is called when the KernelEvents::REQUEST event is dispatched.

@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
The event.
541530
public function checkForRedirection(GetResponseEvent $event) {
    if ($this->routeMatch->getRouteName() != 'entity.data_policy.version_history') {
      return;
    }

    if ($this->currentUser->id() == 1 || !$this->currentUser->hasPermission('view all data policy revisions')) {
      return;
    }

    $url = Url::fromRoute('social_gdpr.data_policy.revisions');
    $response = new RedirectResponse($url->toString());
    $event->setResponse($response);
  }
907876
protected function determineLocale(GetResponseEvent $event)
    {
        $locale = $event->getRequest()->getLocale();

        return in_array($locale, $this->allowedLocales) ?
            $locale :
            null;
    }
786399
public function onEarlyKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        foreach ($this->customFormats as $name => $mimeTypes) {
            $request->setFormat($name, $mimeTypes);
        }
    }
1322387
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }
        $request = $event->getRequest();

        if ($request::getTrustedProxies()) {
            $request->getClientIps();
        }

        $request->getHost();
    }
827225
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (
            !($attributes = RequestAttributesExtractor::extractAttributes($request))
            || !$attributes['receive']
        ) {
            return;
        }

        if (null === $filters = $request->attributes->get('_api_filters')) {
            $queryString = RequestParser::getQueryString($request);
            $filters = $queryString ? RequestParser::parseRequestParams($queryString) : null;
        }

        $context = null === $filters ? [] : ['filters' => $filters];
        if ($this->serializerContextBuilder) {
            // Builtin data providers are able to use the serialization context to automatically add join clauses
            $context += $normalizationContext = $this->serializerContextBuilder->createFromRequest($request, true, $attributes);
            $request->attributes->set('_api_normalization_context', $normalizationContext);
        }

        if (isset($attributes['collection_operation_name'])) {
            $request->attributes->set('data', $request->isMethod('POST') ? null : $this->getCollectionData($attributes, $context));

            return;
        }

        $data = [];

        if ($this->identifierConverter) {
            $context[IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER] = true;
        }

        try {
            $identifiers = $this->extractIdentifiers($request->attributes->all(), $attributes);

            if (isset($attributes['item_operation_name'])) {
                $data = $this->getItemData($identifiers, $attributes, $context);
            } elseif (isset($attributes['subresource_operation_name'])) {
                // Legacy
                if (null === $this->subresourceDataProvider) {
                    throw new RuntimeException('No subresource data provider.');
                }

                $data = $this->getSubresourceData($identifiers, $attributes, $context);
            }
        } catch (InvalidIdentifierException $e) {
            throw new NotFoundHttpException('Not found, because of an invalid identifier configuration', $e);
        }

        if (null === $data) {
            throw new NotFoundHttpException('Not Found');
        }

        $request->attributes->set('data', $data);
    }
411409
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if (Zone::get($request)) {
            return;
        }

        $this->setZone($request);
    }
396076
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        foreach ($this->firewalls as $firewall) {
            //firewalls returns true for an exemption, so skip others
            if (true === $firewall->check($request)) {
                return;
            }
        }
    }
1228225
public function onRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        // skip if route does not match
        if (false === $this->isEnabled($request)) {
            return;
        }

        $content = $request->getContent();

        if ('' === $content) {
            // no content provided
            return;
        }

        if (!count($request->request->all())
            && in_array($request->getMethod(), array('POST', 'PUT', 'PATCH', 'DELETE'))
        ) {
            $contentType = $request->headers->get('Content-Type');

            $format = null === $contentType
                ? $request->getRequestFormat()
                : $request->getFormat($contentType);

            if ($format && !$this->encoderProvider->supports($format)) {
                if ($this->throwExceptionOnUnsupportedContentType) {
                    throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported");
                }

                return;
            }

            $decoder = $this->encoderProvider->getEncoder($format);

            if (!empty($content)) {
                $data = $decoder->decode($content, $format);

                if (is_array($data)) {
                    $request->request = new ParameterBag($data);
                } else {
                    throw new BadRequestHttpException('Invalid '.$format.' message received');
                }
            }
        }
    }
600229
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            // don't do anything if it's not the master request
            return;
        }

        $request = $event->getRequest();

        $session = $this->getContainer()->get('session');

        $utm_params = [
            'utm_source',
            'utm_campaign',
            'utm_medium',
            'utm_term',
        ];

        foreach ($utm_params as $param) {
            if ($request->get($param)) {
                $session->set($param, $request->get($param));
            }
        }
    }
994988
public function onResponseLate(FilterResponseEvent $event)
    {
        if (!$this->eventRequestMatches($event)) {
            return;
        }
        $this->responseTransformer->transformLate($event->getRequest(), $event->getResponse());
    }
952247
public function onKernelRequest(GetResponseEvent $event)
    {
        if (null === $module = $event->getRequest()->get('module')) {
            return;
        }

        if (!$module instanceof ModuleInterface) {
            $module = $this->getModularRouter()->getModuleByRequest($event->getRequest());
        }

        // todo remove current module functionality, as it can lead to unexpected behavior
        $this->getModuleManager()->setCurrentModule($module);
    }
917897
public function onKernelRequest(GetResponseEvent $event): void
    {
        foreach ($this->extensions as $extension) {
            if (!class_exists($extension) || !is_a($extension, ExtensionInterface::class, true)) {
                continue;
            }

            if ($this->twig->hasExtension($extension)) {
                continue;
            }

            $this->twig->addExtension(new $extension());
        }
    }
1063724
public function onKernelRequest(GetResponseEvent $event): void
    {
        $event->getRequest()->attributes->set(
            'csrf_enabled',
            $this->csrfTokenManager instanceof CsrfTokenManager
        );
    }
1159159
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $currentRoute = $request->attributes->get('_route', '');
        if (mb_stripos($currentRoute, self::API_ROUTE_PREFIX) !== 0) {
            return;
        }

        $request->attributes->set(self::API_FLAG_NAME, true);
    }
542910
public function onKernelRequest(GetResponseEvent $event)
    {
        if(!$event->isMasterRequest()){
            return;
        }

        $request = $event->getRequest();

        if (is_array($this->query)) {
            foreach ($this->query as $key => $pattern) {
                if (!empty($pattern) && preg_match('{'.$pattern.'}', $request->get($key))) {
                    return;
                }
            }
        }

        if (is_array($this->cookie)) {
            foreach ($this->cookie as $key => $pattern) {
                if (!empty($pattern) && preg_match('{'.$pattern.'}', $request->cookies->get($key))) {
                    return;
                }
            }
        }

        if (is_array($this->attributes)) {
            foreach ($this->attributes as $key => $pattern) {
                if (!empty($pattern) && preg_match('{'.$pattern.'}', $request->attributes->get($key))) {
                    return;
                }
            }
        }

        if (null !== $this->path && !empty($this->path) && preg_match('{'.$this->path.'}', rawurldecode($request->getPathInfo()))) {
            return;
        }

        if (null !== $this->host && !empty($this->host) && preg_match('{'.$this->host.'}i', $request->getHost())) {
            return;
        }

        if (count((array) $this->ips) !== 0 && $this->checkIps($request->getClientIp(), $this->ips)) {
            return;
        }

        $route = $request->get('_route');
        if (null !== $this->route && preg_match('{'.$this->route.'}', $route)  || (true === $this->debug && '_' === $route[0])) {
            return;
        }

        // Get driver class defined in your configuration
        $driver = $this->driverFactory->getDriver();

        if ($driver->decide() && HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
            $this->handleResponse = true;
            throw new ServiceUnavailableException($this->http_exception_message);
        }
    }
454770
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $theme = $this->activeTheme->getName();
        $controllers = $request->attributes->get(static::ATTRIBUTE_KEY);
        if (isset($controllers[$theme])) {
            $request->attributes->set('_controller', $controllers[$theme]);
        }

        // Get rid of the attribute in the request to avoid it showing up in generated URLs
        $request->attributes->remove(static::ATTRIBUTE_KEY);
        $routeParams = $request->attributes->get('_route_params');
        if (null !== $routeParams) {
            unset($routeParams[static::ATTRIBUTE_KEY]);
            $request->attributes->set('_route_params', $routeParams);
        }
    }
658764
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $attributes = $event->getRequest()->attributes;
        if ($attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
            return;
        }

        if (!$attributes->has('itemType')) {
            return;
        }

        $backend = $this->backendRegistry->getBackend($attributes->get('itemType'));
        $this->container->set('netgen_content_browser.current_backend', $backend);
    }