1 | <?php |
||
25 | abstract class Route implements RouteInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var AssetManagerInterface $asset_manager |
||
30 | */ |
||
31 | protected $asset_manager; |
||
32 | |||
33 | /** |
||
34 | * @var EE_Dependency_Map $dependency_map |
||
35 | */ |
||
36 | protected $dependency_map; |
||
37 | |||
38 | /** |
||
39 | * @var JsonDataNode $data_node |
||
40 | */ |
||
41 | protected $data_node; |
||
42 | |||
43 | /** |
||
44 | * @var LoaderInterface $loader |
||
45 | */ |
||
46 | protected $loader; |
||
47 | |||
48 | /** |
||
49 | * @var RequestInterface $request |
||
50 | */ |
||
51 | protected $request; |
||
52 | |||
53 | /** |
||
54 | * @var RouteMatchSpecificationInterface $specification |
||
55 | */ |
||
56 | protected $specification; |
||
57 | |||
58 | /** |
||
59 | * @var boolean $handled |
||
60 | */ |
||
61 | private $handled = false; |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Route constructor. |
||
66 | * |
||
67 | * @param EE_Dependency_Map $dependency_map |
||
68 | * @param LoaderInterface $loader |
||
69 | * @param RequestInterface $request |
||
70 | * @param JsonDataNode $data_node |
||
71 | * @param RouteMatchSpecificationInterface $specification |
||
72 | */ |
||
73 | public function __construct( |
||
86 | |||
87 | |||
88 | /** |
||
89 | * @since $VID:$ |
||
90 | */ |
||
91 | abstract protected function registerDependencies(); |
||
92 | |||
93 | |||
94 | /** |
||
95 | * implements logic required to run during request |
||
96 | * |
||
97 | * @return bool |
||
98 | * @since $VID:$ |
||
99 | */ |
||
100 | abstract protected function requestHandler(); |
||
101 | |||
102 | |||
103 | /** |
||
104 | * @param JsonDataNode $data_node |
||
105 | */ |
||
106 | protected function setDataNode($data_node) |
||
110 | |||
111 | |||
112 | /** |
||
113 | * @param RouteMatchSpecificationInterface $specification |
||
114 | */ |
||
115 | protected function setSpecification($specification) |
||
119 | |||
120 | |||
121 | /** |
||
122 | * @return JsonDataNode |
||
123 | */ |
||
124 | public function dataNode() |
||
128 | |||
129 | |||
130 | /** |
||
131 | * runs route requestHandler() if |
||
132 | * - route has not previously been handled |
||
133 | * - route specification matches for current request |
||
134 | * sets route handled property based on results returned by requestHandler() |
||
135 | * |
||
136 | * @return bool |
||
137 | * @since $VID:$ |
||
138 | */ |
||
139 | public function handleRequest() |
||
160 | |||
161 | |||
162 | /** |
||
163 | * called just before matchesCurrentRequest() |
||
164 | * and allows Route to perform any setup required such as calling setSpecification() |
||
165 | * |
||
166 | * @since $VID:$ |
||
167 | */ |
||
168 | public function initialize() |
||
172 | |||
173 | |||
174 | /** |
||
175 | * @return bool |
||
176 | */ |
||
177 | final public function isHandled() |
||
181 | |||
182 | |||
183 | /** |
||
184 | * @return bool |
||
185 | */ |
||
186 | final public function isNotHandled() |
||
190 | |||
191 | |||
192 | /** |
||
193 | * returns true if the current request matches this route |
||
194 | * child classes can override and use Request directly to match route with request |
||
195 | * or supply a RouteMatchSpecification class and just use the below |
||
196 | * |
||
197 | * @return bool |
||
198 | * @since $VID:$ |
||
199 | */ |
||
200 | public function matchesCurrentRequest() |
||
206 | } |
||
207 |