This method is called whenever the request event is dispatched.

@param \Symfony\Component\EventDispatcher\Event $event
Triggering event.
974805
public function checkForHomepageRedirect(Event $event) {

    // Make sure front page module is not run when using cli or doing install.
    if (PHP_SAPI === 'cli' || drupal_installation_attempted()) {
      return;
    }
    // Don't run when site is in maintenance mode.
    if (\Drupal::state()->get('system.maintenance_mode')) {
      return;
    }

    // Ignore non index.php requests (like cron).
    if (!empty($_SERVER['SCRIPT_FILENAME']) && realpath(DRUPAL_ROOT . '/index.php') != realpath($_SERVER['SCRIPT_FILENAME'])) {
      return;
    }

    /** @var \Symfony\Component\HttpFoundation\Request $request */
    $request = $event->getRequest();
    $request_path = $request->getPathInfo();
    $frontpage_an = $this->siteSettings->get('page.front');
    if ($request_path === $frontpage_an || $request_path === '/') {
      $frontpage_lu = $this->alternativeFrontpageSettings->get('frontpage_for_authenticated_user');
      if ($frontpage_an === $frontpage_lu) {
        return;
      }
      if ($frontpage_lu && $this->currentUser->isAuthenticated()) {
        $cache_contexts = new CacheableMetadata();
        $cache_contexts->setCacheContexts(['user.roles:anonymous']);

        $response = new CacheableRedirectResponse($frontpage_lu);
        $response->addCacheableDependency($cache_contexts);
        $event->setResponse($response);
      }
    }
  }
941851
public function dispatch($event/*, string $eventName = null*/)
    {
        if (null === $this->callStack) {
            $this->callStack = new \SplObjectStorage();
        }

        $currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : '';
        $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;

        if (\is_object($event)) {
            $eventName = $eventName ?? \get_class($event);
        } else {
            @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
            $swap = $event;
            $event = $eventName ?? new Event();
            $eventName = $swap;

            if (!$event instanceof Event) {
                throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event)));
            }
        }

        if (null !== $this->logger && ($event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) {
            $this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
        }

        $this->preProcess($eventName);
        try {
            $this->beforeDispatch($eventName, $event);
            try {
                $e = $this->stopwatch->start($eventName, 'section');
                try {
                    $this->dispatcher->dispatch($event, $eventName);
                } finally {
                    if ($e->isStarted()) {
                        $e->stop();
                    }
                }
            } finally {
                $this->afterDispatch($eventName, $event);
            }
        } finally {
            $this->currentRequestHash = $currentRequestHash;
            $this->postProcess($eventName);
        }

        return $event;
    }
983732
public function handleHandleHttpRequestEvent(HandleHttpRequestEvent $event) {
        $event->setResponse(
            $this->requestHandler->handle($event->getRequest())
        );
    }
127278
public function beforeDispatch(Event $event)
    {
        /* @var \Cake\Http\ServerRequest $request */
        $request = $event->getData('request');
        $locale = Locale::acceptFromHttp($request->getHeaderLine('Accept-Language'));

        if (!$locale || (!empty($this->_locales) && !in_array($locale, $this->_locales))) {
            return;
        }

        I18n::setLocale($locale);
    }
933667
public function dispatch($event): void
    {
        Assertion::isObject($event, 'An event should be an object');

        $eventName = get_class($event);
        $eventSubscribers = array_merge(
            $this->subscribedToAllEvents,
            $this->subscribers[$eventName] ?? []
        );

        foreach ($eventSubscribers as $eventSubscriber) {
            $eventSubscriber($event);
        }
    }
32973
public function dispatchEvent(\Symfony\Component\EventDispatcher\Event $event)
    {
        $container = \OxidEsales\EshopCommunity\Internal\Application\ContainerFactory::getInstance()->getContainer();
        $dispatcher = $container->get(EventDispatcherInterface::class);
        return $dispatcher->dispatch($event::NAME, $event);
    }
