1 | <?php declare(strict_types=1); |
||
12 | class Route implements |
||
13 | MiddlewareInterface, |
||
14 | MiddlewareAwareInterface, |
||
15 | RouteConditionHandlerInterface, |
||
16 | StrategyAwareInterface |
||
17 | { |
||
18 | use MiddlewareAwareTrait; |
||
19 | use RouteConditionHandlerTrait; |
||
20 | use StrategyAwareTrait; |
||
21 | |||
22 | /** |
||
23 | * @var callable|string |
||
24 | */ |
||
25 | protected $handler; |
||
26 | |||
27 | /** |
||
28 | * @var RouteGroup |
||
29 | */ |
||
30 | protected $group; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $method; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $path; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $vars = []; |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Construct. |
||
50 | * |
||
51 | * @param string $method |
||
52 | * @param string $path |
||
53 | * @param callable|string $handler |
||
54 | */ |
||
55 | 72 | public function __construct(string $method, string $path, $handler) |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 24 | public function process( |
|
71 | |||
72 | /** |
||
73 | * Get the controller callable |
||
74 | * |
||
75 | * @param ContainerInterface|null $container |
||
76 | * |
||
77 | * @return callable |
||
78 | * |
||
79 | * @throws InvalidArgumentException |
||
80 | */ |
||
81 | 45 | public function getCallable(?ContainerInterface $container = null): callable |
|
107 | |||
108 | /** |
||
109 | * Get an object instance from a class name |
||
110 | * |
||
111 | * @param ContainerInterface|null $container |
||
112 | * @param string $class |
||
113 | * |
||
114 | * @return object |
||
115 | */ |
||
116 | 6 | protected function resolveClass(?ContainerInterface $container = null, string $class) |
|
124 | |||
125 | /** |
||
126 | * Return variables to be passed to route callable |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | 27 | public function getVars(): array |
|
134 | |||
135 | /** |
||
136 | * Set variables to be passed to route callable |
||
137 | * |
||
138 | * @param array $vars |
||
139 | * |
||
140 | * @return Route |
||
141 | */ |
||
142 | 27 | public function setVars(array $vars): self |
|
148 | |||
149 | /** |
||
150 | * Get the parent group |
||
151 | * |
||
152 | * @return RouteGroup |
||
153 | */ |
||
154 | 27 | public function getParentGroup(): ?RouteGroup |
|
158 | |||
159 | /** |
||
160 | * Set the parent group |
||
161 | * |
||
162 | * @param RouteGroup $group |
||
163 | * |
||
164 | * @return Route |
||
165 | */ |
||
166 | 12 | public function setParentGroup(RouteGroup $group): self |
|
179 | |||
180 | /** |
||
181 | * Get the path |
||
182 | * |
||
183 | * @param array $replacements |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | 39 | public function getPath(array $replacements = []): string |
|
197 | |||
198 | /** |
||
199 | * Get the HTTP method |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | 36 | public function getMethod(): string |
|
207 | } |
||
208 |