@@ -52,234 +52,234 @@ |
||
52 | 52 | class BootstrapCore |
53 | 53 | { |
54 | 54 | |
55 | - /** |
|
56 | - * @type LoaderInterface $loader |
|
57 | - */ |
|
58 | - private $loader; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var RequestInterface $request |
|
62 | - */ |
|
63 | - protected $request; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var ResponseInterface $response |
|
67 | - */ |
|
68 | - protected $response; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var RequestStackBuilder $request_stack_builder |
|
72 | - */ |
|
73 | - protected $request_stack_builder; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var RequestStack $request_stack |
|
77 | - */ |
|
78 | - protected $request_stack; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * BootstrapCore constructor. |
|
83 | - */ |
|
84 | - public function __construct() |
|
85 | - { |
|
86 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | - add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws InvalidRequestStackMiddlewareException |
|
93 | - * @throws InvalidClassException |
|
94 | - * @throws DomainException |
|
95 | - * @throws EE_Error |
|
96 | - * @throws InvalidArgumentException |
|
97 | - * @throws InvalidDataTypeException |
|
98 | - * @throws InvalidInterfaceException |
|
99 | - * @throws ReflectionException |
|
100 | - */ |
|
101 | - public function initialize() |
|
102 | - { |
|
103 | - $this->bootstrapDependencyInjectionContainer(); |
|
104 | - $this->bootstrapDomain(); |
|
105 | - $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
106 | - add_action( |
|
107 | - 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
108 | - array($bootstrap_request, 'setupLegacyRequest') |
|
109 | - ); |
|
110 | - $this->runRequestStack(); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @throws ReflectionException |
|
116 | - * @throws EE_Error |
|
117 | - * @throws InvalidArgumentException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - */ |
|
121 | - private function bootstrapDependencyInjectionContainer() |
|
122 | - { |
|
123 | - $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
124 | - $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
125 | - $bootstrap_di->buildLoader(); |
|
126 | - $registry = $bootstrap_di->getRegistry(); |
|
127 | - $dependency_map = $bootstrap_di->getDependencyMap(); |
|
128 | - $dependency_map->initialize(); |
|
129 | - $registry->initialize(); |
|
130 | - $this->loader = $bootstrap_di->getLoader(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * configures the Domain object for core |
|
136 | - * |
|
137 | - * @return void |
|
138 | - * @throws DomainException |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidClassException |
|
142 | - * @throws InvalidFilePathException |
|
143 | - * @throws InvalidInterfaceException |
|
144 | - */ |
|
145 | - private function bootstrapDomain() |
|
146 | - { |
|
147 | - DomainFactory::getShared( |
|
148 | - new FullyQualifiedName( |
|
149 | - 'EventEspresso\core\domain\Domain' |
|
150 | - ), |
|
151 | - array( |
|
152 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
153 | - Version::fromString(espresso_version()) |
|
154 | - ) |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * sets up the request and response objects |
|
161 | - * |
|
162 | - * @return BootstrapRequestResponseObjects |
|
163 | - * @throws InvalidArgumentException |
|
164 | - */ |
|
165 | - private function bootstrapRequestResponseObjects() |
|
166 | - { |
|
167 | - /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
168 | - $bootstrap_request = $this->loader->getShared( |
|
169 | - 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
170 | - array($this->loader) |
|
171 | - ); |
|
172 | - $bootstrap_request->buildRequestResponse(); |
|
173 | - $bootstrap_request->shareRequestResponse(); |
|
174 | - $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
175 | - $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
176 | - return $bootstrap_request; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * run_request_stack |
|
182 | - * construct request stack and run middleware apps |
|
183 | - * |
|
184 | - * @throws InvalidRequestStackMiddlewareException |
|
185 | - * @throws InvalidInterfaceException |
|
186 | - * @throws InvalidDataTypeException |
|
187 | - * @throws EE_Error |
|
188 | - */ |
|
189 | - public function runRequestStack() |
|
190 | - { |
|
191 | - $this->loadAutoloader(); |
|
192 | - $this->setAutoloadersForRequiredFiles(); |
|
193 | - $this->request_stack_builder = $this->buildRequestStack(); |
|
194 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
195 | - new RequestStackCoreApp() |
|
196 | - ); |
|
197 | - $this->request_stack->handleRequest($this->request, $this->response); |
|
198 | - $this->request_stack->handleResponse(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * load_autoloader |
|
204 | - * |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - protected function loadAutoloader() |
|
208 | - { |
|
209 | - // load interfaces |
|
210 | - espresso_load_required( |
|
211 | - 'EEH_Autoloader', |
|
212 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
213 | - ); |
|
214 | - EEH_Autoloader::instance(); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * load_required_files |
|
221 | - * |
|
222 | - * @throws EE_Error |
|
223 | - */ |
|
224 | - protected function setAutoloadersForRequiredFiles() |
|
225 | - { |
|
226 | - // load interfaces |
|
227 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
228 | - // load helpers |
|
229 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
230 | - // load request stack |
|
231 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
232 | - // load middleware |
|
233 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * build_request_stack |
|
240 | - * |
|
241 | - * @return RequestStackBuilder |
|
242 | - */ |
|
243 | - public function buildRequestStack() |
|
244 | - { |
|
245 | - $request_stack_builder = new RequestStackBuilder($this->loader); |
|
246 | - /** |
|
247 | - * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
248 | - * so items at the beginning of the final middleware stack will run last. |
|
249 | - * First parameter is the middleware classname, second is an array of arguments |
|
250 | - */ |
|
251 | - $stack_apps = apply_filters( |
|
252 | - 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
253 | - array( |
|
254 | - // first in last out |
|
255 | - 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
256 | - 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
257 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
258 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
259 | - // last in first out |
|
260 | - 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
261 | - ) |
|
262 | - ); |
|
263 | - // legacy filter for backwards compatibility |
|
264 | - $stack_apps = apply_filters( |
|
265 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
266 | - $stack_apps |
|
267 | - ); |
|
268 | - // load middleware onto stack : FILO (First In Last Out) |
|
269 | - // items at the beginning of the $stack_apps array will run last |
|
270 | - foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
271 | - $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
272 | - } |
|
273 | - // finally, we'll add this on its own because we need it to always be part of the stack |
|
274 | - // and we also need it to always run first because the rest of the system relies on it |
|
275 | - $request_stack_builder->push( |
|
276 | - array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
277 | - ); |
|
278 | - return apply_filters( |
|
279 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
280 | - $request_stack_builder |
|
281 | - ); |
|
282 | - } |
|
55 | + /** |
|
56 | + * @type LoaderInterface $loader |
|
57 | + */ |
|
58 | + private $loader; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var RequestInterface $request |
|
62 | + */ |
|
63 | + protected $request; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var ResponseInterface $response |
|
67 | + */ |
|
68 | + protected $response; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var RequestStackBuilder $request_stack_builder |
|
72 | + */ |
|
73 | + protected $request_stack_builder; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var RequestStack $request_stack |
|
77 | + */ |
|
78 | + protected $request_stack; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * BootstrapCore constructor. |
|
83 | + */ |
|
84 | + public function __construct() |
|
85 | + { |
|
86 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | + add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws InvalidRequestStackMiddlewareException |
|
93 | + * @throws InvalidClassException |
|
94 | + * @throws DomainException |
|
95 | + * @throws EE_Error |
|
96 | + * @throws InvalidArgumentException |
|
97 | + * @throws InvalidDataTypeException |
|
98 | + * @throws InvalidInterfaceException |
|
99 | + * @throws ReflectionException |
|
100 | + */ |
|
101 | + public function initialize() |
|
102 | + { |
|
103 | + $this->bootstrapDependencyInjectionContainer(); |
|
104 | + $this->bootstrapDomain(); |
|
105 | + $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
106 | + add_action( |
|
107 | + 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
108 | + array($bootstrap_request, 'setupLegacyRequest') |
|
109 | + ); |
|
110 | + $this->runRequestStack(); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @throws ReflectionException |
|
116 | + * @throws EE_Error |
|
117 | + * @throws InvalidArgumentException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + */ |
|
121 | + private function bootstrapDependencyInjectionContainer() |
|
122 | + { |
|
123 | + $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
124 | + $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
125 | + $bootstrap_di->buildLoader(); |
|
126 | + $registry = $bootstrap_di->getRegistry(); |
|
127 | + $dependency_map = $bootstrap_di->getDependencyMap(); |
|
128 | + $dependency_map->initialize(); |
|
129 | + $registry->initialize(); |
|
130 | + $this->loader = $bootstrap_di->getLoader(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * configures the Domain object for core |
|
136 | + * |
|
137 | + * @return void |
|
138 | + * @throws DomainException |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidClassException |
|
142 | + * @throws InvalidFilePathException |
|
143 | + * @throws InvalidInterfaceException |
|
144 | + */ |
|
145 | + private function bootstrapDomain() |
|
146 | + { |
|
147 | + DomainFactory::getShared( |
|
148 | + new FullyQualifiedName( |
|
149 | + 'EventEspresso\core\domain\Domain' |
|
150 | + ), |
|
151 | + array( |
|
152 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
153 | + Version::fromString(espresso_version()) |
|
154 | + ) |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * sets up the request and response objects |
|
161 | + * |
|
162 | + * @return BootstrapRequestResponseObjects |
|
163 | + * @throws InvalidArgumentException |
|
164 | + */ |
|
165 | + private function bootstrapRequestResponseObjects() |
|
166 | + { |
|
167 | + /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
168 | + $bootstrap_request = $this->loader->getShared( |
|
169 | + 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
170 | + array($this->loader) |
|
171 | + ); |
|
172 | + $bootstrap_request->buildRequestResponse(); |
|
173 | + $bootstrap_request->shareRequestResponse(); |
|
174 | + $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
175 | + $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
176 | + return $bootstrap_request; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * run_request_stack |
|
182 | + * construct request stack and run middleware apps |
|
183 | + * |
|
184 | + * @throws InvalidRequestStackMiddlewareException |
|
185 | + * @throws InvalidInterfaceException |
|
186 | + * @throws InvalidDataTypeException |
|
187 | + * @throws EE_Error |
|
188 | + */ |
|
189 | + public function runRequestStack() |
|
190 | + { |
|
191 | + $this->loadAutoloader(); |
|
192 | + $this->setAutoloadersForRequiredFiles(); |
|
193 | + $this->request_stack_builder = $this->buildRequestStack(); |
|
194 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
195 | + new RequestStackCoreApp() |
|
196 | + ); |
|
197 | + $this->request_stack->handleRequest($this->request, $this->response); |
|
198 | + $this->request_stack->handleResponse(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * load_autoloader |
|
204 | + * |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + protected function loadAutoloader() |
|
208 | + { |
|
209 | + // load interfaces |
|
210 | + espresso_load_required( |
|
211 | + 'EEH_Autoloader', |
|
212 | + EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
213 | + ); |
|
214 | + EEH_Autoloader::instance(); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * load_required_files |
|
221 | + * |
|
222 | + * @throws EE_Error |
|
223 | + */ |
|
224 | + protected function setAutoloadersForRequiredFiles() |
|
225 | + { |
|
226 | + // load interfaces |
|
227 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
228 | + // load helpers |
|
229 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
230 | + // load request stack |
|
231 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
232 | + // load middleware |
|
233 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * build_request_stack |
|
240 | + * |
|
241 | + * @return RequestStackBuilder |
|
242 | + */ |
|
243 | + public function buildRequestStack() |
|
244 | + { |
|
245 | + $request_stack_builder = new RequestStackBuilder($this->loader); |
|
246 | + /** |
|
247 | + * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
248 | + * so items at the beginning of the final middleware stack will run last. |
|
249 | + * First parameter is the middleware classname, second is an array of arguments |
|
250 | + */ |
|
251 | + $stack_apps = apply_filters( |
|
252 | + 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
253 | + array( |
|
254 | + // first in last out |
|
255 | + 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
256 | + 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
257 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
258 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
259 | + // last in first out |
|
260 | + 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
261 | + ) |
|
262 | + ); |
|
263 | + // legacy filter for backwards compatibility |
|
264 | + $stack_apps = apply_filters( |
|
265 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
266 | + $stack_apps |
|
267 | + ); |
|
268 | + // load middleware onto stack : FILO (First In Last Out) |
|
269 | + // items at the beginning of the $stack_apps array will run last |
|
270 | + foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
271 | + $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
272 | + } |
|
273 | + // finally, we'll add this on its own because we need it to always be part of the stack |
|
274 | + // and we also need it to always run first because the rest of the system relies on it |
|
275 | + $request_stack_builder->push( |
|
276 | + array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
277 | + ); |
|
278 | + return apply_filters( |
|
279 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
280 | + $request_stack_builder |
|
281 | + ); |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -21,59 +21,59 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class EE_Messages_Email_Newsletter_Validator extends EE_Messages_Validator |
23 | 23 | { |
24 | - public function __construct($fields, $context) |
|
25 | - { |
|
26 | - $this->_m_name = 'email'; |
|
27 | - $this->_mt_name = 'newsletter'; |
|
24 | + public function __construct($fields, $context) |
|
25 | + { |
|
26 | + $this->_m_name = 'email'; |
|
27 | + $this->_mt_name = 'newsletter'; |
|
28 | 28 | |
29 | - parent::__construct($fields, $context); |
|
30 | - } |
|
29 | + parent::__construct($fields, $context); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * custom validator (restricting what was originally set by the messenger) |
|
34 | - */ |
|
35 | - protected function _modify_validator() |
|
36 | - { |
|
37 | - if ($this->_context == 'attendee') { |
|
38 | - $this->_valid_shortcodes_modifier[$this->_context]['from'] = array( |
|
39 | - 'recipient_details', |
|
40 | - 'email', |
|
41 | - 'organization', |
|
42 | - ); |
|
43 | - } |
|
32 | + /** |
|
33 | + * custom validator (restricting what was originally set by the messenger) |
|
34 | + */ |
|
35 | + protected function _modify_validator() |
|
36 | + { |
|
37 | + if ($this->_context == 'attendee') { |
|
38 | + $this->_valid_shortcodes_modifier[$this->_context]['from'] = array( |
|
39 | + 'recipient_details', |
|
40 | + 'email', |
|
41 | + 'organization', |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | - //excluded shortcodes |
|
46 | - $fields = array('to', 'from', 'subject', 'content', 'newsletter_content'); |
|
47 | - foreach ($fields as $field) { |
|
48 | - $this->_specific_shortcode_excludes[$field] = array( |
|
49 | - '[RECIPIENT_REGISTRATION_CODE]', |
|
50 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]', |
|
51 | - '[EVENT_AUTHOR_EMAIL]', |
|
52 | - ); |
|
53 | - } |
|
54 | - $add_excludes = array( |
|
55 | - '[RECIPIENT_FNAME]', |
|
56 | - '[RECIPIENT_LNAME]', |
|
57 | - '[RECIPIENT_EMAIL]', |
|
58 | - '[COMPANY]', |
|
59 | - '[CO_ADD1]', |
|
60 | - '[CO_ADD2]', |
|
61 | - '[CO_CITY]', |
|
62 | - '[CO_STATE]', |
|
63 | - '[CO_ZIP]', |
|
64 | - '[CO_LOGO]', |
|
65 | - '[CO_PHONE]', |
|
66 | - '[CO_LOGO_URL]', |
|
67 | - '[CO_FACEBOOK_URL]', |
|
68 | - '[CO_TWITTER_URL]', |
|
69 | - '[CO_PINTEREST_URL]', |
|
70 | - '[CO_GOOGLE_URL]', |
|
71 | - '[CO_LINKEDIN_URL]', |
|
72 | - '[CO_INSTAGRAM_URL]', |
|
73 | - ); |
|
74 | - $this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'], |
|
75 | - $add_excludes); |
|
76 | - $this->_specific_shortcode_excludes['content'] = array_merge($this->_specific_shortcode_excludes['content'], |
|
77 | - array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]')); |
|
78 | - } |
|
45 | + //excluded shortcodes |
|
46 | + $fields = array('to', 'from', 'subject', 'content', 'newsletter_content'); |
|
47 | + foreach ($fields as $field) { |
|
48 | + $this->_specific_shortcode_excludes[$field] = array( |
|
49 | + '[RECIPIENT_REGISTRATION_CODE]', |
|
50 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]', |
|
51 | + '[EVENT_AUTHOR_EMAIL]', |
|
52 | + ); |
|
53 | + } |
|
54 | + $add_excludes = array( |
|
55 | + '[RECIPIENT_FNAME]', |
|
56 | + '[RECIPIENT_LNAME]', |
|
57 | + '[RECIPIENT_EMAIL]', |
|
58 | + '[COMPANY]', |
|
59 | + '[CO_ADD1]', |
|
60 | + '[CO_ADD2]', |
|
61 | + '[CO_CITY]', |
|
62 | + '[CO_STATE]', |
|
63 | + '[CO_ZIP]', |
|
64 | + '[CO_LOGO]', |
|
65 | + '[CO_PHONE]', |
|
66 | + '[CO_LOGO_URL]', |
|
67 | + '[CO_FACEBOOK_URL]', |
|
68 | + '[CO_TWITTER_URL]', |
|
69 | + '[CO_PINTEREST_URL]', |
|
70 | + '[CO_GOOGLE_URL]', |
|
71 | + '[CO_LINKEDIN_URL]', |
|
72 | + '[CO_INSTAGRAM_URL]', |
|
73 | + ); |
|
74 | + $this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'], |
|
75 | + $add_excludes); |
|
76 | + $this->_specific_shortcode_excludes['content'] = array_merge($this->_specific_shortcode_excludes['content'], |
|
77 | + array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]')); |
|
78 | + } |
|
79 | 79 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @subpackage helpers |
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('No direct script access allowed'); |
11 | 11 | } |
12 | 12 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -23,152 +23,152 @@ discard block |
||
23 | 23 | class EE_Newsletter_message_type extends EE_message_type |
24 | 24 | { |
25 | 25 | |
26 | - public function __construct() |
|
27 | - { |
|
28 | - $this->name = 'newsletter'; |
|
29 | - $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', |
|
30 | - 'event_espresso'); |
|
31 | - $this->label = array( |
|
32 | - 'singular' => __('batch', 'event_espresso'), |
|
33 | - 'plural' => __('batches', 'event_espresso'), |
|
34 | - ); |
|
35 | - $this->_master_templates = array( |
|
36 | - 'email' => 'registration', |
|
37 | - ); |
|
38 | - |
|
39 | - parent::__construct(); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - protected function _set_admin_pages() |
|
44 | - { |
|
45 | - $this->admin_registered_pages = array(); //no admin pages to register this with. |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - protected function _set_data_handler() |
|
50 | - { |
|
51 | - $this->_data_handler = 'Registrations'; |
|
52 | - $this->_single_message = $this->_data instanceof EE_Registration; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
57 | - { |
|
58 | - //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects. |
|
59 | - return array($registration); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - protected function _set_admin_settings_fields() |
|
64 | - { |
|
65 | - $this->_admin_settings_fields = array(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - protected function _set_contexts() |
|
70 | - { |
|
71 | - $this->_context_label = array( |
|
72 | - 'label' => __('recipient', 'event_espresso'), |
|
73 | - 'plural' => __('recipients', 'event_espresso'), |
|
74 | - 'description' => __('Recipient\'s are who will receive the message.', 'event_espresso'), |
|
75 | - ); |
|
76 | - |
|
77 | - $this->_contexts = array( |
|
78 | - 'attendee' => array( |
|
79 | - 'label' => __('Registrant', 'event_espresso'), |
|
80 | - 'description' => __('This template goes to selected registrants.', 'event_espresso'), |
|
81 | - ), |
|
82 | - ); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * used to set the valid shortcodes. |
|
88 | - * For the newsletter message type we only have two valid shortcode libraries in use, recipient details and |
|
89 | - * organization. That's it! |
|
90 | - * |
|
91 | - * @since 4.3.0 |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - protected function _set_valid_shortcodes() |
|
95 | - { |
|
96 | - parent::_set_valid_shortcodes(); |
|
97 | - |
|
98 | - $included_shortcodes = array( |
|
99 | - 'recipient_details', |
|
100 | - 'organization', |
|
101 | - 'newsletter', |
|
102 | - ); |
|
103 | - |
|
104 | - foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
|
105 | - foreach ($shortcodes as $key => $shortcode) { |
|
106 | - if (! in_array($shortcode, $included_shortcodes)) { |
|
107 | - unset($this->_valid_shortcodes[$context][$key]); |
|
108 | - } |
|
109 | - } |
|
110 | - $this->_valid_shortcodes[$context][] = 'newsletter'; |
|
111 | - } |
|
112 | - |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * Override default _attendee_addressees in EE_message_type because we want to loop through the registrations |
|
118 | - * for EE_message_type. |
|
119 | - */ |
|
120 | - protected function _attendee_addressees() |
|
121 | - { |
|
122 | - $addressee = array(); |
|
123 | - |
|
124 | - //looping through registrations |
|
125 | - foreach ($this->_data->registrations as $reg_id => $details) { |
|
126 | - //set $attendee array to blank on each loop |
|
127 | - $aee = array(); |
|
128 | - |
|
129 | - //need to get the attendee from this registration. |
|
130 | - $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee |
|
131 | - ? $details['att_obj'] |
|
132 | - : null; |
|
133 | - |
|
134 | - if (! $attendee instanceof EE_Attendee) { |
|
135 | - continue; |
|
136 | - } |
|
137 | - |
|
138 | - //set $aee from attendee object |
|
139 | - $aee['att_obj'] = $attendee; |
|
140 | - $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs']) |
|
141 | - ? $this->_data->attendees[$attendee->ID()]['reg_objs'] |
|
142 | - : array(); |
|
143 | - $aee['attendee_email'] = $attendee->email(); |
|
144 | - $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs']) |
|
145 | - ? $this->_data->attendees[$attendee->ID()]['tkt_objs'] |
|
146 | - : array(); |
|
147 | - |
|
148 | - if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) { |
|
149 | - $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
150 | - $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
151 | - } else { |
|
152 | - $aee['evt_objs'] = $aee['events'] = array(); |
|
153 | - } |
|
154 | - |
|
155 | - $aee['reg_obj'] = isset($details['reg_obj']) |
|
156 | - ? $details['reg_obj'] |
|
157 | - : null; |
|
158 | - $aee['attendees'] = $this->_data->attendees; |
|
159 | - |
|
160 | - //merge in the primary attendee data |
|
161 | - $aee = array_merge($this->_default_addressee_data, $aee); |
|
162 | - |
|
163 | - //make sure txn is set |
|
164 | - if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) { |
|
165 | - $aee['txn'] = $aee['reg_obj']->transaction(); |
|
166 | - } |
|
167 | - |
|
168 | - $addressee[] = new EE_Messages_Addressee($aee); |
|
169 | - } |
|
170 | - return $addressee; |
|
171 | - } |
|
26 | + public function __construct() |
|
27 | + { |
|
28 | + $this->name = 'newsletter'; |
|
29 | + $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', |
|
30 | + 'event_espresso'); |
|
31 | + $this->label = array( |
|
32 | + 'singular' => __('batch', 'event_espresso'), |
|
33 | + 'plural' => __('batches', 'event_espresso'), |
|
34 | + ); |
|
35 | + $this->_master_templates = array( |
|
36 | + 'email' => 'registration', |
|
37 | + ); |
|
38 | + |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + protected function _set_admin_pages() |
|
44 | + { |
|
45 | + $this->admin_registered_pages = array(); //no admin pages to register this with. |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + protected function _set_data_handler() |
|
50 | + { |
|
51 | + $this->_data_handler = 'Registrations'; |
|
52 | + $this->_single_message = $this->_data instanceof EE_Registration; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) |
|
57 | + { |
|
58 | + //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects. |
|
59 | + return array($registration); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + protected function _set_admin_settings_fields() |
|
64 | + { |
|
65 | + $this->_admin_settings_fields = array(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + protected function _set_contexts() |
|
70 | + { |
|
71 | + $this->_context_label = array( |
|
72 | + 'label' => __('recipient', 'event_espresso'), |
|
73 | + 'plural' => __('recipients', 'event_espresso'), |
|
74 | + 'description' => __('Recipient\'s are who will receive the message.', 'event_espresso'), |
|
75 | + ); |
|
76 | + |
|
77 | + $this->_contexts = array( |
|
78 | + 'attendee' => array( |
|
79 | + 'label' => __('Registrant', 'event_espresso'), |
|
80 | + 'description' => __('This template goes to selected registrants.', 'event_espresso'), |
|
81 | + ), |
|
82 | + ); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * used to set the valid shortcodes. |
|
88 | + * For the newsletter message type we only have two valid shortcode libraries in use, recipient details and |
|
89 | + * organization. That's it! |
|
90 | + * |
|
91 | + * @since 4.3.0 |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + protected function _set_valid_shortcodes() |
|
95 | + { |
|
96 | + parent::_set_valid_shortcodes(); |
|
97 | + |
|
98 | + $included_shortcodes = array( |
|
99 | + 'recipient_details', |
|
100 | + 'organization', |
|
101 | + 'newsletter', |
|
102 | + ); |
|
103 | + |
|
104 | + foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
|
105 | + foreach ($shortcodes as $key => $shortcode) { |
|
106 | + if (! in_array($shortcode, $included_shortcodes)) { |
|
107 | + unset($this->_valid_shortcodes[$context][$key]); |
|
108 | + } |
|
109 | + } |
|
110 | + $this->_valid_shortcodes[$context][] = 'newsletter'; |
|
111 | + } |
|
112 | + |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * Override default _attendee_addressees in EE_message_type because we want to loop through the registrations |
|
118 | + * for EE_message_type. |
|
119 | + */ |
|
120 | + protected function _attendee_addressees() |
|
121 | + { |
|
122 | + $addressee = array(); |
|
123 | + |
|
124 | + //looping through registrations |
|
125 | + foreach ($this->_data->registrations as $reg_id => $details) { |
|
126 | + //set $attendee array to blank on each loop |
|
127 | + $aee = array(); |
|
128 | + |
|
129 | + //need to get the attendee from this registration. |
|
130 | + $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee |
|
131 | + ? $details['att_obj'] |
|
132 | + : null; |
|
133 | + |
|
134 | + if (! $attendee instanceof EE_Attendee) { |
|
135 | + continue; |
|
136 | + } |
|
137 | + |
|
138 | + //set $aee from attendee object |
|
139 | + $aee['att_obj'] = $attendee; |
|
140 | + $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs']) |
|
141 | + ? $this->_data->attendees[$attendee->ID()]['reg_objs'] |
|
142 | + : array(); |
|
143 | + $aee['attendee_email'] = $attendee->email(); |
|
144 | + $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs']) |
|
145 | + ? $this->_data->attendees[$attendee->ID()]['tkt_objs'] |
|
146 | + : array(); |
|
147 | + |
|
148 | + if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) { |
|
149 | + $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
150 | + $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
151 | + } else { |
|
152 | + $aee['evt_objs'] = $aee['events'] = array(); |
|
153 | + } |
|
154 | + |
|
155 | + $aee['reg_obj'] = isset($details['reg_obj']) |
|
156 | + ? $details['reg_obj'] |
|
157 | + : null; |
|
158 | + $aee['attendees'] = $this->_data->attendees; |
|
159 | + |
|
160 | + //merge in the primary attendee data |
|
161 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
162 | + |
|
163 | + //make sure txn is set |
|
164 | + if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) { |
|
165 | + $aee['txn'] = $aee['reg_obj']->transaction(); |
|
166 | + } |
|
167 | + |
|
168 | + $addressee[] = new EE_Messages_Addressee($aee); |
|
169 | + } |
|
170 | + return $addressee; |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | 174 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @subpackage helpers |
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('No direct script access allowed'); |
11 | 11 | } |
12 | 12 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
105 | 105 | foreach ($shortcodes as $key => $shortcode) { |
106 | - if (! in_array($shortcode, $included_shortcodes)) { |
|
106 | + if ( ! in_array($shortcode, $included_shortcodes)) { |
|
107 | 107 | unset($this->_valid_shortcodes[$context][$key]); |
108 | 108 | } |
109 | 109 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ? $details['att_obj'] |
132 | 132 | : null; |
133 | 133 | |
134 | - if (! $attendee instanceof EE_Attendee) { |
|
134 | + if ( ! $attendee instanceof EE_Attendee) { |
|
135 | 135 | continue; |
136 | 136 | } |
137 | 137 |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.59.rc.032'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.59.rc.032'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
9 | 9 | |
10 | 10 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -25,849 +25,849 @@ discard block |
||
25 | 25 | class EE_Dependency_Map |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * This means that the requested class dependency is not present in the dependency map |
|
30 | - */ |
|
31 | - const not_registered = 0; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | - */ |
|
36 | - const load_new_object = 1; |
|
37 | - |
|
38 | - /** |
|
39 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | - */ |
|
42 | - const load_from_cache = 2; |
|
43 | - |
|
44 | - /** |
|
45 | - * When registering a dependency, |
|
46 | - * this indicates to keep any existing dependencies that already exist, |
|
47 | - * and simply discard any new dependencies declared in the incoming data |
|
48 | - */ |
|
49 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | - |
|
51 | - /** |
|
52 | - * When registering a dependency, |
|
53 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | - */ |
|
55 | - const OVERWRITE_DEPENDENCIES = 1; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @type EE_Dependency_Map $_instance |
|
61 | - */ |
|
62 | - protected static $_instance; |
|
63 | - |
|
64 | - /** |
|
65 | - * @type RequestInterface $request |
|
66 | - */ |
|
67 | - protected $request; |
|
68 | - |
|
69 | - /** |
|
70 | - * @type LegacyRequestInterface $legacy_request |
|
71 | - */ |
|
72 | - protected $legacy_request; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type ResponseInterface $response |
|
76 | - */ |
|
77 | - protected $response; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type LoaderInterface $loader |
|
81 | - */ |
|
82 | - protected $loader; |
|
83 | - |
|
84 | - /** |
|
85 | - * @type array $_dependency_map |
|
86 | - */ |
|
87 | - protected $_dependency_map = array(); |
|
88 | - |
|
89 | - /** |
|
90 | - * @type array $_class_loaders |
|
91 | - */ |
|
92 | - protected $_class_loaders = array(); |
|
93 | - |
|
94 | - /** |
|
95 | - * @type array $_aliases |
|
96 | - */ |
|
97 | - protected $_aliases = array(); |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * EE_Dependency_Map constructor. |
|
103 | - */ |
|
104 | - protected function __construct() |
|
105 | - { |
|
106 | - // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | - do_action('EE_Dependency_Map____construct'); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @throws InvalidDataTypeException |
|
114 | - * @throws InvalidInterfaceException |
|
115 | - * @throws InvalidArgumentException |
|
116 | - */ |
|
117 | - public function initialize() |
|
118 | - { |
|
119 | - $this->_register_core_dependencies(); |
|
120 | - $this->_register_core_class_loaders(); |
|
121 | - $this->_register_core_aliases(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @singleton method used to instantiate class object |
|
128 | - * @return EE_Dependency_Map |
|
129 | - */ |
|
130 | - public static function instance() { |
|
131 | - // check if class object is instantiated, and instantiated properly |
|
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | - self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | - } |
|
135 | - return self::$_instance; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param RequestInterface $request |
|
141 | - */ |
|
142 | - public function setRequest(RequestInterface $request) |
|
143 | - { |
|
144 | - $this->request = $request; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param LegacyRequestInterface $legacy_request |
|
150 | - */ |
|
151 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | - { |
|
153 | - $this->legacy_request = $legacy_request; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param ResponseInterface $response |
|
159 | - */ |
|
160 | - public function setResponse(ResponseInterface $response) |
|
161 | - { |
|
162 | - $this->response = $response; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @param LoaderInterface $loader |
|
169 | - */ |
|
170 | - public function setLoader(LoaderInterface $loader) |
|
171 | - { |
|
172 | - $this->loader = $loader; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $class |
|
179 | - * @param array $dependencies |
|
180 | - * @param int $overwrite |
|
181 | - * @return bool |
|
182 | - */ |
|
183 | - public static function register_dependencies( |
|
184 | - $class, |
|
185 | - array $dependencies, |
|
186 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | - ) { |
|
188 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | - * to the class specified by the first parameter. |
|
196 | - * IMPORTANT !!! |
|
197 | - * The order of elements in the incoming $dependencies array MUST match |
|
198 | - * the order of the constructor parameters for the class in question. |
|
199 | - * This is especially important when overriding any existing dependencies that are registered. |
|
200 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | - * |
|
202 | - * @param string $class |
|
203 | - * @param array $dependencies |
|
204 | - * @param int $overwrite |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function registerDependencies( |
|
208 | - $class, |
|
209 | - array $dependencies, |
|
210 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | - ) { |
|
212 | - $class = trim($class, '\\'); |
|
213 | - $registered = false; |
|
214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | - } |
|
217 | - // we need to make sure that any aliases used when registering a dependency |
|
218 | - // get resolved to the correct class name |
|
219 | - foreach ($dependencies as $dependency => $load_source) { |
|
220 | - $alias = self::$_instance->get_alias($dependency); |
|
221 | - if ( |
|
222 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | - ) { |
|
225 | - unset($dependencies[$dependency]); |
|
226 | - $dependencies[$alias] = $load_source; |
|
227 | - $registered = true; |
|
228 | - } |
|
229 | - } |
|
230 | - // now add our two lists of dependencies together. |
|
231 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | - // so $dependencies is NOT overwritten because it is listed first |
|
233 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | - // Union is way faster than array_merge() but should be used with caution... |
|
235 | - // especially with numerically indexed arrays |
|
236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | - // now we need to ensure that the resulting dependencies |
|
238 | - // array only has the entries that are required for the class |
|
239 | - // so first count how many dependencies were originally registered for the class |
|
240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | - // if that count is non-zero (meaning dependencies were already registered) |
|
242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | - // then truncate the final array to match that count |
|
244 | - ? array_slice($dependencies, 0, $dependency_count) |
|
245 | - // otherwise just take the incoming array because nothing previously existed |
|
246 | - : $dependencies; |
|
247 | - return $registered; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param string $class_name |
|
254 | - * @param string $loader |
|
255 | - * @return bool |
|
256 | - * @throws DomainException |
|
257 | - */ |
|
258 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | - { |
|
260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | - throw new DomainException( |
|
262 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | - ); |
|
264 | - } |
|
265 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | - if ( |
|
267 | - ! is_callable($loader) |
|
268 | - && ( |
|
269 | - strpos($loader, 'load_') !== 0 |
|
270 | - || ! method_exists('EE_Registry', $loader) |
|
271 | - ) |
|
272 | - ) { |
|
273 | - throw new DomainException( |
|
274 | - sprintf( |
|
275 | - esc_html__( |
|
276 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | - 'event_espresso' |
|
278 | - ), |
|
279 | - $loader |
|
280 | - ) |
|
281 | - ); |
|
282 | - } |
|
283 | - $class_name = self::$_instance->get_alias($class_name); |
|
284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | - return true; |
|
287 | - } |
|
288 | - return false; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public function dependency_map() |
|
297 | - { |
|
298 | - return $this->_dependency_map; |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | - * |
|
306 | - * @param string $class_name |
|
307 | - * @return boolean |
|
308 | - */ |
|
309 | - public function has($class_name = '') |
|
310 | - { |
|
311 | - // all legacy models have the same dependencies |
|
312 | - if (strpos($class_name, 'EEM_') === 0) { |
|
313 | - $class_name = 'LEGACY_MODELS'; |
|
314 | - } |
|
315 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | - * |
|
323 | - * @param string $class_name |
|
324 | - * @param string $dependency |
|
325 | - * @return bool |
|
326 | - */ |
|
327 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | - { |
|
329 | - // all legacy models have the same dependencies |
|
330 | - if (strpos($class_name, 'EEM_') === 0) { |
|
331 | - $class_name = 'LEGACY_MODELS'; |
|
332 | - } |
|
333 | - $dependency = $this->get_alias($dependency); |
|
334 | - return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | - ? true |
|
336 | - : false; |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | - * |
|
344 | - * @param string $class_name |
|
345 | - * @param string $dependency |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | - { |
|
350 | - // all legacy models have the same dependencies |
|
351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
352 | - $class_name = 'LEGACY_MODELS'; |
|
353 | - } |
|
354 | - $dependency = $this->get_alias($dependency); |
|
355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | - ? $this->_dependency_map[$class_name][$dependency] |
|
357 | - : EE_Dependency_Map::not_registered; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param string $class_name |
|
364 | - * @return string | Closure |
|
365 | - */ |
|
366 | - public function class_loader($class_name) |
|
367 | - { |
|
368 | - // all legacy models use load_model() |
|
369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
370 | - return 'load_model'; |
|
371 | - } |
|
372 | - $class_name = $this->get_alias($class_name); |
|
373 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @return array |
|
380 | - */ |
|
381 | - public function class_loaders() |
|
382 | - { |
|
383 | - return $this->_class_loaders; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * adds an alias for a classname |
|
390 | - * |
|
391 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | - */ |
|
395 | - public function add_alias($class_name, $alias, $for_class = '') |
|
396 | - { |
|
397 | - if ($for_class !== '') { |
|
398 | - if (! isset($this->_aliases[$for_class])) { |
|
399 | - $this->_aliases[$for_class] = array(); |
|
400 | - } |
|
401 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | - } |
|
403 | - $this->_aliases[$class_name] = $alias; |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * returns TRUE if the provided class name has an alias |
|
410 | - * |
|
411 | - * @param string $class_name |
|
412 | - * @param string $for_class |
|
413 | - * @return bool |
|
414 | - */ |
|
415 | - public function has_alias($class_name = '', $for_class = '') |
|
416 | - { |
|
417 | - return isset($this->_aliases[$for_class][$class_name]) |
|
418 | - || ( |
|
419 | - isset($this->_aliases[$class_name]) |
|
420 | - && ! is_array($this->_aliases[$class_name]) |
|
421 | - ); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | - * for example: |
|
430 | - * if the following two entries were added to the _aliases array: |
|
431 | - * array( |
|
432 | - * 'interface_alias' => 'some\namespace\interface' |
|
433 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | - * ) |
|
435 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | - * to load an instance of 'some\namespace\classname' |
|
437 | - * |
|
438 | - * @param string $class_name |
|
439 | - * @param string $for_class |
|
440 | - * @return string |
|
441 | - */ |
|
442 | - public function get_alias($class_name = '', $for_class = '') |
|
443 | - { |
|
444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
445 | - return $class_name; |
|
446 | - } |
|
447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | - } |
|
450 | - return $this->get_alias($this->_aliases[$class_name]); |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | - * This is done by using the following class constants: |
|
459 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | - */ |
|
462 | - protected function _register_core_dependencies() |
|
463 | - { |
|
464 | - $this->_dependency_map = array( |
|
465 | - 'EE_Request_Handler' => array( |
|
466 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | - ), |
|
468 | - 'EE_System' => array( |
|
469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | - ), |
|
474 | - 'EE_Session' => array( |
|
475 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | - ), |
|
479 | - 'EE_Cart' => array( |
|
480 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | - ), |
|
482 | - 'EE_Front_Controller' => array( |
|
483 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messenger_Collection_Loader' => array( |
|
488 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | - ), |
|
490 | - 'EE_Message_Type_Collection_Loader' => array( |
|
491 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | - ), |
|
493 | - 'EE_Message_Resource_Manager' => array( |
|
494 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | - ), |
|
498 | - 'EE_Message_Factory' => array( |
|
499 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | - ), |
|
501 | - 'EE_messages' => array( |
|
502 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | - ), |
|
504 | - 'EE_Messages_Generator' => array( |
|
505 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EE_Messages_Processor' => array( |
|
511 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | - ), |
|
513 | - 'EE_Messages_Queue' => array( |
|
514 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | - ), |
|
516 | - 'EE_Messages_Template_Defaults' => array( |
|
517 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | - ), |
|
520 | - 'EE_Message_To_Generate_From_Request' => array( |
|
521 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | - ), |
|
531 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | - ), |
|
534 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | - ), |
|
538 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | - ), |
|
541 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | - ), |
|
544 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | - ), |
|
547 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | - ), |
|
550 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | - ), |
|
553 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | - ), |
|
556 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | - ), |
|
559 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | - ), |
|
562 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | - ), |
|
565 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | - ), |
|
568 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | - ), |
|
574 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | - ), |
|
577 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - ), |
|
580 | - 'EE_Data_Migration_Class_Base' => array( |
|
581 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | - ), |
|
584 | - 'EE_DMS_Core_4_1_0' => array( |
|
585 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | - ), |
|
588 | - 'EE_DMS_Core_4_2_0' => array( |
|
589 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | - ), |
|
592 | - 'EE_DMS_Core_4_3_0' => array( |
|
593 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | - ), |
|
596 | - 'EE_DMS_Core_4_4_0' => array( |
|
597 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | - ), |
|
600 | - 'EE_DMS_Core_4_5_0' => array( |
|
601 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | - ), |
|
604 | - 'EE_DMS_Core_4_6_0' => array( |
|
605 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | - ), |
|
608 | - 'EE_DMS_Core_4_7_0' => array( |
|
609 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | - ), |
|
612 | - 'EE_DMS_Core_4_8_0' => array( |
|
613 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | - ), |
|
616 | - 'EE_DMS_Core_4_9_0' => array( |
|
617 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ), |
|
620 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | - ), |
|
625 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ), |
|
628 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | - ), |
|
631 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | - ), |
|
634 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | - ), |
|
637 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | - ), |
|
640 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | - ), |
|
643 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | - ), |
|
649 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | - ), |
|
652 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | - null, |
|
658 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | - ), |
|
660 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | - ), |
|
663 | - 'LEGACY_MODELS' => array( |
|
664 | - null, |
|
665 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | - ), |
|
667 | - 'EE_Module_Request_Router' => array( |
|
668 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | - ), |
|
670 | - 'EE_Registration_Processor' => array( |
|
671 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | - ), |
|
673 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | - null, |
|
675 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | - ), |
|
678 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
679 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
681 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
682 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
683 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
684 | - ), |
|
685 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
686 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
687 | - ), |
|
688 | - ); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * Registers how core classes are loaded. |
|
695 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
696 | - * 'EE_Request_Handler' => 'load_core' |
|
697 | - * 'EE_Messages_Queue' => 'load_lib' |
|
698 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
699 | - * or, if greater control is required, by providing a custom closure. For example: |
|
700 | - * 'Some_Class' => function () { |
|
701 | - * return new Some_Class(); |
|
702 | - * }, |
|
703 | - * This is required for instantiating dependencies |
|
704 | - * where an interface has been type hinted in a class constructor. For example: |
|
705 | - * 'Required_Interface' => function () { |
|
706 | - * return new A_Class_That_Implements_Required_Interface(); |
|
707 | - * }, |
|
708 | - * |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - * @throws InvalidDataTypeException |
|
711 | - * @throws InvalidArgumentException |
|
712 | - */ |
|
713 | - protected function _register_core_class_loaders() |
|
714 | - { |
|
715 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
716 | - //be used in a closure. |
|
717 | - $request = &$this->request; |
|
718 | - $response = &$this->response; |
|
719 | - $legacy_request = &$this->legacy_request; |
|
720 | - // $loader = &$this->loader; |
|
721 | - $this->_class_loaders = array( |
|
722 | - //load_core |
|
723 | - 'EE_Capabilities' => 'load_core', |
|
724 | - 'EE_Encryption' => 'load_core', |
|
725 | - 'EE_Front_Controller' => 'load_core', |
|
726 | - 'EE_Module_Request_Router' => 'load_core', |
|
727 | - 'EE_Registry' => 'load_core', |
|
728 | - 'EE_Request' => function () use (&$legacy_request) { |
|
729 | - return $legacy_request; |
|
730 | - }, |
|
731 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
732 | - return $request; |
|
733 | - }, |
|
734 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
735 | - return $response; |
|
736 | - }, |
|
737 | - 'EE_Request_Handler' => 'load_core', |
|
738 | - 'EE_Session' => 'load_core', |
|
739 | - 'EE_Cron_Tasks' => 'load_core', |
|
740 | - 'EE_System' => 'load_core', |
|
741 | - 'EE_Maintenance_Mode' => 'load_core', |
|
742 | - 'EE_Register_CPTs' => 'load_core', |
|
743 | - 'EE_Admin' => 'load_core', |
|
744 | - //load_lib |
|
745 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
746 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
747 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
748 | - 'EE_Messenger_Collection' => 'load_lib', |
|
749 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
750 | - 'EE_Messages_Processor' => 'load_lib', |
|
751 | - 'EE_Message_Repository' => 'load_lib', |
|
752 | - 'EE_Messages_Queue' => 'load_lib', |
|
753 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
754 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
755 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
756 | - 'EE_Messages_Generator' => function () { |
|
757 | - return EE_Registry::instance()->load_lib( |
|
758 | - 'Messages_Generator', |
|
759 | - array(), |
|
760 | - false, |
|
761 | - false |
|
762 | - ); |
|
763 | - }, |
|
764 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
765 | - return EE_Registry::instance()->load_lib( |
|
766 | - 'Messages_Template_Defaults', |
|
767 | - $arguments, |
|
768 | - false, |
|
769 | - false |
|
770 | - ); |
|
771 | - }, |
|
772 | - //load_model |
|
773 | - // 'EEM_Attendee' => 'load_model', |
|
774 | - // 'EEM_Message_Template_Group' => 'load_model', |
|
775 | - // 'EEM_Message_Template' => 'load_model', |
|
776 | - //load_helper |
|
777 | - 'EEH_Parse_Shortcodes' => function () { |
|
778 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
779 | - return new EEH_Parse_Shortcodes(); |
|
780 | - } |
|
781 | - return null; |
|
782 | - }, |
|
783 | - 'EE_Template_Config' => function () { |
|
784 | - return EE_Config::instance()->template_settings; |
|
785 | - }, |
|
786 | - 'EE_Currency_Config' => function () { |
|
787 | - return EE_Config::instance()->currency; |
|
788 | - }, |
|
789 | - 'EE_Registration_Config' => function () { |
|
790 | - return EE_Config::instance()->registration; |
|
791 | - }, |
|
792 | - 'EE_Core_Config' => function () { |
|
793 | - return EE_Config::instance()->core; |
|
794 | - }, |
|
795 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
796 | - return LoaderFactory::getLoader(); |
|
797 | - }, |
|
798 | - ); |
|
799 | - } |
|
800 | - |
|
801 | - |
|
802 | - |
|
803 | - /** |
|
804 | - * can be used for supplying alternate names for classes, |
|
805 | - * or for connecting interface names to instantiable classes |
|
806 | - */ |
|
807 | - protected function _register_core_aliases() |
|
808 | - { |
|
809 | - $this->_aliases = array( |
|
810 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
811 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
812 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
813 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
814 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
815 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
816 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
817 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
818 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
819 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
820 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
821 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
822 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
823 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
824 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
825 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
826 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
827 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
828 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
829 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
830 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
831 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
832 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
833 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
834 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
835 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
836 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
837 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
838 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
839 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
840 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
841 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
842 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
843 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
844 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
845 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
846 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
847 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
848 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
849 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
850 | - ); |
|
851 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
852 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
853 | - } |
|
854 | - } |
|
855 | - |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
860 | - * request Primarily used by unit tests. |
|
861 | - * |
|
862 | - * @throws InvalidDataTypeException |
|
863 | - * @throws InvalidInterfaceException |
|
864 | - * @throws InvalidArgumentException |
|
865 | - */ |
|
866 | - public function reset() |
|
867 | - { |
|
868 | - $this->_register_core_class_loaders(); |
|
869 | - $this->_register_core_dependencies(); |
|
870 | - } |
|
28 | + /** |
|
29 | + * This means that the requested class dependency is not present in the dependency map |
|
30 | + */ |
|
31 | + const not_registered = 0; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | + */ |
|
36 | + const load_new_object = 1; |
|
37 | + |
|
38 | + /** |
|
39 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | + */ |
|
42 | + const load_from_cache = 2; |
|
43 | + |
|
44 | + /** |
|
45 | + * When registering a dependency, |
|
46 | + * this indicates to keep any existing dependencies that already exist, |
|
47 | + * and simply discard any new dependencies declared in the incoming data |
|
48 | + */ |
|
49 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | + |
|
51 | + /** |
|
52 | + * When registering a dependency, |
|
53 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | + */ |
|
55 | + const OVERWRITE_DEPENDENCIES = 1; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @type EE_Dependency_Map $_instance |
|
61 | + */ |
|
62 | + protected static $_instance; |
|
63 | + |
|
64 | + /** |
|
65 | + * @type RequestInterface $request |
|
66 | + */ |
|
67 | + protected $request; |
|
68 | + |
|
69 | + /** |
|
70 | + * @type LegacyRequestInterface $legacy_request |
|
71 | + */ |
|
72 | + protected $legacy_request; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type ResponseInterface $response |
|
76 | + */ |
|
77 | + protected $response; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type LoaderInterface $loader |
|
81 | + */ |
|
82 | + protected $loader; |
|
83 | + |
|
84 | + /** |
|
85 | + * @type array $_dependency_map |
|
86 | + */ |
|
87 | + protected $_dependency_map = array(); |
|
88 | + |
|
89 | + /** |
|
90 | + * @type array $_class_loaders |
|
91 | + */ |
|
92 | + protected $_class_loaders = array(); |
|
93 | + |
|
94 | + /** |
|
95 | + * @type array $_aliases |
|
96 | + */ |
|
97 | + protected $_aliases = array(); |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * EE_Dependency_Map constructor. |
|
103 | + */ |
|
104 | + protected function __construct() |
|
105 | + { |
|
106 | + // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | + do_action('EE_Dependency_Map____construct'); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @throws InvalidDataTypeException |
|
114 | + * @throws InvalidInterfaceException |
|
115 | + * @throws InvalidArgumentException |
|
116 | + */ |
|
117 | + public function initialize() |
|
118 | + { |
|
119 | + $this->_register_core_dependencies(); |
|
120 | + $this->_register_core_class_loaders(); |
|
121 | + $this->_register_core_aliases(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @singleton method used to instantiate class object |
|
128 | + * @return EE_Dependency_Map |
|
129 | + */ |
|
130 | + public static function instance() { |
|
131 | + // check if class object is instantiated, and instantiated properly |
|
132 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | + self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | + } |
|
135 | + return self::$_instance; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param RequestInterface $request |
|
141 | + */ |
|
142 | + public function setRequest(RequestInterface $request) |
|
143 | + { |
|
144 | + $this->request = $request; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param LegacyRequestInterface $legacy_request |
|
150 | + */ |
|
151 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | + { |
|
153 | + $this->legacy_request = $legacy_request; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param ResponseInterface $response |
|
159 | + */ |
|
160 | + public function setResponse(ResponseInterface $response) |
|
161 | + { |
|
162 | + $this->response = $response; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @param LoaderInterface $loader |
|
169 | + */ |
|
170 | + public function setLoader(LoaderInterface $loader) |
|
171 | + { |
|
172 | + $this->loader = $loader; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $class |
|
179 | + * @param array $dependencies |
|
180 | + * @param int $overwrite |
|
181 | + * @return bool |
|
182 | + */ |
|
183 | + public static function register_dependencies( |
|
184 | + $class, |
|
185 | + array $dependencies, |
|
186 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | + ) { |
|
188 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | + * to the class specified by the first parameter. |
|
196 | + * IMPORTANT !!! |
|
197 | + * The order of elements in the incoming $dependencies array MUST match |
|
198 | + * the order of the constructor parameters for the class in question. |
|
199 | + * This is especially important when overriding any existing dependencies that are registered. |
|
200 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | + * |
|
202 | + * @param string $class |
|
203 | + * @param array $dependencies |
|
204 | + * @param int $overwrite |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function registerDependencies( |
|
208 | + $class, |
|
209 | + array $dependencies, |
|
210 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | + ) { |
|
212 | + $class = trim($class, '\\'); |
|
213 | + $registered = false; |
|
214 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | + } |
|
217 | + // we need to make sure that any aliases used when registering a dependency |
|
218 | + // get resolved to the correct class name |
|
219 | + foreach ($dependencies as $dependency => $load_source) { |
|
220 | + $alias = self::$_instance->get_alias($dependency); |
|
221 | + if ( |
|
222 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | + ) { |
|
225 | + unset($dependencies[$dependency]); |
|
226 | + $dependencies[$alias] = $load_source; |
|
227 | + $registered = true; |
|
228 | + } |
|
229 | + } |
|
230 | + // now add our two lists of dependencies together. |
|
231 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | + // so $dependencies is NOT overwritten because it is listed first |
|
233 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | + // Union is way faster than array_merge() but should be used with caution... |
|
235 | + // especially with numerically indexed arrays |
|
236 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | + // now we need to ensure that the resulting dependencies |
|
238 | + // array only has the entries that are required for the class |
|
239 | + // so first count how many dependencies were originally registered for the class |
|
240 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | + // if that count is non-zero (meaning dependencies were already registered) |
|
242 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | + // then truncate the final array to match that count |
|
244 | + ? array_slice($dependencies, 0, $dependency_count) |
|
245 | + // otherwise just take the incoming array because nothing previously existed |
|
246 | + : $dependencies; |
|
247 | + return $registered; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param string $class_name |
|
254 | + * @param string $loader |
|
255 | + * @return bool |
|
256 | + * @throws DomainException |
|
257 | + */ |
|
258 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | + { |
|
260 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | + throw new DomainException( |
|
262 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | + ); |
|
264 | + } |
|
265 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | + if ( |
|
267 | + ! is_callable($loader) |
|
268 | + && ( |
|
269 | + strpos($loader, 'load_') !== 0 |
|
270 | + || ! method_exists('EE_Registry', $loader) |
|
271 | + ) |
|
272 | + ) { |
|
273 | + throw new DomainException( |
|
274 | + sprintf( |
|
275 | + esc_html__( |
|
276 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | + 'event_espresso' |
|
278 | + ), |
|
279 | + $loader |
|
280 | + ) |
|
281 | + ); |
|
282 | + } |
|
283 | + $class_name = self::$_instance->get_alias($class_name); |
|
284 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | + return true; |
|
287 | + } |
|
288 | + return false; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public function dependency_map() |
|
297 | + { |
|
298 | + return $this->_dependency_map; |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | + * |
|
306 | + * @param string $class_name |
|
307 | + * @return boolean |
|
308 | + */ |
|
309 | + public function has($class_name = '') |
|
310 | + { |
|
311 | + // all legacy models have the same dependencies |
|
312 | + if (strpos($class_name, 'EEM_') === 0) { |
|
313 | + $class_name = 'LEGACY_MODELS'; |
|
314 | + } |
|
315 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | + * |
|
323 | + * @param string $class_name |
|
324 | + * @param string $dependency |
|
325 | + * @return bool |
|
326 | + */ |
|
327 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | + { |
|
329 | + // all legacy models have the same dependencies |
|
330 | + if (strpos($class_name, 'EEM_') === 0) { |
|
331 | + $class_name = 'LEGACY_MODELS'; |
|
332 | + } |
|
333 | + $dependency = $this->get_alias($dependency); |
|
334 | + return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | + ? true |
|
336 | + : false; |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | + * |
|
344 | + * @param string $class_name |
|
345 | + * @param string $dependency |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | + { |
|
350 | + // all legacy models have the same dependencies |
|
351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
352 | + $class_name = 'LEGACY_MODELS'; |
|
353 | + } |
|
354 | + $dependency = $this->get_alias($dependency); |
|
355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | + ? $this->_dependency_map[$class_name][$dependency] |
|
357 | + : EE_Dependency_Map::not_registered; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param string $class_name |
|
364 | + * @return string | Closure |
|
365 | + */ |
|
366 | + public function class_loader($class_name) |
|
367 | + { |
|
368 | + // all legacy models use load_model() |
|
369 | + if(strpos($class_name, 'EEM_') === 0){ |
|
370 | + return 'load_model'; |
|
371 | + } |
|
372 | + $class_name = $this->get_alias($class_name); |
|
373 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @return array |
|
380 | + */ |
|
381 | + public function class_loaders() |
|
382 | + { |
|
383 | + return $this->_class_loaders; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * adds an alias for a classname |
|
390 | + * |
|
391 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | + */ |
|
395 | + public function add_alias($class_name, $alias, $for_class = '') |
|
396 | + { |
|
397 | + if ($for_class !== '') { |
|
398 | + if (! isset($this->_aliases[$for_class])) { |
|
399 | + $this->_aliases[$for_class] = array(); |
|
400 | + } |
|
401 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | + } |
|
403 | + $this->_aliases[$class_name] = $alias; |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * returns TRUE if the provided class name has an alias |
|
410 | + * |
|
411 | + * @param string $class_name |
|
412 | + * @param string $for_class |
|
413 | + * @return bool |
|
414 | + */ |
|
415 | + public function has_alias($class_name = '', $for_class = '') |
|
416 | + { |
|
417 | + return isset($this->_aliases[$for_class][$class_name]) |
|
418 | + || ( |
|
419 | + isset($this->_aliases[$class_name]) |
|
420 | + && ! is_array($this->_aliases[$class_name]) |
|
421 | + ); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | + * for example: |
|
430 | + * if the following two entries were added to the _aliases array: |
|
431 | + * array( |
|
432 | + * 'interface_alias' => 'some\namespace\interface' |
|
433 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | + * ) |
|
435 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | + * to load an instance of 'some\namespace\classname' |
|
437 | + * |
|
438 | + * @param string $class_name |
|
439 | + * @param string $for_class |
|
440 | + * @return string |
|
441 | + */ |
|
442 | + public function get_alias($class_name = '', $for_class = '') |
|
443 | + { |
|
444 | + if (! $this->has_alias($class_name, $for_class)) { |
|
445 | + return $class_name; |
|
446 | + } |
|
447 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | + } |
|
450 | + return $this->get_alias($this->_aliases[$class_name]); |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | + * This is done by using the following class constants: |
|
459 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | + */ |
|
462 | + protected function _register_core_dependencies() |
|
463 | + { |
|
464 | + $this->_dependency_map = array( |
|
465 | + 'EE_Request_Handler' => array( |
|
466 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | + ), |
|
468 | + 'EE_System' => array( |
|
469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | + ), |
|
474 | + 'EE_Session' => array( |
|
475 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | + ), |
|
479 | + 'EE_Cart' => array( |
|
480 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | + ), |
|
482 | + 'EE_Front_Controller' => array( |
|
483 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messenger_Collection_Loader' => array( |
|
488 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | + ), |
|
490 | + 'EE_Message_Type_Collection_Loader' => array( |
|
491 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | + ), |
|
493 | + 'EE_Message_Resource_Manager' => array( |
|
494 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | + ), |
|
498 | + 'EE_Message_Factory' => array( |
|
499 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | + ), |
|
501 | + 'EE_messages' => array( |
|
502 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | + ), |
|
504 | + 'EE_Messages_Generator' => array( |
|
505 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EE_Messages_Processor' => array( |
|
511 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | + ), |
|
513 | + 'EE_Messages_Queue' => array( |
|
514 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | + ), |
|
516 | + 'EE_Messages_Template_Defaults' => array( |
|
517 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | + ), |
|
520 | + 'EE_Message_To_Generate_From_Request' => array( |
|
521 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | + ), |
|
531 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | + ), |
|
534 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | + ), |
|
538 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | + ), |
|
541 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | + ), |
|
544 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | + ), |
|
547 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | + ), |
|
550 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | + ), |
|
553 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | + ), |
|
556 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | + ), |
|
559 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | + ), |
|
562 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | + ), |
|
565 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | + ), |
|
568 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | + ), |
|
574 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | + ), |
|
577 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + ), |
|
580 | + 'EE_Data_Migration_Class_Base' => array( |
|
581 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | + ), |
|
584 | + 'EE_DMS_Core_4_1_0' => array( |
|
585 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | + ), |
|
588 | + 'EE_DMS_Core_4_2_0' => array( |
|
589 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | + ), |
|
592 | + 'EE_DMS_Core_4_3_0' => array( |
|
593 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | + ), |
|
596 | + 'EE_DMS_Core_4_4_0' => array( |
|
597 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | + ), |
|
600 | + 'EE_DMS_Core_4_5_0' => array( |
|
601 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | + ), |
|
604 | + 'EE_DMS_Core_4_6_0' => array( |
|
605 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | + ), |
|
608 | + 'EE_DMS_Core_4_7_0' => array( |
|
609 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | + ), |
|
612 | + 'EE_DMS_Core_4_8_0' => array( |
|
613 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | + ), |
|
616 | + 'EE_DMS_Core_4_9_0' => array( |
|
617 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ), |
|
620 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | + ), |
|
625 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ), |
|
628 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | + ), |
|
631 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | + ), |
|
634 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | + ), |
|
637 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | + ), |
|
640 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | + ), |
|
643 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | + ), |
|
649 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | + ), |
|
652 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | + null, |
|
658 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | + ), |
|
660 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | + ), |
|
663 | + 'LEGACY_MODELS' => array( |
|
664 | + null, |
|
665 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | + ), |
|
667 | + 'EE_Module_Request_Router' => array( |
|
668 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | + ), |
|
670 | + 'EE_Registration_Processor' => array( |
|
671 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | + ), |
|
673 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | + null, |
|
675 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | + ), |
|
678 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
679 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
681 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
682 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
683 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
684 | + ), |
|
685 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
686 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
687 | + ), |
|
688 | + ); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * Registers how core classes are loaded. |
|
695 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
696 | + * 'EE_Request_Handler' => 'load_core' |
|
697 | + * 'EE_Messages_Queue' => 'load_lib' |
|
698 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
699 | + * or, if greater control is required, by providing a custom closure. For example: |
|
700 | + * 'Some_Class' => function () { |
|
701 | + * return new Some_Class(); |
|
702 | + * }, |
|
703 | + * This is required for instantiating dependencies |
|
704 | + * where an interface has been type hinted in a class constructor. For example: |
|
705 | + * 'Required_Interface' => function () { |
|
706 | + * return new A_Class_That_Implements_Required_Interface(); |
|
707 | + * }, |
|
708 | + * |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + * @throws InvalidDataTypeException |
|
711 | + * @throws InvalidArgumentException |
|
712 | + */ |
|
713 | + protected function _register_core_class_loaders() |
|
714 | + { |
|
715 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
716 | + //be used in a closure. |
|
717 | + $request = &$this->request; |
|
718 | + $response = &$this->response; |
|
719 | + $legacy_request = &$this->legacy_request; |
|
720 | + // $loader = &$this->loader; |
|
721 | + $this->_class_loaders = array( |
|
722 | + //load_core |
|
723 | + 'EE_Capabilities' => 'load_core', |
|
724 | + 'EE_Encryption' => 'load_core', |
|
725 | + 'EE_Front_Controller' => 'load_core', |
|
726 | + 'EE_Module_Request_Router' => 'load_core', |
|
727 | + 'EE_Registry' => 'load_core', |
|
728 | + 'EE_Request' => function () use (&$legacy_request) { |
|
729 | + return $legacy_request; |
|
730 | + }, |
|
731 | + 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
732 | + return $request; |
|
733 | + }, |
|
734 | + 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
735 | + return $response; |
|
736 | + }, |
|
737 | + 'EE_Request_Handler' => 'load_core', |
|
738 | + 'EE_Session' => 'load_core', |
|
739 | + 'EE_Cron_Tasks' => 'load_core', |
|
740 | + 'EE_System' => 'load_core', |
|
741 | + 'EE_Maintenance_Mode' => 'load_core', |
|
742 | + 'EE_Register_CPTs' => 'load_core', |
|
743 | + 'EE_Admin' => 'load_core', |
|
744 | + //load_lib |
|
745 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
746 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
747 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
748 | + 'EE_Messenger_Collection' => 'load_lib', |
|
749 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
750 | + 'EE_Messages_Processor' => 'load_lib', |
|
751 | + 'EE_Message_Repository' => 'load_lib', |
|
752 | + 'EE_Messages_Queue' => 'load_lib', |
|
753 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
754 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
755 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
756 | + 'EE_Messages_Generator' => function () { |
|
757 | + return EE_Registry::instance()->load_lib( |
|
758 | + 'Messages_Generator', |
|
759 | + array(), |
|
760 | + false, |
|
761 | + false |
|
762 | + ); |
|
763 | + }, |
|
764 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
765 | + return EE_Registry::instance()->load_lib( |
|
766 | + 'Messages_Template_Defaults', |
|
767 | + $arguments, |
|
768 | + false, |
|
769 | + false |
|
770 | + ); |
|
771 | + }, |
|
772 | + //load_model |
|
773 | + // 'EEM_Attendee' => 'load_model', |
|
774 | + // 'EEM_Message_Template_Group' => 'load_model', |
|
775 | + // 'EEM_Message_Template' => 'load_model', |
|
776 | + //load_helper |
|
777 | + 'EEH_Parse_Shortcodes' => function () { |
|
778 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
779 | + return new EEH_Parse_Shortcodes(); |
|
780 | + } |
|
781 | + return null; |
|
782 | + }, |
|
783 | + 'EE_Template_Config' => function () { |
|
784 | + return EE_Config::instance()->template_settings; |
|
785 | + }, |
|
786 | + 'EE_Currency_Config' => function () { |
|
787 | + return EE_Config::instance()->currency; |
|
788 | + }, |
|
789 | + 'EE_Registration_Config' => function () { |
|
790 | + return EE_Config::instance()->registration; |
|
791 | + }, |
|
792 | + 'EE_Core_Config' => function () { |
|
793 | + return EE_Config::instance()->core; |
|
794 | + }, |
|
795 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
796 | + return LoaderFactory::getLoader(); |
|
797 | + }, |
|
798 | + ); |
|
799 | + } |
|
800 | + |
|
801 | + |
|
802 | + |
|
803 | + /** |
|
804 | + * can be used for supplying alternate names for classes, |
|
805 | + * or for connecting interface names to instantiable classes |
|
806 | + */ |
|
807 | + protected function _register_core_aliases() |
|
808 | + { |
|
809 | + $this->_aliases = array( |
|
810 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
811 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
812 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
813 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
814 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
815 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
816 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
817 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
818 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
819 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
820 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
821 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
822 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
823 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
824 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
825 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
826 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
827 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
828 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
829 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
830 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
831 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
832 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
833 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
834 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
835 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
836 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
837 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
838 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
839 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
840 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
841 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
842 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
843 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
844 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
845 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
846 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
847 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
848 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
849 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
850 | + ); |
|
851 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
852 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
853 | + } |
|
854 | + } |
|
855 | + |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
860 | + * request Primarily used by unit tests. |
|
861 | + * |
|
862 | + * @throws InvalidDataTypeException |
|
863 | + * @throws InvalidInterfaceException |
|
864 | + * @throws InvalidArgumentException |
|
865 | + */ |
|
866 | + public function reset() |
|
867 | + { |
|
868 | + $this->_register_core_class_loaders(); |
|
869 | + $this->_register_core_dependencies(); |
|
870 | + } |
|
871 | 871 | |
872 | 872 | |
873 | 873 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\services\request\RequestInterface; |
8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
9 | 9 | |
10 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | 11 | exit('No direct script access allowed'); |
12 | 12 | } |
13 | 13 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public static function instance() { |
131 | 131 | // check if class object is instantiated, and instantiated properly |
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
132 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | 133 | self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
134 | 134 | } |
135 | 135 | return self::$_instance; |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | ) { |
212 | 212 | $class = trim($class, '\\'); |
213 | 213 | $registered = false; |
214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
214 | + if (empty(self::$_instance->_dependency_map[$class])) { |
|
215 | + self::$_instance->_dependency_map[$class] = array(); |
|
216 | 216 | } |
217 | 217 | // we need to make sure that any aliases used when registering a dependency |
218 | 218 | // get resolved to the correct class name |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $alias = self::$_instance->get_alias($dependency); |
221 | 221 | if ( |
222 | 222 | $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
223 | + || ! isset(self::$_instance->_dependency_map[$class][$alias]) |
|
224 | 224 | ) { |
225 | 225 | unset($dependencies[$dependency]); |
226 | 226 | $dependencies[$alias] = $load_source; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
234 | 234 | // Union is way faster than array_merge() but should be used with caution... |
235 | 235 | // especially with numerically indexed arrays |
236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
236 | + $dependencies += self::$_instance->_dependency_map[$class]; |
|
237 | 237 | // now we need to ensure that the resulting dependencies |
238 | 238 | // array only has the entries that are required for the class |
239 | 239 | // so first count how many dependencies were originally registered for the class |
240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
240 | + $dependency_count = count(self::$_instance->_dependency_map[$class]); |
|
241 | 241 | // if that count is non-zero (meaning dependencies were already registered) |
242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
242 | + self::$_instance->_dependency_map[$class] = $dependency_count |
|
243 | 243 | // then truncate the final array to match that count |
244 | 244 | ? array_slice($dependencies, 0, $dependency_count) |
245 | 245 | // otherwise just take the incoming array because nothing previously existed |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function register_class_loader($class_name, $loader = 'load_core') |
259 | 259 | { |
260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
260 | + if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | 261 | throw new DomainException( |
262 | 262 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
263 | 263 | ); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | ); |
282 | 282 | } |
283 | 283 | $class_name = self::$_instance->get_alias($class_name); |
284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
284 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | 285 | self::$_instance->_class_loaders[$class_name] = $loader; |
286 | 286 | return true; |
287 | 287 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | public function class_loader($class_name) |
367 | 367 | { |
368 | 368 | // all legacy models use load_model() |
369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
369 | + if (strpos($class_name, 'EEM_') === 0) { |
|
370 | 370 | return 'load_model'; |
371 | 371 | } |
372 | 372 | $class_name = $this->get_alias($class_name); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | public function add_alias($class_name, $alias, $for_class = '') |
396 | 396 | { |
397 | 397 | if ($for_class !== '') { |
398 | - if (! isset($this->_aliases[$for_class])) { |
|
398 | + if ( ! isset($this->_aliases[$for_class])) { |
|
399 | 399 | $this->_aliases[$for_class] = array(); |
400 | 400 | } |
401 | 401 | $this->_aliases[$for_class][$class_name] = $alias; |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function get_alias($class_name = '', $for_class = '') |
443 | 443 | { |
444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
444 | + if ( ! $this->has_alias($class_name, $for_class)) { |
|
445 | 445 | return $class_name; |
446 | 446 | } |
447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
447 | + if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) { |
|
448 | 448 | return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
449 | 449 | } |
450 | 450 | return $this->get_alias($this->_aliases[$class_name]); |
@@ -725,13 +725,13 @@ discard block |
||
725 | 725 | 'EE_Front_Controller' => 'load_core', |
726 | 726 | 'EE_Module_Request_Router' => 'load_core', |
727 | 727 | 'EE_Registry' => 'load_core', |
728 | - 'EE_Request' => function () use (&$legacy_request) { |
|
728 | + 'EE_Request' => function() use (&$legacy_request) { |
|
729 | 729 | return $legacy_request; |
730 | 730 | }, |
731 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
731 | + 'EventEspresso\core\services\request\Request' => function() use (&$request) { |
|
732 | 732 | return $request; |
733 | 733 | }, |
734 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
734 | + 'EventEspresso\core\services\request\Response' => function() use (&$response) { |
|
735 | 735 | return $response; |
736 | 736 | }, |
737 | 737 | 'EE_Request_Handler' => 'load_core', |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
754 | 754 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
755 | 755 | 'EE_Payment_Method_Manager' => 'load_lib', |
756 | - 'EE_Messages_Generator' => function () { |
|
756 | + 'EE_Messages_Generator' => function() { |
|
757 | 757 | return EE_Registry::instance()->load_lib( |
758 | 758 | 'Messages_Generator', |
759 | 759 | array(), |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | false |
762 | 762 | ); |
763 | 763 | }, |
764 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
764 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
765 | 765 | return EE_Registry::instance()->load_lib( |
766 | 766 | 'Messages_Template_Defaults', |
767 | 767 | $arguments, |
@@ -774,25 +774,25 @@ discard block |
||
774 | 774 | // 'EEM_Message_Template_Group' => 'load_model', |
775 | 775 | // 'EEM_Message_Template' => 'load_model', |
776 | 776 | //load_helper |
777 | - 'EEH_Parse_Shortcodes' => function () { |
|
777 | + 'EEH_Parse_Shortcodes' => function() { |
|
778 | 778 | if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
779 | 779 | return new EEH_Parse_Shortcodes(); |
780 | 780 | } |
781 | 781 | return null; |
782 | 782 | }, |
783 | - 'EE_Template_Config' => function () { |
|
783 | + 'EE_Template_Config' => function() { |
|
784 | 784 | return EE_Config::instance()->template_settings; |
785 | 785 | }, |
786 | - 'EE_Currency_Config' => function () { |
|
786 | + 'EE_Currency_Config' => function() { |
|
787 | 787 | return EE_Config::instance()->currency; |
788 | 788 | }, |
789 | - 'EE_Registration_Config' => function () { |
|
789 | + 'EE_Registration_Config' => function() { |
|
790 | 790 | return EE_Config::instance()->registration; |
791 | 791 | }, |
792 | - 'EE_Core_Config' => function () { |
|
792 | + 'EE_Core_Config' => function() { |
|
793 | 793 | return EE_Config::instance()->core; |
794 | 794 | }, |
795 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
795 | + 'EventEspresso\core\services\loaders\Loader' => function() { |
|
796 | 796 | return LoaderFactory::getLoader(); |
797 | 797 | }, |
798 | 798 | ); |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
849 | 849 | 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
850 | 850 | ); |
851 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
851 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
852 | 852 | $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
853 | 853 | } |
854 | 854 | } |