diff --git a/core/core.services.yml b/core/core.services.yml index b333112..e87f0a7 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -254,7 +254,7 @@ services: class: Drupal\Core\Routing\RouteProvider arguments: ['@database'] router.route_preloader: - class: Drupal\Core\Routing\AdminRoutesPreloader + class: Drupal\Core\Routing\NonAdminRoutesPreloader arguments: ['@router.route_provider', '@state', '@content_negotiation'] tags: - { name: 'event_subscriber' } diff --git a/core/lib/Drupal/Core/Routing/NonAdminRoutesPreloader.php b/core/lib/Drupal/Core/Routing/NonAdminRoutesPreloader.php index dc810c7..4275832 100644 --- a/core/lib/Drupal/Core/Routing/NonAdminRoutesPreloader.php +++ b/core/lib/Drupal/Core/Routing/NonAdminRoutesPreloader.php @@ -8,14 +8,13 @@ namespace Drupal\Core\Routing; use Drupal\Core\ContentNegotiation; -use Drupal\Core\DestructableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; /** - * Defines a class which preloads admin routes. + * Defines a class which preloads non admin routes. */ class NonAdminRoutesPreloader implements EventSubscriberInterface { @@ -89,7 +88,10 @@ protected function getAdminRoutes() { * The Event to process. */ public function onRequest(KernelEvent $event) { - $this->loadAdminRoutes(); + // Just preload on normal html pages, as they will contain the menu links. + if ($this->negotiation->getContentType($event->getRequest()) == 'html') { + $this->loadAdminRoutes(); + } } /** @@ -112,7 +114,7 @@ public function onAlterRoutes(RouteBuildEvent $event) { foreach ($collection->all() as $name => $route) { // Just preload non admin and _content routes, as they are the ones // that appear on menu links and co. - if (strpos($route->getPath(), '/admin') !== 0 && $route->hasDefault('_content')) { + if (strpos($route->getPath(), '/admin') === FALSE && $route->hasDefault('_content')) { $this->adminRoutesOnRebuild[] = $name; } }