CoolCMS API

RouterDispatcher
in package
uses SmartObject

FinalYes

Builds the application {@see Router}.

Static sections (test, cron, admin, api, script, fallback) come from DI factories. Dynamic front routes come from the precomputed RouteTableSnapshot: a cache hit needs no SQL (RouteTableCache), a miss or disabled cache goes through RouteTableBuilder. The router never reads the database itself.

Table of Contents

Properties

$container  : Container
$factoryCache  : array<string, RouteFactoryInterface>
$localeResolver  : LocaleResolver
$pageSlugTranslator  : PageSlugTranslator
$routeTableBuilder  : RouteTableBuilder
$routeTableCache  : RouteTableCache
$translators  : array<int, TranslatorInterface>

Methods

__construct()  : mixed
addTranslator()  : void
Called by the NEON decorator for every tagged translator.
addTranslators()  : void
createRouter()  : Router
warmupTranslator()  : void
Warms up a translator by entity ids so components and presenters can preload the cache before linking.
warmupTranslatorFromEntities()  : void
Warms up a translator from already loaded entities, without a database query.
createDynamicRoutes()  : void
Creates the dynamic front routes from the route definitions.
createRouteFromDefinition()  : TranslatableRoute|null
Creates a route from a {@see RouteDefinition} through its factory.
getFactory()  : RouteFactoryInterface|null
Returns the factory instance from the cache or the DI container, falling back to `DefaultRouteFactory`.

Properties

Methods

__construct()

public __construct(Container $container, LocaleResolver $localeResolver, PageSlugTranslator $pageSlugTranslator, RouteTableBuilder $routeTableBuilder, RouteTableCache $routeTableCache, DefaultRouteFactory $defaultRouteFactory) : mixed
Parameters
$container : Container
$localeResolver : LocaleResolver
$pageSlugTranslator : PageSlugTranslator
$routeTableBuilder : RouteTableBuilder
$routeTableCache : RouteTableCache
$defaultRouteFactory : DefaultRouteFactory

warmupTranslator()

Warms up a translator by entity ids so components and presenters can preload the cache before linking.

public warmupTranslator(string $translatorClass[, array<int, int>|null $ids = null ]) : void
Parameters
$translatorClass : string
$ids : array<int, int>|null = null

entity ids to load; null loads all

warmupTranslatorFromEntities()

Warms up a translator from already loaded entities, without a database query.

public warmupTranslatorFromEntities(string $translatorClass, array<string|int, mixed> $entities) : void
Parameters
$translatorClass : string
$entities : array<string|int, mixed>

entities with translations loaded; the translator takes only its own (shared) entity and skips the rest

createDynamicRoutes()

Creates the dynamic front routes from the route definitions.

private createDynamicRoutes(RouteList $router, array<int, RouteDefinition> $routes, string $defaultLocale) : void
Parameters
$router : RouteList
$routes : array<int, RouteDefinition>
$defaultLocale : string

createRouteFromDefinition()

Creates a route from a {@see RouteDefinition} through its factory.

private createRouteFromDefinition(RouteDefinition $definition[, string $defaultLocale = 'cs' ]) : TranslatableRoute|null

The presenter existence check already ran in the builder. Returns null when the factory cannot be created, and the route is skipped.

Parameters
$definition : RouteDefinition
$defaultLocale : string = 'cs'
Return values
TranslatableRoute|null

getFactory()

Returns the factory instance from the cache or the DI container, falling back to `DefaultRouteFactory`.

private getFactory(string $factoryClassName, int $routeId) : RouteFactoryInterface|null

The class name comes from the database (route_factory), so it is verified before the container is asked for it.

Parameters
$factoryClassName : string
$routeId : int
Return values
RouteFactoryInterface|null
On this page

Search results