1 | <?php |
||
27 | abstract class Route implements RouteInterface |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * @var AssetManagerInterface $asset_manager |
||
32 | */ |
||
33 | protected $asset_manager; |
||
34 | |||
35 | /** |
||
36 | * @var EE_Dependency_Map $dependency_map |
||
37 | */ |
||
38 | protected $dependency_map; |
||
39 | |||
40 | /** |
||
41 | * @var JsonDataNode $data_node |
||
42 | */ |
||
43 | protected $data_node; |
||
44 | |||
45 | /** |
||
46 | * @var LoaderInterface $loader |
||
47 | */ |
||
48 | protected $loader; |
||
49 | |||
50 | /** |
||
51 | * @var RequestInterface $request |
||
52 | */ |
||
53 | protected $request; |
||
54 | |||
55 | /** |
||
56 | * @var RouteMatchSpecificationInterface $specification |
||
57 | */ |
||
58 | protected $specification; |
||
59 | |||
60 | /** |
||
61 | * @var boolean $handled |
||
62 | */ |
||
63 | private $handled = false; |
||
64 | |||
65 | /** |
||
66 | * @var array $default_dependencies |
||
67 | */ |
||
68 | protected static $default_dependencies = [ |
||
69 | 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
||
70 | 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
||
71 | 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
||
72 | ]; |
||
73 | |||
74 | /** |
||
75 | * @var array $full_dependencies |
||
76 | */ |
||
77 | protected static $full_dependencies = [ |
||
78 | 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
||
79 | 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
||
80 | 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
||
81 | 'EventEspresso\core\services\json\JsonDataNode' => EE_Dependency_Map::load_from_cache, |
||
82 | 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' => EE_Dependency_Map::load_from_cache, |
||
83 | ]; |
||
84 | |||
85 | |||
86 | /** |
||
87 | * Route constructor. |
||
88 | * |
||
89 | * @param EE_Dependency_Map $dependency_map |
||
90 | * @param LoaderInterface $loader |
||
91 | * @param RequestInterface $request |
||
92 | * @param JsonDataNode|null $data_node |
||
93 | * @param RouteMatchSpecificationInterface|null $specification |
||
94 | */ |
||
95 | public function __construct( |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @since $VID:$ |
||
112 | */ |
||
113 | abstract protected function registerDependencies(); |
||
114 | |||
115 | |||
116 | /** |
||
117 | * implements logic required to run during request |
||
118 | * |
||
119 | * @return bool |
||
120 | * @since $VID:$ |
||
121 | */ |
||
122 | abstract protected function requestHandler(); |
||
123 | |||
124 | |||
125 | /** |
||
126 | * @return array |
||
127 | */ |
||
128 | public static function getDefaultDependencies() |
||
132 | |||
133 | |||
134 | /** |
||
135 | * @return array |
||
136 | */ |
||
137 | public static function getFullDependencies() |
||
141 | |||
142 | |||
143 | /** |
||
144 | * @param JsonDataNode $data_node |
||
145 | */ |
||
146 | protected function setDataNode($data_node) |
||
150 | |||
151 | |||
152 | /** |
||
153 | * @param RouteMatchSpecificationInterface $specification |
||
154 | */ |
||
155 | protected function setSpecification($specification) |
||
159 | |||
160 | |||
161 | /** |
||
162 | * @return JsonDataNode |
||
163 | */ |
||
164 | public function dataNode() |
||
168 | |||
169 | |||
170 | /** |
||
171 | * runs route requestHandler() if |
||
172 | * - route has not previously been handled |
||
173 | * - route specification matches for current request |
||
174 | * sets route handled property based on results returned by requestHandler() |
||
175 | * |
||
176 | * @return bool |
||
177 | * @since $VID:$ |
||
178 | */ |
||
179 | public function handleRequest() |
||
200 | |||
201 | |||
202 | /** |
||
203 | * called just before matchesCurrentRequest() |
||
204 | * and allows Route to perform any setup required such as calling setSpecification() |
||
205 | * |
||
206 | * @since $VID:$ |
||
207 | */ |
||
208 | public function initialize() |
||
212 | |||
213 | |||
214 | /** |
||
215 | * @return bool |
||
216 | */ |
||
217 | final public function isHandled() |
||
221 | |||
222 | |||
223 | /** |
||
224 | * @return bool |
||
225 | */ |
||
226 | final public function isNotHandled() |
||
230 | |||
231 | |||
232 | /** |
||
233 | * returns true if the current request matches this route |
||
234 | * child classes can override and use Request directly to match route with request |
||
235 | * or supply a RouteMatchSpecification class and just use the below |
||
236 | * |
||
237 | * @return bool |
||
238 | * @since $VID:$ |
||
239 | */ |
||
240 | public function matchesCurrentRequest() |
||
246 | |||
247 | |||
248 | /** |
||
249 | * @param string $domain_fqcn |
||
250 | * @since $VID:$ |
||
251 | */ |
||
252 | public function initializeBaristaForDomain($domain_fqcn) |
||
263 | } |
||
264 |