621279
public function on(string $event, $handler)
    {
        if (self::isSupportedEvent($event)) {
            $this->options[$event] = $handler;
        }
    }
402630
public function onLoadQueueListenerRun(LoadQueueEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $query  = $event->getQuery();
        $result = $this->database->execute($query);
        $event->setEvents($result);
    }
921565
public function afterPaginate(Event $event)
    {
        $event;
        if (!$this->_table()->behaviors()->has('Search')) {
            return;
        }

        $enabled = $this->getConfig('enabled') ?: !$this->_request()->is('api');
        if (!$enabled) {
            return;
        }

        $fields = $this->fields();
        $this->_controller()->set('searchInputs', $fields);
    }
774271
protected function afterDispatch(string $eventName, $event)
    {
        $this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event));
    }
604680
public function triggerEvent(string $event): void
    {
        // TODO: use event library and allow attach events to IFile and ICacheStateful.
        // cache triggers
        if ($this->file instanceof ICacheStateful) {
            switch ($event) {
                case self::EVENT_CACHED:
                    $this->file->setCachedAt($this->name, time());
                    break;
                case self::EVENT_EMPTY:
                case self::EVENT_ERROR:
                case self::EVENT_NOT_FOUND:
                    // TODO: split those and save different cases of cache state.
                    $this->file->setCachedAt($this->name, null);
                    break;
            }

            $this->file->saveState();
        }

        // other triggers
    }
439795
public function dispatch(Event $event) {
    
    foreach ($this->getSubscribers($event) as $subscriber) {
      $subscriber->trigger($event);
    }
    
    return $this;
  }
1270926
protected function fireEvent($event)
    {
        $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]);
    }
652677
private function postProcess(Event $event)
	{
		$skipped = false;

		foreach ($this->dispatcher->getListeners($event) as $listener)
		{
			if (!($listener instanceof TraceableListener))
			{
				// A new listener was added during dispatch.
				continue;
			}

			// Unwrap listener
			//$this->dispatcher->removeListener($listener, $event);
			//$this->dispatcher->addListener($listener->getWrappedListener(), $event);
			$priority = $this->dispatcher->getListenerPriority($listener, $event);

			$this->dispatcher->getListeners()[$event->getName()]->remove($listener);
			$this->dispatcher->getListeners()[$event->getName()]->add($listener->getWrappedListener(), $priority);

			$info = $this->getListenerInfo($listener->getWrappedListener(), $event->getName());

			$eventName = $event->getName();

			if ($listener->wasCalled())
			{
				if (null !== $this->logger)
				{
					$this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty']));
				}

				if (!isset($this->called[$eventName]))
				{
					$this->called[$eventName] = new \SplObjectStorage();
				}

				$this->called[$eventName]->attach($listener);
			}

			if (null !== $this->logger && $skipped)
			{
				$this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName));
			}

			if ($listener->stoppedPropagation())
			{
				if (null !== $this->logger)
				{
					$this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName));
				}

				$skipped = true;
			}
		}
	}
1345336
public function onRequestBeforeSend(Event $event)
    {
        $request = $event['request'];
        if (!$request->getParams()->get('cookies.disable')) {
            $request->removeHeader('Cookie');
            // Find cookies that match this request
            foreach ($this->cookieJar->getMatchingCookies($request) as $cookie) {
                $request->addCookie($cookie->getName(), $cookie->getValue());
            }
        }
    }
1302231
public function triggerEvent($eventName, Event $event = null)
    {
        if (!$event) {
            $event = new Event;
        }

        $event->setTarget($this);

        return $this->eventDispatcher->dispatch($eventName, $event);
    }
1042170
final public function handle(Event $event): void
    {
        if (!$this->isEventSupported($event)) {
            throw new InvalidEventException(\sprintf(
                'Event must be a %s, %s given',
                \implode('or ', $this->getSupportedEventTypes()),
                \get_class($event)
            ));
        }

        $this->handleEvent($event);
    }