1 | <?php |
||
11 | class RouteDefinitionProvider |
||
12 | { |
||
13 | /** @var array<int[]> List of static paths to route */ |
||
14 | protected $staticRoutes = []; |
||
15 | |||
16 | /** @var array<int[]> List of routes per number of segments */ |
||
17 | protected $segmentCounts = []; |
||
18 | |||
19 | /** @var array<array<int[]>> List of routes by each segment */ |
||
20 | protected $segmentValues = []; |
||
21 | |||
22 | /** @var array[] Cache of all route definitions */ |
||
23 | protected $routeDefinitions = []; |
||
24 | |||
25 | /** @var int[] List of routes by their name */ |
||
26 | protected $routesByName = []; |
||
27 | |||
28 | /** |
||
29 | * Adds a new route definition. |
||
30 | * @param RouteDefinition $definition A new route definition to add |
||
31 | */ |
||
32 | 18 | public function addRouteDefinition(RouteDefinition $definition): void |
|
58 | |||
59 | /** |
||
60 | * Returns PHP code for cached RouteDefinitionProvider that can be stored in file and included. |
||
61 | * @return string PHP code for cached RouteDefinitionProvider |
||
62 | */ |
||
63 | 18 | public function getCacheFile(): string |
|
83 | |||
84 | /** |
||
85 | * Returns list of routes per static path. |
||
86 | * @return array[] List of routes per static path |
||
87 | */ |
||
88 | 17 | public function getStaticRoutes(): array |
|
92 | |||
93 | /** |
||
94 | * Returns route ids with specific segment count. |
||
95 | * @param int $count The number of segments in the path |
||
96 | * @return int[] List of route ids with specific segment count |
||
97 | */ |
||
98 | 11 | public function getSegmentCountIds(int $count): array |
|
102 | |||
103 | /** |
||
104 | * Returns route ids with specific value for specific segment. |
||
105 | * @param int $segment The number of the segment |
||
106 | * @param string $value The value for the segment or '/' dynamic segments |
||
107 | * @return int[] List of route ids the match the given criteria |
||
108 | */ |
||
109 | 8 | public function getSegmentValueIds(int $segment, string $value): array |
|
113 | |||
114 | /** |
||
115 | * Returns a route definition by a specific id. |
||
116 | * @param int $routeId Id of the route definition |
||
117 | * @return RouteDefinition The route definition for the specific id |
||
118 | */ |
||
119 | 16 | public function getRouteDefinition(int $routeId): RouteDefinition |
|
127 | |||
128 | /** |
||
129 | * Returns a route definition by the name of the route. |
||
130 | * @param string $name The name of the route |
||
131 | * @return RouteDefinition The route definition with the given name |
||
132 | */ |
||
133 | 10 | public function getRouteDefinitionByName(string $name): RouteDefinition |
|
141 | } |
||
142 |