CoolCMS API

RouteTableSnapshot
in package

FinalYes

Complete precomputed snapshot of the routing table, made of plain arrays and never entities.

Produced by RouteTableBuilder (always, even with the cache disabled) and merely wrapped into a Redis payload by RouteTableCache.

Both slug maps (idToSlug and slugToId) are stored explicitly. Flipping one on load would change the last-wins behavior for duplicate hrefs and differ from PageSlugTranslator. Because the maps are complete, an unknown slug or locale is a plain miss that returns null without a database query.

Table of Contents

Properties

$defaultLocale  : string
$idToSlug  : array<string|int, mixed>
$localeMap  : array<string|int, mixed>
$routes  : array<string|int, mixed>
$slugToId  : array<string|int, mixed>

Methods

__construct()  : mixed
fromArray()  : self
Rebuilds the snapshot from a decoded payload. After `json_decode(assoc: true)` PHP casts numeric string keys (language id, page id, even a numeric slug such as "2024") to int, so `isset($map[$langId][$pageId])` keeps working.
toArray()  : array{routes: list>, idToSlug: array>, slugToId: array>, localeMap: array, defaultLocale: string}

Properties

Methods

__construct()

public __construct(array<int, RouteDefinition> $routes, array<int, array<int, string>> $idToSlug, array<int, array<string, int>> $slugToId, array<string, int> $localeMap[, string $defaultLocale = 'cs' ]) : mixed
Parameters
$routes : array<int, RouteDefinition>

in match priority order

$idToSlug : array<int, array<int, string>>

[langId][pageId] = href

$slugToId : array<int, array<string, int>>

[langId][href] = pageId

$localeMap : array<string, int>

[locale] = langId

$defaultLocale : string = 'cs'

fromArray()

Rebuilds the snapshot from a decoded payload. After `json_decode(assoc: true)` PHP casts numeric string keys (language id, page id, even a numeric slug such as "2024") to int, so `isset($map[$langId][$pageId])` keeps working.

public static fromArray(array<string, mixed> $data) : self
Parameters
$data : array<string, mixed>
Tags
throws
InvalidArgumentException

when the shape is invalid (the caller treats it as a cache miss)

Return values
self

toArray()

public toArray() : array{routes: list>, idToSlug: array>, slugToId: array>, localeMap: array, defaultLocale: string}
Return values
array{routes: list>, idToSlug: array>, slugToId: array>, localeMap: array, defaultLocale: string}
On this page

Search results