RoutePreloader
class RoutePreloader implements EventSubscriberInterface (View source)
Defines a class which preloads non-admin routes.
On an actual site we want to avoid too many database queries so we build a list of all routes which most likely appear on the actual site, which are all HTML routes not starting with "/admin".
Properties
| protected RouteProviderInterface|PreloadableRouteProviderInterface | $routeProvider | The route provider. |
|
| protected StateInterface | $state | The state key value store. |
|
| protected array | $nonAdminRoutesOnRebuild | Contains the non-admin routes while rebuilding the routes. |
|
| protected CacheBackendInterface | $cache | The cache backend used to skip the state loading. |
Methods
Constructs a new RoutePreloader.
Loads all non-admin routes right before the actual page is rendered.
Store the non admin routes in state when the route building is finished.
{@inheritdoc}
Determines whether the given route is a GET and HTML route.
Details
__construct(RouteProviderInterface $route_provider, StateInterface $state, CacheBackendInterface $cache)
Constructs a new RoutePreloader.
onRequest(KernelEvent $event)
Loads all non-admin routes right before the actual page is rendered.
onAlterRoutes(RouteBuildEvent $event)
Alters existing routes for a specific collection.
onFinishedRoutes()
Store the non admin routes in state when the route building is finished.
static
getSubscribedEvents()
{@inheritdoc}
static protected bool
isGetAndHtmlRoute(Route $route)
Determines whether the given route is a GET and HTML route.