1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\entities\routing\handlers\shared; |
4
|
|
|
|
5
|
|
|
use EE_Dependency_Map; |
6
|
|
|
use EventEspresso\core\domain\entities\routing\handlers\Route; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class AssetRequests |
10
|
|
|
* loads for any type of request where asset managers are required |
11
|
|
|
* |
12
|
|
|
* @package EventEspresso\core\domain\entities\routing\handlers\shared |
13
|
|
|
* @author Brent Christensen |
14
|
|
|
* @since \$VID:$ |
15
|
|
|
*/ |
16
|
|
|
class AssetRequests extends Route |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* returns true if the current request matches this route |
21
|
|
|
* |
22
|
|
|
* @return bool |
23
|
|
|
* @since $VID:$ |
24
|
|
|
*/ |
25
|
|
|
public function matchesCurrentRequest() |
26
|
|
|
{ |
27
|
|
|
return $this->request->isAdmin() |
28
|
|
|
|| $this->request->isFrontend() |
29
|
|
|
|| $this->request->isIframe() |
30
|
|
|
|| $this->request->isWordPressApi(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @since $VID:$ |
36
|
|
|
*/ |
37
|
|
|
protected function registerDependencies() |
38
|
|
|
{ |
39
|
|
|
$default_dependencies = [ |
40
|
|
|
'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
41
|
|
|
'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
42
|
|
|
'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
43
|
|
|
]; |
44
|
|
|
$this->dependency_map->registerDependencies( |
45
|
|
|
'EventEspresso\core\domain\services\assets\ReactAssetManager', |
46
|
|
|
$default_dependencies |
47
|
|
|
); |
48
|
|
|
$this->dependency_map->registerDependencies( |
49
|
|
|
'EventEspresso\core\domain\services\assets\CoreAssetManager', |
50
|
|
|
[ |
51
|
|
|
'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
52
|
|
|
'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
53
|
|
|
'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
54
|
|
|
'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
55
|
|
|
'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
56
|
|
|
] |
57
|
|
|
); |
58
|
|
|
$this->dependency_map->registerDependencies( |
59
|
|
|
'EventEspresso\core\services\editor\BlockRegistrationManager', |
60
|
|
|
[ |
61
|
|
|
'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
62
|
|
|
'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
63
|
|
|
'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
64
|
|
|
'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
65
|
|
|
] |
66
|
|
|
); |
67
|
|
|
$this->dependency_map->registerDependencies( |
68
|
|
|
'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager', |
69
|
|
|
[ |
70
|
|
|
'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
71
|
|
|
'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
72
|
|
|
'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
73
|
|
|
] |
74
|
|
|
); |
75
|
|
|
$this->dependency_map->registerDependencies( |
76
|
|
|
'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer', |
77
|
|
|
[ |
78
|
|
|
'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
79
|
|
|
'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
80
|
|
|
] |
81
|
|
|
); |
82
|
|
|
$this->dependency_map->registerDependencies( |
83
|
|
|
'EventEspresso\core\domain\entities\editor\blocks\EventAttendees', |
84
|
|
|
[ |
85
|
|
|
'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => EE_Dependency_Map::load_from_cache, |
86
|
|
|
'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
87
|
|
|
'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => EE_Dependency_Map::load_from_cache, |
88
|
|
|
] |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* implements logic required to run during request |
95
|
|
|
* |
96
|
|
|
* @return bool |
97
|
|
|
* @since $VID:$ |
98
|
|
|
*/ |
99
|
|
|
protected function requestHandler() |
100
|
|
|
{ |
101
|
|
|
$this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
102
|
|
|
$this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
103
|
|
|
if ($this->canLoadBlocks()) { |
104
|
|
|
$this->loader->getShared( |
105
|
|
|
'EventEspresso\core\services\editor\BlockRegistrationManager' |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
return true; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Return whether blocks can be registered/loaded or not. |
114
|
|
|
* |
115
|
|
|
* @return bool |
116
|
|
|
* @since $VID:$ |
117
|
|
|
*/ |
118
|
|
View Code Duplication |
private function canLoadBlocks() |
119
|
|
|
{ |
120
|
|
|
return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
121
|
|
|
&& function_exists('register_block_type') |
122
|
|
|
// don't load blocks if in the Divi page builder editor context |
123
|
|
|
// @see https://github.com/eventespresso/event-espresso-core/issues/814 |
124
|
|
|
&& ! $this->request->getRequestParam('et_fb', false); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|