Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RoutePreloader.php

function RoutePreloader::onRequest

Loads all non-admin routes right before the actual page is rendered.

Parameters

\Symfony\Component\HttpKernel\Event\KernelEvent $event: The event to process.

File

core/lib/Drupal/Core/Routing/RoutePreloader.php, line 47

Class

RoutePreloader
Defines a class that can pre-load non-admin routes.

Namespace

Drupal\Core\Routing

Code

public function onRequest(KernelEvent $event) {
    // Only preload on normal HTML pages, as they will display menu links.
    if ($this->routeProvider instanceof PreloadableRouteProviderInterface && $event->getRequest()
        ->getRequestFormat() == 'html') {
        $routes = $this->state
            ->get('routing.non_admin_routes', []);
        if ($routes) {
            // Preload all the non-admin routes at once.
            $this->routeProvider
                ->preLoadRoutes($routes);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal