|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\entities\routing\handlers\frontend; |
|
4
|
|
|
|
|
5
|
|
|
use EE_Dependency_Map; |
|
6
|
|
|
use EE_Maintenance_Mode; |
|
7
|
|
|
use EventEspresso\core\domain\entities\routing\handlers\Route; |
|
8
|
|
|
use EventEspresso\core\services\loaders\LoaderInterface; |
|
9
|
|
|
use EventEspresso\core\services\request\RequestInterface; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class FrontendRequests |
|
13
|
|
|
* registers dependencies and loads resources for all non-authorized standard HTTP requests |
|
14
|
|
|
* |
|
15
|
|
|
* @package EventEspresso\core\domain\entities\routing\handlers\frontend |
|
16
|
|
|
* @author Brent Christensen |
|
17
|
|
|
* @since \$VID:$ |
|
18
|
|
|
*/ |
|
19
|
|
|
class FrontendRequests extends Route |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var EE_Maintenance_Mode $maintenance_mode |
|
24
|
|
|
*/ |
|
25
|
|
|
private $maintenance_mode; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* returns true if the current request matches this route |
|
30
|
|
|
* child classes can override and use Request directly to match route with request |
|
31
|
|
|
* or supply a RouteMatchSpecification class and just use the below |
|
32
|
|
|
* |
|
33
|
|
|
* @return bool |
|
34
|
|
|
* @since $VID:$ |
|
35
|
|
|
*/ |
|
36
|
|
|
public function matchesCurrentRequest() |
|
37
|
|
|
{ |
|
38
|
|
|
return ($this->request->isFrontend() || $this->request->isFrontAjax()) && ! $this->maintenance_mode->level(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* FrontendRequests constructor. |
|
44
|
|
|
* |
|
45
|
|
|
* @param EE_Dependency_Map $dependency_map |
|
46
|
|
|
* @param EE_Maintenance_Mode $maintenance_mode |
|
47
|
|
|
* @param LoaderInterface $loader |
|
48
|
|
|
* @param RequestInterface $request |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct( |
|
51
|
|
|
EE_Dependency_Map $dependency_map, |
|
52
|
|
|
EE_Maintenance_Mode $maintenance_mode, |
|
53
|
|
|
LoaderInterface $loader, |
|
54
|
|
|
RequestInterface $request |
|
55
|
|
|
) { |
|
56
|
|
|
$this->maintenance_mode = $maintenance_mode; |
|
57
|
|
|
parent::__construct($dependency_map, $loader, $request); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @since $VID:$ |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function registerDependencies() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->dependency_map->registerDependencies( |
|
67
|
|
|
'EE_Front_Controller', |
|
68
|
|
|
[ |
|
69
|
|
|
'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
70
|
|
|
'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
71
|
|
|
'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
72
|
|
|
] |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* implements logic required to run during request |
|
79
|
|
|
* |
|
80
|
|
|
* @return bool |
|
81
|
|
|
* @since $VID:$ |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function requestHandler() |
|
84
|
|
|
{ |
|
85
|
|
|
do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
86
|
|
|
$this->loader->getShared('EE_Front_Controller'); |
|
87
|
|
|
return true; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|