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 \League\Route\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 | 46 | public function __construct(string $method, string $path, $handler) |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | 16 | public function process( |
|
63 | |||
64 | /** |
||
65 | * Get the controller callable |
||
66 | * |
||
67 | * @param \Psr\Container\ContainerInterface|null $container |
||
68 | * |
||
69 | * @throws \InvalidArgumentException |
||
70 | * |
||
71 | * @return callable |
||
72 | */ |
||
73 | 30 | public function getCallable(?ContainerInterface $container = null) : callable |
|
99 | |||
100 | /** |
||
101 | * Get an object instance from a class name |
||
102 | * |
||
103 | * @param \Psr\Container\ContainerInterface|null $container |
||
104 | * @param string $class |
||
105 | * |
||
106 | * @return object |
||
107 | */ |
||
108 | 4 | protected function resolveClass(?ContainerInterface $container = null, string $class) |
|
116 | |||
117 | /** |
||
118 | * Return variables to be passed to route callable |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 18 | public function getVars() : array |
|
126 | |||
127 | /** |
||
128 | * Set variables to be passed to route callable |
||
129 | * |
||
130 | * @param array $vars |
||
131 | * |
||
132 | * @return \League\Route\Route |
||
133 | */ |
||
134 | 18 | public function setVars(array $vars) : self |
|
140 | |||
141 | /** |
||
142 | * Get the parent group |
||
143 | * |
||
144 | * @return \League\Route\RouteGroup |
||
145 | */ |
||
146 | 18 | public function getParentGroup() : ?RouteGroup |
|
150 | |||
151 | /** |
||
152 | * Set the parent group |
||
153 | * |
||
154 | * @param \League\Route\RouteGroup $group |
||
155 | * |
||
156 | * @return \League\Route\Route |
||
157 | */ |
||
158 | 8 | public function setParentGroup(RouteGroup $group) : self |
|
170 | |||
171 | /** |
||
172 | * Get the path |
||
173 | * |
||
174 | * @return string |
||
175 | */ |
||
176 | 24 | public function getPath() : string |
|
180 | |||
181 | /** |
||
182 | * Get the HTTP method |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | 24 | public function getMethod() : string |
|
190 | } |
||
191 |