@@ -22,1083 +22,1083 @@ |
||
22 | 22 | class EE_Dependency_Map |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * This means that the requested class dependency is not present in the dependency map |
|
27 | - */ |
|
28 | - const not_registered = 0; |
|
29 | - |
|
30 | - /** |
|
31 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | - */ |
|
33 | - const load_new_object = 1; |
|
34 | - |
|
35 | - /** |
|
36 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | - */ |
|
39 | - const load_from_cache = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * When registering a dependency, |
|
43 | - * this indicates to keep any existing dependencies that already exist, |
|
44 | - * and simply discard any new dependencies declared in the incoming data |
|
45 | - */ |
|
46 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | - |
|
48 | - /** |
|
49 | - * When registering a dependency, |
|
50 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | - */ |
|
52 | - const OVERWRITE_DEPENDENCIES = 1; |
|
53 | - |
|
54 | - /** |
|
55 | - * @type EE_Dependency_Map $_instance |
|
56 | - */ |
|
57 | - protected static $_instance; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var ClassInterfaceCache $class_cache |
|
61 | - */ |
|
62 | - private $class_cache; |
|
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 = []; |
|
88 | - |
|
89 | - /** |
|
90 | - * @type array $_class_loaders |
|
91 | - */ |
|
92 | - protected $_class_loaders = []; |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * EE_Dependency_Map constructor. |
|
97 | - * |
|
98 | - * @param ClassInterfaceCache $class_cache |
|
99 | - */ |
|
100 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
101 | - { |
|
102 | - $this->class_cache = $class_cache; |
|
103 | - do_action('EE_Dependency_Map____construct', $this); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return void |
|
109 | - * @throws InvalidAliasException |
|
110 | - */ |
|
111 | - public function initialize() |
|
112 | - { |
|
113 | - $this->_register_core_dependencies(); |
|
114 | - $this->_register_core_class_loaders(); |
|
115 | - $this->_register_core_aliases(); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @singleton method used to instantiate class object |
|
121 | - * @param ClassInterfaceCache|null $class_cache |
|
122 | - * @return EE_Dependency_Map |
|
123 | - */ |
|
124 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
125 | - { |
|
126 | - // check if class object is instantiated, and instantiated properly |
|
127 | - if ( |
|
128 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
129 | - && $class_cache instanceof ClassInterfaceCache |
|
130 | - ) { |
|
131 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
132 | - } |
|
133 | - return EE_Dependency_Map::$_instance; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param RequestInterface $request |
|
139 | - */ |
|
140 | - public function setRequest(RequestInterface $request) |
|
141 | - { |
|
142 | - $this->request = $request; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @param LegacyRequestInterface $legacy_request |
|
148 | - */ |
|
149 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
150 | - { |
|
151 | - $this->legacy_request = $legacy_request; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @param ResponseInterface $response |
|
157 | - */ |
|
158 | - public function setResponse(ResponseInterface $response) |
|
159 | - { |
|
160 | - $this->response = $response; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param LoaderInterface $loader |
|
166 | - */ |
|
167 | - public function setLoader(LoaderInterface $loader) |
|
168 | - { |
|
169 | - $this->loader = $loader; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @param string $class |
|
175 | - * @param array $dependencies |
|
176 | - * @param int $overwrite |
|
177 | - * @return bool |
|
178 | - */ |
|
179 | - public static function register_dependencies( |
|
180 | - $class, |
|
181 | - array $dependencies, |
|
182 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
183 | - ) { |
|
184 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
190 | - * to the class specified by the first parameter. |
|
191 | - * IMPORTANT !!! |
|
192 | - * The order of elements in the incoming $dependencies array MUST match |
|
193 | - * the order of the constructor parameters for the class in question. |
|
194 | - * This is especially important when overriding any existing dependencies that are registered. |
|
195 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
196 | - * |
|
197 | - * @param string $class |
|
198 | - * @param array $dependencies |
|
199 | - * @param int $overwrite |
|
200 | - * @return bool |
|
201 | - */ |
|
202 | - public function registerDependencies( |
|
203 | - $class, |
|
204 | - array $dependencies, |
|
205 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
206 | - ) { |
|
207 | - $class = trim($class, '\\'); |
|
208 | - $registered = false; |
|
209 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
210 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
211 | - } |
|
212 | - // we need to make sure that any aliases used when registering a dependency |
|
213 | - // get resolved to the correct class name |
|
214 | - foreach ($dependencies as $dependency => $load_source) { |
|
215 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
216 | - if ( |
|
217 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
218 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
219 | - ) { |
|
220 | - unset($dependencies[ $dependency ]); |
|
221 | - $dependencies[ $alias ] = $load_source; |
|
222 | - $registered = true; |
|
223 | - } |
|
224 | - } |
|
225 | - // now add our two lists of dependencies together. |
|
226 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
227 | - // so $dependencies is NOT overwritten because it is listed first |
|
228 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
229 | - // Union is way faster than array_merge() but should be used with caution... |
|
230 | - // especially with numerically indexed arrays |
|
231 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
232 | - // now we need to ensure that the resulting dependencies |
|
233 | - // array only has the entries that are required for the class |
|
234 | - // so first count how many dependencies were originally registered for the class |
|
235 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
236 | - // if that count is non-zero (meaning dependencies were already registered) |
|
237 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
238 | - // then truncate the final array to match that count |
|
239 | - ? array_slice($dependencies, 0, $dependency_count) |
|
240 | - // otherwise just take the incoming array because nothing previously existed |
|
241 | - : $dependencies; |
|
242 | - return $registered; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param string $class_name |
|
248 | - * @param string $loader |
|
249 | - * @return bool |
|
250 | - * @throws DomainException |
|
251 | - */ |
|
252 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
253 | - { |
|
254 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * @param string $class_name |
|
260 | - * @param string $loader |
|
261 | - * @return bool |
|
262 | - * @throws DomainException |
|
263 | - */ |
|
264 | - public function registerClassLoader($class_name, $loader = 'load_core') |
|
265 | - { |
|
266 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
267 | - throw new DomainException( |
|
268 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
269 | - ); |
|
270 | - } |
|
271 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
272 | - if ( |
|
273 | - ! is_callable($loader) |
|
274 | - && ( |
|
275 | - strpos($loader, 'load_') !== 0 |
|
276 | - || ! method_exists('EE_Registry', $loader) |
|
277 | - ) |
|
278 | - ) { |
|
279 | - throw new DomainException( |
|
280 | - sprintf( |
|
281 | - esc_html__( |
|
282 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
283 | - 'event_espresso' |
|
284 | - ), |
|
285 | - $loader |
|
286 | - ) |
|
287 | - ); |
|
288 | - } |
|
289 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
290 | - if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
291 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
292 | - return true; |
|
293 | - } |
|
294 | - return false; |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * @return array |
|
300 | - */ |
|
301 | - public function dependency_map() |
|
302 | - { |
|
303 | - return $this->_dependency_map; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
309 | - * |
|
310 | - * @param string $class_name |
|
311 | - * @return boolean |
|
312 | - */ |
|
313 | - public function has($class_name = '') |
|
314 | - { |
|
315 | - // all legacy models have the same dependencies |
|
316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
317 | - $class_name = 'LEGACY_MODELS'; |
|
318 | - } |
|
319 | - return isset($this->_dependency_map[ $class_name ]); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
325 | - * |
|
326 | - * @param string $class_name |
|
327 | - * @param string $dependency |
|
328 | - * @return bool |
|
329 | - */ |
|
330 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
331 | - { |
|
332 | - // all legacy models have the same dependencies |
|
333 | - if (strpos($class_name, 'EEM_') === 0) { |
|
334 | - $class_name = 'LEGACY_MODELS'; |
|
335 | - } |
|
336 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
337 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
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->getFqnForAlias($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 | - * @param string $class_name |
|
363 | - * @return string | Closure |
|
364 | - */ |
|
365 | - public function class_loader($class_name) |
|
366 | - { |
|
367 | - // all legacy models use load_model() |
|
368 | - if (strpos($class_name, 'EEM_') === 0) { |
|
369 | - return 'load_model'; |
|
370 | - } |
|
371 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
372 | - // perform strpos() first to avoid loading regex every time we load a class |
|
373 | - if ( |
|
374 | - strpos($class_name, 'EE_CPT_') === 0 |
|
375 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
376 | - ) { |
|
377 | - return 'load_core'; |
|
378 | - } |
|
379 | - $class_name = $this->getFqnForAlias($class_name); |
|
380 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * @return array |
|
386 | - */ |
|
387 | - public function class_loaders() |
|
388 | - { |
|
389 | - return $this->_class_loaders; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * adds an alias for a classname |
|
395 | - * |
|
396 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
397 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
398 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
399 | - * @throws InvalidAliasException |
|
400 | - */ |
|
401 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
402 | - { |
|
403 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
409 | - * WHY? |
|
410 | - * Because if a class is type hinting for a concretion, |
|
411 | - * then why would we need to find another class to supply it? |
|
412 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
413 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
414 | - * Don't go looking for some substitute. |
|
415 | - * Whereas if a class is type hinting for an interface... |
|
416 | - * then we need to find an actual class to use. |
|
417 | - * So the interface IS the alias for some other FQN, |
|
418 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
419 | - * represents some other class. |
|
420 | - * |
|
421 | - * @param string $fqn |
|
422 | - * @param string $for_class |
|
423 | - * @return bool |
|
424 | - */ |
|
425 | - public function isAlias($fqn = '', $for_class = '') |
|
426 | - { |
|
427 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
433 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
434 | - * for example: |
|
435 | - * if the following two entries were added to the _aliases array: |
|
436 | - * array( |
|
437 | - * 'interface_alias' => 'some\namespace\interface' |
|
438 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
439 | - * ) |
|
440 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
441 | - * to load an instance of 'some\namespace\classname' |
|
442 | - * |
|
443 | - * @param string $alias |
|
444 | - * @param string $for_class |
|
445 | - * @return string |
|
446 | - */ |
|
447 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
448 | - { |
|
449 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
455 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
456 | - * This is done by using the following class constants: |
|
457 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
458 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
459 | - */ |
|
460 | - protected function _register_core_dependencies() |
|
461 | - { |
|
462 | - $this->_dependency_map = [ |
|
463 | - 'EE_Request_Handler' => [ |
|
464 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
465 | - ], |
|
466 | - 'EE_System' => [ |
|
467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
471 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
472 | - ], |
|
473 | - 'EE_Admin' => [ |
|
474 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
475 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
476 | - ], |
|
477 | - 'EE_Cart' => [ |
|
478 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
479 | - ], |
|
480 | - 'EE_Messenger_Collection_Loader' => [ |
|
481 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | - ], |
|
483 | - 'EE_Message_Type_Collection_Loader' => [ |
|
484 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
485 | - ], |
|
486 | - 'EE_Message_Resource_Manager' => [ |
|
487 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
488 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
489 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
490 | - ], |
|
491 | - 'EE_Message_Factory' => [ |
|
492 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | - ], |
|
494 | - 'EE_messages' => [ |
|
495 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | - ], |
|
497 | - 'EE_Messages_Generator' => [ |
|
498 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
499 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
500 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
501 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
502 | - ], |
|
503 | - 'EE_Messages_Processor' => [ |
|
504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | - ], |
|
506 | - 'EE_Messages_Queue' => [ |
|
507 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
508 | - ], |
|
509 | - 'EE_Messages_Template_Defaults' => [ |
|
510 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
511 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
512 | - ], |
|
513 | - 'EE_Message_To_Generate_From_Request' => [ |
|
514 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
515 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
516 | - ], |
|
517 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
518 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
519 | - ], |
|
520 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
521 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
523 | - ], |
|
524 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
525 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
526 | - ], |
|
527 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
528 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
529 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
530 | - ], |
|
531 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | - ], |
|
534 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
535 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
536 | - ], |
|
537 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
538 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | - ], |
|
540 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
541 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
542 | - ], |
|
543 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
544 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | - ], |
|
546 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
547 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | - ], |
|
549 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
550 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
551 | - ], |
|
552 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
553 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
554 | - ], |
|
555 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
556 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
557 | - ], |
|
558 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
559 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | - ], |
|
561 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
562 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | - ], |
|
564 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
565 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
566 | - ], |
|
567 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
568 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
569 | - ], |
|
570 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | - ], |
|
573 | - 'EE_Data_Migration_Class_Base' => [ |
|
574 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | - ], |
|
577 | - 'EE_DMS_Core_4_1_0' => [ |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | - ], |
|
581 | - 'EE_DMS_Core_4_2_0' => [ |
|
582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | - ], |
|
585 | - 'EE_DMS_Core_4_3_0' => [ |
|
586 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | - ], |
|
589 | - 'EE_DMS_Core_4_4_0' => [ |
|
590 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | - ], |
|
593 | - 'EE_DMS_Core_4_5_0' => [ |
|
594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | - ], |
|
597 | - 'EE_DMS_Core_4_6_0' => [ |
|
598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | - ], |
|
601 | - 'EE_DMS_Core_4_7_0' => [ |
|
602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | - ], |
|
605 | - 'EE_DMS_Core_4_8_0' => [ |
|
606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | - ], |
|
609 | - 'EE_DMS_Core_4_9_0' => [ |
|
610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | - ], |
|
613 | - 'EE_DMS_Core_4_10_0' => [ |
|
614 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
617 | - ], |
|
618 | - 'EE_DMS_Core_4_11_0' => [ |
|
619 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
620 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
621 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
622 | - ], |
|
623 | - 'EE_DMS_Core_4_12_0' => [ |
|
624 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
625 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ], |
|
628 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
629 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
630 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
631 | - ], |
|
632 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
633 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | - ], |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
636 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | - ], |
|
638 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
639 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | - ], |
|
642 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
643 | - null, |
|
644 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | - ], |
|
646 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
647 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | - ], |
|
649 | - 'LEGACY_MODELS' => [ |
|
650 | - null, |
|
651 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | - ], |
|
653 | - 'EE_Module_Request_Router' => [ |
|
654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | - ], |
|
656 | - 'EE_Registration_Processor' => [ |
|
657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | - ], |
|
659 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
660 | - null, |
|
661 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | - ], |
|
664 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
665 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
666 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
667 | - ], |
|
668 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
669 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
670 | - ], |
|
671 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
672 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
673 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
674 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
675 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
677 | - ], |
|
678 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
679 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
680 | - ], |
|
681 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
682 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
683 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | - ], |
|
685 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
686 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
687 | - ], |
|
688 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
689 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
690 | - ], |
|
691 | - 'EE_CPT_Strategy' => [ |
|
692 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
693 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
694 | - ], |
|
695 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
696 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
697 | - ], |
|
698 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
699 | - null, |
|
700 | - null, |
|
701 | - null, |
|
702 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
703 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
704 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
705 | - ], |
|
706 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
707 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
708 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
709 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
710 | - ], |
|
711 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
712 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
713 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
714 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
715 | - ], |
|
716 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
717 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
718 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
719 | - ], |
|
720 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
721 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
722 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
723 | - ], |
|
724 | - 'EE_URL_Validation_Strategy' => [ |
|
725 | - null, |
|
726 | - null, |
|
727 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
728 | - ], |
|
729 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
730 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
731 | - ], |
|
732 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
733 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
734 | - ], |
|
735 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
736 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
737 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
738 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
739 | - null, |
|
740 | - ], |
|
741 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
742 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
743 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
744 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
745 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | - ], |
|
747 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
748 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
749 | - ], |
|
750 | - 'EventEspresso\core\services\routing\Router' => [ |
|
751 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
752 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
753 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
754 | - ], |
|
755 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
756 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
757 | - ], |
|
758 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
759 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
760 | - ], |
|
761 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
762 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
763 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | - ], |
|
765 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
766 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
767 | - ], |
|
768 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
769 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
771 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
772 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
773 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
774 | - ], |
|
775 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
776 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
777 | - ], |
|
778 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
779 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
780 | - ], |
|
781 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
782 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
783 | - ], |
|
784 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
785 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
786 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
787 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
788 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
789 | - ], |
|
790 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
791 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
792 | - ], |
|
793 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
794 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
795 | - ], |
|
796 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
797 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
800 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
801 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
802 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
803 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
804 | - ], |
|
805 | - 'EventEspresso\core\domain\services\registration\form\v1\RegForm' => [ |
|
806 | - null, |
|
807 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
808 | - ], |
|
809 | - 'EventEspresso\core\domain\services\registration\form\v1\RegistrationForm' => [ |
|
810 | - null, |
|
811 | - null, |
|
812 | - null, |
|
813 | - null, |
|
814 | - 'EEM_Event_Question_Group' => EE_Dependency_Map::load_from_cache, |
|
815 | - ], |
|
816 | - 'EventEspresso\core\domain\services\registration\form\v1\QuestionGroupRegForm' => [ |
|
817 | - null, |
|
818 | - null, |
|
819 | - null, |
|
820 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => EE_Dependency_Map::load_from_cache, |
|
821 | - ], |
|
822 | - 'EventEspresso\core\domain\services\registration\form\v1\CountryOptions' => [ |
|
823 | - null, |
|
824 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
825 | - 'EEM_Country' => EE_Dependency_Map::load_from_cache, |
|
826 | - ], |
|
827 | - 'EventEspresso\core\domain\services\registration\form\v1\StateOptions' => [ |
|
828 | - null, |
|
829 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
830 | - ], |
|
831 | - ]; |
|
832 | - } |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * Registers how core classes are loaded. |
|
837 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
838 | - * 'EE_Request_Handler' => 'load_core' |
|
839 | - * 'EE_Messages_Queue' => 'load_lib' |
|
840 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
841 | - * or, if greater control is required, by providing a custom closure. For example: |
|
842 | - * 'Some_Class' => function () { |
|
843 | - * return new Some_Class(); |
|
844 | - * }, |
|
845 | - * This is required for instantiating dependencies |
|
846 | - * where an interface has been type hinted in a class constructor. For example: |
|
847 | - * 'Required_Interface' => function () { |
|
848 | - * return new A_Class_That_Implements_Required_Interface(); |
|
849 | - * }, |
|
850 | - */ |
|
851 | - protected function _register_core_class_loaders() |
|
852 | - { |
|
853 | - $this->_class_loaders = [ |
|
854 | - // load_core |
|
855 | - 'EE_Dependency_Map' => function () { |
|
856 | - return $this; |
|
857 | - }, |
|
858 | - 'EE_Capabilities' => 'load_core', |
|
859 | - 'EE_Encryption' => 'load_core', |
|
860 | - 'EE_Front_Controller' => 'load_core', |
|
861 | - 'EE_Module_Request_Router' => 'load_core', |
|
862 | - 'EE_Registry' => 'load_core', |
|
863 | - 'EE_Request' => function () { |
|
864 | - return $this->legacy_request; |
|
865 | - }, |
|
866 | - 'EventEspresso\core\services\request\Request' => function () { |
|
867 | - return $this->request; |
|
868 | - }, |
|
869 | - 'EventEspresso\core\services\request\Response' => function () { |
|
870 | - return $this->response; |
|
871 | - }, |
|
872 | - 'EE_Base' => 'load_core', |
|
873 | - 'EE_Request_Handler' => 'load_core', |
|
874 | - 'EE_Session' => 'load_core', |
|
875 | - 'EE_Cron_Tasks' => 'load_core', |
|
876 | - 'EE_System' => 'load_core', |
|
877 | - 'EE_Maintenance_Mode' => 'load_core', |
|
878 | - 'EE_Register_CPTs' => 'load_core', |
|
879 | - 'EE_Admin' => 'load_core', |
|
880 | - 'EE_CPT_Strategy' => 'load_core', |
|
881 | - // load_class |
|
882 | - 'EE_Registration_Processor' => 'load_class', |
|
883 | - // load_lib |
|
884 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
885 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
886 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
887 | - 'EE_Messenger_Collection' => 'load_lib', |
|
888 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
889 | - 'EE_Messages_Processor' => 'load_lib', |
|
890 | - 'EE_Message_Repository' => 'load_lib', |
|
891 | - 'EE_Messages_Queue' => 'load_lib', |
|
892 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
893 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
894 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
895 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
896 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
897 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
898 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
899 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
900 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
901 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
902 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
903 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
904 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
905 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
906 | - 'EE_Messages_Generator' => static function () { |
|
907 | - return EE_Registry::instance()->load_lib( |
|
908 | - 'Messages_Generator', |
|
909 | - [], |
|
910 | - false, |
|
911 | - false |
|
912 | - ); |
|
913 | - }, |
|
914 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
915 | - return EE_Registry::instance()->load_lib( |
|
916 | - 'Messages_Template_Defaults', |
|
917 | - $arguments, |
|
918 | - false, |
|
919 | - false |
|
920 | - ); |
|
921 | - }, |
|
922 | - // load_helper |
|
923 | - 'EEH_Parse_Shortcodes' => static function () { |
|
924 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
925 | - return new EEH_Parse_Shortcodes(); |
|
926 | - } |
|
927 | - return null; |
|
928 | - }, |
|
929 | - 'EE_Template_Config' => static function () { |
|
930 | - return EE_Config::instance()->template_settings; |
|
931 | - }, |
|
932 | - 'EE_Currency_Config' => static function () { |
|
933 | - return EE_Config::instance()->currency; |
|
934 | - }, |
|
935 | - 'EE_Registration_Config' => static function () { |
|
936 | - return EE_Config::instance()->registration; |
|
937 | - }, |
|
938 | - 'EE_Core_Config' => static function () { |
|
939 | - return EE_Config::instance()->core; |
|
940 | - }, |
|
941 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
942 | - return LoaderFactory::getLoader(); |
|
943 | - }, |
|
944 | - 'EE_Network_Config' => static function () { |
|
945 | - return EE_Network_Config::instance(); |
|
946 | - }, |
|
947 | - 'EE_Config' => static function () { |
|
948 | - return EE_Config::instance(); |
|
949 | - }, |
|
950 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
951 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
952 | - }, |
|
953 | - 'EE_Admin_Config' => static function () { |
|
954 | - return EE_Config::instance()->admin; |
|
955 | - }, |
|
956 | - 'EE_Organization_Config' => static function () { |
|
957 | - return EE_Config::instance()->organization; |
|
958 | - }, |
|
959 | - 'EE_Network_Core_Config' => static function () { |
|
960 | - return EE_Network_Config::instance()->core; |
|
961 | - }, |
|
962 | - 'EE_Environment_Config' => static function () { |
|
963 | - return EE_Config::instance()->environment; |
|
964 | - }, |
|
965 | - 'EED_Core_Rest_Api' => static function () { |
|
966 | - return EED_Core_Rest_Api::instance(); |
|
967 | - }, |
|
968 | - 'WP_REST_Server' => static function () { |
|
969 | - return rest_get_server(); |
|
970 | - }, |
|
971 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
972 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
973 | - }, |
|
974 | - ]; |
|
975 | - } |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * can be used for supplying alternate names for classes, |
|
980 | - * or for connecting interface names to instantiable classes |
|
981 | - * |
|
982 | - * @throws InvalidAliasException |
|
983 | - */ |
|
984 | - protected function _register_core_aliases() |
|
985 | - { |
|
986 | - $aliases = [ |
|
987 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
988 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
989 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
990 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
991 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
992 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
993 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
994 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
995 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
996 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
997 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
998 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
999 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1000 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1001 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1002 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1003 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1004 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1005 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1006 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1007 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1008 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1009 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1010 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1011 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1012 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1013 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1014 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1015 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1016 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1017 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1018 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1019 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1020 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1021 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1022 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1023 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1024 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1025 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1026 | - ]; |
|
1027 | - foreach ($aliases as $alias => $fqn) { |
|
1028 | - if (is_array($fqn)) { |
|
1029 | - foreach ($fqn as $class => $for_class) { |
|
1030 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1031 | - } |
|
1032 | - continue; |
|
1033 | - } |
|
1034 | - $this->class_cache->addAlias($fqn, $alias); |
|
1035 | - } |
|
1036 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1037 | - $this->class_cache->addAlias( |
|
1038 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1039 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1040 | - ); |
|
1041 | - } |
|
1042 | - } |
|
1043 | - |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1047 | - * request Primarily used by unit tests. |
|
1048 | - */ |
|
1049 | - public function reset() |
|
1050 | - { |
|
1051 | - $this->_register_core_class_loaders(); |
|
1052 | - $this->_register_core_dependencies(); |
|
1053 | - } |
|
1054 | - |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1058 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1059 | - * WHY? |
|
1060 | - * Because if a class is type hinting for a concretion, |
|
1061 | - * then why would we need to find another class to supply it? |
|
1062 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1063 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1064 | - * Don't go looking for some substitute. |
|
1065 | - * Whereas if a class is type hinting for an interface... |
|
1066 | - * then we need to find an actual class to use. |
|
1067 | - * So the interface IS the alias for some other FQN, |
|
1068 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1069 | - * represents some other class. |
|
1070 | - * |
|
1071 | - * @param string $fqn |
|
1072 | - * @param string $for_class |
|
1073 | - * @return bool |
|
1074 | - * @deprecated 4.9.62.p |
|
1075 | - */ |
|
1076 | - public function has_alias($fqn = '', $for_class = '') |
|
1077 | - { |
|
1078 | - return $this->isAlias($fqn, $for_class); |
|
1079 | - } |
|
1080 | - |
|
1081 | - |
|
1082 | - /** |
|
1083 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1084 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1085 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1086 | - * for example: |
|
1087 | - * if the following two entries were added to the _aliases array: |
|
1088 | - * array( |
|
1089 | - * 'interface_alias' => 'some\namespace\interface' |
|
1090 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1091 | - * ) |
|
1092 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1093 | - * to load an instance of 'some\namespace\classname' |
|
1094 | - * |
|
1095 | - * @param string $alias |
|
1096 | - * @param string $for_class |
|
1097 | - * @return string |
|
1098 | - * @deprecated 4.9.62.p |
|
1099 | - */ |
|
1100 | - public function get_alias($alias = '', $for_class = '') |
|
1101 | - { |
|
1102 | - return $this->getFqnForAlias($alias, $for_class); |
|
1103 | - } |
|
25 | + /** |
|
26 | + * This means that the requested class dependency is not present in the dependency map |
|
27 | + */ |
|
28 | + const not_registered = 0; |
|
29 | + |
|
30 | + /** |
|
31 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | + */ |
|
33 | + const load_new_object = 1; |
|
34 | + |
|
35 | + /** |
|
36 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | + */ |
|
39 | + const load_from_cache = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * When registering a dependency, |
|
43 | + * this indicates to keep any existing dependencies that already exist, |
|
44 | + * and simply discard any new dependencies declared in the incoming data |
|
45 | + */ |
|
46 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | + |
|
48 | + /** |
|
49 | + * When registering a dependency, |
|
50 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | + */ |
|
52 | + const OVERWRITE_DEPENDENCIES = 1; |
|
53 | + |
|
54 | + /** |
|
55 | + * @type EE_Dependency_Map $_instance |
|
56 | + */ |
|
57 | + protected static $_instance; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var ClassInterfaceCache $class_cache |
|
61 | + */ |
|
62 | + private $class_cache; |
|
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 = []; |
|
88 | + |
|
89 | + /** |
|
90 | + * @type array $_class_loaders |
|
91 | + */ |
|
92 | + protected $_class_loaders = []; |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * EE_Dependency_Map constructor. |
|
97 | + * |
|
98 | + * @param ClassInterfaceCache $class_cache |
|
99 | + */ |
|
100 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
101 | + { |
|
102 | + $this->class_cache = $class_cache; |
|
103 | + do_action('EE_Dependency_Map____construct', $this); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return void |
|
109 | + * @throws InvalidAliasException |
|
110 | + */ |
|
111 | + public function initialize() |
|
112 | + { |
|
113 | + $this->_register_core_dependencies(); |
|
114 | + $this->_register_core_class_loaders(); |
|
115 | + $this->_register_core_aliases(); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @singleton method used to instantiate class object |
|
121 | + * @param ClassInterfaceCache|null $class_cache |
|
122 | + * @return EE_Dependency_Map |
|
123 | + */ |
|
124 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
125 | + { |
|
126 | + // check if class object is instantiated, and instantiated properly |
|
127 | + if ( |
|
128 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
129 | + && $class_cache instanceof ClassInterfaceCache |
|
130 | + ) { |
|
131 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
132 | + } |
|
133 | + return EE_Dependency_Map::$_instance; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param RequestInterface $request |
|
139 | + */ |
|
140 | + public function setRequest(RequestInterface $request) |
|
141 | + { |
|
142 | + $this->request = $request; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @param LegacyRequestInterface $legacy_request |
|
148 | + */ |
|
149 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
150 | + { |
|
151 | + $this->legacy_request = $legacy_request; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @param ResponseInterface $response |
|
157 | + */ |
|
158 | + public function setResponse(ResponseInterface $response) |
|
159 | + { |
|
160 | + $this->response = $response; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param LoaderInterface $loader |
|
166 | + */ |
|
167 | + public function setLoader(LoaderInterface $loader) |
|
168 | + { |
|
169 | + $this->loader = $loader; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @param string $class |
|
175 | + * @param array $dependencies |
|
176 | + * @param int $overwrite |
|
177 | + * @return bool |
|
178 | + */ |
|
179 | + public static function register_dependencies( |
|
180 | + $class, |
|
181 | + array $dependencies, |
|
182 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
183 | + ) { |
|
184 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
190 | + * to the class specified by the first parameter. |
|
191 | + * IMPORTANT !!! |
|
192 | + * The order of elements in the incoming $dependencies array MUST match |
|
193 | + * the order of the constructor parameters for the class in question. |
|
194 | + * This is especially important when overriding any existing dependencies that are registered. |
|
195 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
196 | + * |
|
197 | + * @param string $class |
|
198 | + * @param array $dependencies |
|
199 | + * @param int $overwrite |
|
200 | + * @return bool |
|
201 | + */ |
|
202 | + public function registerDependencies( |
|
203 | + $class, |
|
204 | + array $dependencies, |
|
205 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
206 | + ) { |
|
207 | + $class = trim($class, '\\'); |
|
208 | + $registered = false; |
|
209 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
210 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
211 | + } |
|
212 | + // we need to make sure that any aliases used when registering a dependency |
|
213 | + // get resolved to the correct class name |
|
214 | + foreach ($dependencies as $dependency => $load_source) { |
|
215 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
216 | + if ( |
|
217 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
218 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
219 | + ) { |
|
220 | + unset($dependencies[ $dependency ]); |
|
221 | + $dependencies[ $alias ] = $load_source; |
|
222 | + $registered = true; |
|
223 | + } |
|
224 | + } |
|
225 | + // now add our two lists of dependencies together. |
|
226 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
227 | + // so $dependencies is NOT overwritten because it is listed first |
|
228 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
229 | + // Union is way faster than array_merge() but should be used with caution... |
|
230 | + // especially with numerically indexed arrays |
|
231 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
232 | + // now we need to ensure that the resulting dependencies |
|
233 | + // array only has the entries that are required for the class |
|
234 | + // so first count how many dependencies were originally registered for the class |
|
235 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
236 | + // if that count is non-zero (meaning dependencies were already registered) |
|
237 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
238 | + // then truncate the final array to match that count |
|
239 | + ? array_slice($dependencies, 0, $dependency_count) |
|
240 | + // otherwise just take the incoming array because nothing previously existed |
|
241 | + : $dependencies; |
|
242 | + return $registered; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param string $class_name |
|
248 | + * @param string $loader |
|
249 | + * @return bool |
|
250 | + * @throws DomainException |
|
251 | + */ |
|
252 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
253 | + { |
|
254 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * @param string $class_name |
|
260 | + * @param string $loader |
|
261 | + * @return bool |
|
262 | + * @throws DomainException |
|
263 | + */ |
|
264 | + public function registerClassLoader($class_name, $loader = 'load_core') |
|
265 | + { |
|
266 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
267 | + throw new DomainException( |
|
268 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
269 | + ); |
|
270 | + } |
|
271 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
272 | + if ( |
|
273 | + ! is_callable($loader) |
|
274 | + && ( |
|
275 | + strpos($loader, 'load_') !== 0 |
|
276 | + || ! method_exists('EE_Registry', $loader) |
|
277 | + ) |
|
278 | + ) { |
|
279 | + throw new DomainException( |
|
280 | + sprintf( |
|
281 | + esc_html__( |
|
282 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
283 | + 'event_espresso' |
|
284 | + ), |
|
285 | + $loader |
|
286 | + ) |
|
287 | + ); |
|
288 | + } |
|
289 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
290 | + if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
291 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
292 | + return true; |
|
293 | + } |
|
294 | + return false; |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * @return array |
|
300 | + */ |
|
301 | + public function dependency_map() |
|
302 | + { |
|
303 | + return $this->_dependency_map; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
309 | + * |
|
310 | + * @param string $class_name |
|
311 | + * @return boolean |
|
312 | + */ |
|
313 | + public function has($class_name = '') |
|
314 | + { |
|
315 | + // all legacy models have the same dependencies |
|
316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
317 | + $class_name = 'LEGACY_MODELS'; |
|
318 | + } |
|
319 | + return isset($this->_dependency_map[ $class_name ]); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
325 | + * |
|
326 | + * @param string $class_name |
|
327 | + * @param string $dependency |
|
328 | + * @return bool |
|
329 | + */ |
|
330 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
331 | + { |
|
332 | + // all legacy models have the same dependencies |
|
333 | + if (strpos($class_name, 'EEM_') === 0) { |
|
334 | + $class_name = 'LEGACY_MODELS'; |
|
335 | + } |
|
336 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
337 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
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->getFqnForAlias($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 | + * @param string $class_name |
|
363 | + * @return string | Closure |
|
364 | + */ |
|
365 | + public function class_loader($class_name) |
|
366 | + { |
|
367 | + // all legacy models use load_model() |
|
368 | + if (strpos($class_name, 'EEM_') === 0) { |
|
369 | + return 'load_model'; |
|
370 | + } |
|
371 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
372 | + // perform strpos() first to avoid loading regex every time we load a class |
|
373 | + if ( |
|
374 | + strpos($class_name, 'EE_CPT_') === 0 |
|
375 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
376 | + ) { |
|
377 | + return 'load_core'; |
|
378 | + } |
|
379 | + $class_name = $this->getFqnForAlias($class_name); |
|
380 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * @return array |
|
386 | + */ |
|
387 | + public function class_loaders() |
|
388 | + { |
|
389 | + return $this->_class_loaders; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * adds an alias for a classname |
|
395 | + * |
|
396 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
397 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
398 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
399 | + * @throws InvalidAliasException |
|
400 | + */ |
|
401 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
402 | + { |
|
403 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
409 | + * WHY? |
|
410 | + * Because if a class is type hinting for a concretion, |
|
411 | + * then why would we need to find another class to supply it? |
|
412 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
413 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
414 | + * Don't go looking for some substitute. |
|
415 | + * Whereas if a class is type hinting for an interface... |
|
416 | + * then we need to find an actual class to use. |
|
417 | + * So the interface IS the alias for some other FQN, |
|
418 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
419 | + * represents some other class. |
|
420 | + * |
|
421 | + * @param string $fqn |
|
422 | + * @param string $for_class |
|
423 | + * @return bool |
|
424 | + */ |
|
425 | + public function isAlias($fqn = '', $for_class = '') |
|
426 | + { |
|
427 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
433 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
434 | + * for example: |
|
435 | + * if the following two entries were added to the _aliases array: |
|
436 | + * array( |
|
437 | + * 'interface_alias' => 'some\namespace\interface' |
|
438 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
439 | + * ) |
|
440 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
441 | + * to load an instance of 'some\namespace\classname' |
|
442 | + * |
|
443 | + * @param string $alias |
|
444 | + * @param string $for_class |
|
445 | + * @return string |
|
446 | + */ |
|
447 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
448 | + { |
|
449 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
455 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
456 | + * This is done by using the following class constants: |
|
457 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
458 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
459 | + */ |
|
460 | + protected function _register_core_dependencies() |
|
461 | + { |
|
462 | + $this->_dependency_map = [ |
|
463 | + 'EE_Request_Handler' => [ |
|
464 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
465 | + ], |
|
466 | + 'EE_System' => [ |
|
467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
471 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
472 | + ], |
|
473 | + 'EE_Admin' => [ |
|
474 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
475 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
476 | + ], |
|
477 | + 'EE_Cart' => [ |
|
478 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
479 | + ], |
|
480 | + 'EE_Messenger_Collection_Loader' => [ |
|
481 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | + ], |
|
483 | + 'EE_Message_Type_Collection_Loader' => [ |
|
484 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
485 | + ], |
|
486 | + 'EE_Message_Resource_Manager' => [ |
|
487 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
488 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
489 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
490 | + ], |
|
491 | + 'EE_Message_Factory' => [ |
|
492 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | + ], |
|
494 | + 'EE_messages' => [ |
|
495 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | + ], |
|
497 | + 'EE_Messages_Generator' => [ |
|
498 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
499 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
500 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
501 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
502 | + ], |
|
503 | + 'EE_Messages_Processor' => [ |
|
504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | + ], |
|
506 | + 'EE_Messages_Queue' => [ |
|
507 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
508 | + ], |
|
509 | + 'EE_Messages_Template_Defaults' => [ |
|
510 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
511 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
512 | + ], |
|
513 | + 'EE_Message_To_Generate_From_Request' => [ |
|
514 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
515 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
516 | + ], |
|
517 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
518 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
519 | + ], |
|
520 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
521 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
523 | + ], |
|
524 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
525 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
526 | + ], |
|
527 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
528 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
529 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
530 | + ], |
|
531 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | + ], |
|
534 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
535 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
536 | + ], |
|
537 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
538 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | + ], |
|
540 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
541 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
542 | + ], |
|
543 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
544 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | + ], |
|
546 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
547 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | + ], |
|
549 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
550 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
551 | + ], |
|
552 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
553 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
554 | + ], |
|
555 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
556 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
557 | + ], |
|
558 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
559 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | + ], |
|
561 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
562 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | + ], |
|
564 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
565 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
566 | + ], |
|
567 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
568 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
569 | + ], |
|
570 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | + ], |
|
573 | + 'EE_Data_Migration_Class_Base' => [ |
|
574 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | + ], |
|
577 | + 'EE_DMS_Core_4_1_0' => [ |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | + ], |
|
581 | + 'EE_DMS_Core_4_2_0' => [ |
|
582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | + ], |
|
585 | + 'EE_DMS_Core_4_3_0' => [ |
|
586 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | + ], |
|
589 | + 'EE_DMS_Core_4_4_0' => [ |
|
590 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | + ], |
|
593 | + 'EE_DMS_Core_4_5_0' => [ |
|
594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | + ], |
|
597 | + 'EE_DMS_Core_4_6_0' => [ |
|
598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | + ], |
|
601 | + 'EE_DMS_Core_4_7_0' => [ |
|
602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | + ], |
|
605 | + 'EE_DMS_Core_4_8_0' => [ |
|
606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | + ], |
|
609 | + 'EE_DMS_Core_4_9_0' => [ |
|
610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | + ], |
|
613 | + 'EE_DMS_Core_4_10_0' => [ |
|
614 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
617 | + ], |
|
618 | + 'EE_DMS_Core_4_11_0' => [ |
|
619 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
620 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
621 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
622 | + ], |
|
623 | + 'EE_DMS_Core_4_12_0' => [ |
|
624 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
625 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ], |
|
628 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
629 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
630 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
631 | + ], |
|
632 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
633 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | + ], |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
636 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | + ], |
|
638 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
639 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | + ], |
|
642 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
643 | + null, |
|
644 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | + ], |
|
646 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
647 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | + ], |
|
649 | + 'LEGACY_MODELS' => [ |
|
650 | + null, |
|
651 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | + ], |
|
653 | + 'EE_Module_Request_Router' => [ |
|
654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | + ], |
|
656 | + 'EE_Registration_Processor' => [ |
|
657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | + ], |
|
659 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
660 | + null, |
|
661 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | + ], |
|
664 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
665 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
666 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
667 | + ], |
|
668 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
669 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
670 | + ], |
|
671 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
672 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
673 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
674 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
675 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
677 | + ], |
|
678 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
679 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
680 | + ], |
|
681 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
682 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
683 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | + ], |
|
685 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
686 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
687 | + ], |
|
688 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
689 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
690 | + ], |
|
691 | + 'EE_CPT_Strategy' => [ |
|
692 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
693 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
694 | + ], |
|
695 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
696 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
697 | + ], |
|
698 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
699 | + null, |
|
700 | + null, |
|
701 | + null, |
|
702 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
703 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
704 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
705 | + ], |
|
706 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
707 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
708 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
709 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
710 | + ], |
|
711 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
712 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
713 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
714 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
715 | + ], |
|
716 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
717 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
718 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
719 | + ], |
|
720 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
721 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
722 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
723 | + ], |
|
724 | + 'EE_URL_Validation_Strategy' => [ |
|
725 | + null, |
|
726 | + null, |
|
727 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
728 | + ], |
|
729 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
730 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
731 | + ], |
|
732 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
733 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
734 | + ], |
|
735 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
736 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
737 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
738 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
739 | + null, |
|
740 | + ], |
|
741 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
742 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
743 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
744 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
745 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | + ], |
|
747 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
748 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
749 | + ], |
|
750 | + 'EventEspresso\core\services\routing\Router' => [ |
|
751 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
752 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
753 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
754 | + ], |
|
755 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
756 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
757 | + ], |
|
758 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
759 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
760 | + ], |
|
761 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
762 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
763 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | + ], |
|
765 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
766 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
767 | + ], |
|
768 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
769 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
771 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
772 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
773 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
774 | + ], |
|
775 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
776 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
777 | + ], |
|
778 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
779 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
780 | + ], |
|
781 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
782 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
783 | + ], |
|
784 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
785 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
786 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
787 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
788 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
789 | + ], |
|
790 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
791 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
792 | + ], |
|
793 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
794 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
795 | + ], |
|
796 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
797 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
800 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
801 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
802 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
803 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
804 | + ], |
|
805 | + 'EventEspresso\core\domain\services\registration\form\v1\RegForm' => [ |
|
806 | + null, |
|
807 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
808 | + ], |
|
809 | + 'EventEspresso\core\domain\services\registration\form\v1\RegistrationForm' => [ |
|
810 | + null, |
|
811 | + null, |
|
812 | + null, |
|
813 | + null, |
|
814 | + 'EEM_Event_Question_Group' => EE_Dependency_Map::load_from_cache, |
|
815 | + ], |
|
816 | + 'EventEspresso\core\domain\services\registration\form\v1\QuestionGroupRegForm' => [ |
|
817 | + null, |
|
818 | + null, |
|
819 | + null, |
|
820 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => EE_Dependency_Map::load_from_cache, |
|
821 | + ], |
|
822 | + 'EventEspresso\core\domain\services\registration\form\v1\CountryOptions' => [ |
|
823 | + null, |
|
824 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
825 | + 'EEM_Country' => EE_Dependency_Map::load_from_cache, |
|
826 | + ], |
|
827 | + 'EventEspresso\core\domain\services\registration\form\v1\StateOptions' => [ |
|
828 | + null, |
|
829 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
830 | + ], |
|
831 | + ]; |
|
832 | + } |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * Registers how core classes are loaded. |
|
837 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
838 | + * 'EE_Request_Handler' => 'load_core' |
|
839 | + * 'EE_Messages_Queue' => 'load_lib' |
|
840 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
841 | + * or, if greater control is required, by providing a custom closure. For example: |
|
842 | + * 'Some_Class' => function () { |
|
843 | + * return new Some_Class(); |
|
844 | + * }, |
|
845 | + * This is required for instantiating dependencies |
|
846 | + * where an interface has been type hinted in a class constructor. For example: |
|
847 | + * 'Required_Interface' => function () { |
|
848 | + * return new A_Class_That_Implements_Required_Interface(); |
|
849 | + * }, |
|
850 | + */ |
|
851 | + protected function _register_core_class_loaders() |
|
852 | + { |
|
853 | + $this->_class_loaders = [ |
|
854 | + // load_core |
|
855 | + 'EE_Dependency_Map' => function () { |
|
856 | + return $this; |
|
857 | + }, |
|
858 | + 'EE_Capabilities' => 'load_core', |
|
859 | + 'EE_Encryption' => 'load_core', |
|
860 | + 'EE_Front_Controller' => 'load_core', |
|
861 | + 'EE_Module_Request_Router' => 'load_core', |
|
862 | + 'EE_Registry' => 'load_core', |
|
863 | + 'EE_Request' => function () { |
|
864 | + return $this->legacy_request; |
|
865 | + }, |
|
866 | + 'EventEspresso\core\services\request\Request' => function () { |
|
867 | + return $this->request; |
|
868 | + }, |
|
869 | + 'EventEspresso\core\services\request\Response' => function () { |
|
870 | + return $this->response; |
|
871 | + }, |
|
872 | + 'EE_Base' => 'load_core', |
|
873 | + 'EE_Request_Handler' => 'load_core', |
|
874 | + 'EE_Session' => 'load_core', |
|
875 | + 'EE_Cron_Tasks' => 'load_core', |
|
876 | + 'EE_System' => 'load_core', |
|
877 | + 'EE_Maintenance_Mode' => 'load_core', |
|
878 | + 'EE_Register_CPTs' => 'load_core', |
|
879 | + 'EE_Admin' => 'load_core', |
|
880 | + 'EE_CPT_Strategy' => 'load_core', |
|
881 | + // load_class |
|
882 | + 'EE_Registration_Processor' => 'load_class', |
|
883 | + // load_lib |
|
884 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
885 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
886 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
887 | + 'EE_Messenger_Collection' => 'load_lib', |
|
888 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
889 | + 'EE_Messages_Processor' => 'load_lib', |
|
890 | + 'EE_Message_Repository' => 'load_lib', |
|
891 | + 'EE_Messages_Queue' => 'load_lib', |
|
892 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
893 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
894 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
895 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
896 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
897 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
898 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
899 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
900 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
901 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
902 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
903 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
904 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
905 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
906 | + 'EE_Messages_Generator' => static function () { |
|
907 | + return EE_Registry::instance()->load_lib( |
|
908 | + 'Messages_Generator', |
|
909 | + [], |
|
910 | + false, |
|
911 | + false |
|
912 | + ); |
|
913 | + }, |
|
914 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
915 | + return EE_Registry::instance()->load_lib( |
|
916 | + 'Messages_Template_Defaults', |
|
917 | + $arguments, |
|
918 | + false, |
|
919 | + false |
|
920 | + ); |
|
921 | + }, |
|
922 | + // load_helper |
|
923 | + 'EEH_Parse_Shortcodes' => static function () { |
|
924 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
925 | + return new EEH_Parse_Shortcodes(); |
|
926 | + } |
|
927 | + return null; |
|
928 | + }, |
|
929 | + 'EE_Template_Config' => static function () { |
|
930 | + return EE_Config::instance()->template_settings; |
|
931 | + }, |
|
932 | + 'EE_Currency_Config' => static function () { |
|
933 | + return EE_Config::instance()->currency; |
|
934 | + }, |
|
935 | + 'EE_Registration_Config' => static function () { |
|
936 | + return EE_Config::instance()->registration; |
|
937 | + }, |
|
938 | + 'EE_Core_Config' => static function () { |
|
939 | + return EE_Config::instance()->core; |
|
940 | + }, |
|
941 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
942 | + return LoaderFactory::getLoader(); |
|
943 | + }, |
|
944 | + 'EE_Network_Config' => static function () { |
|
945 | + return EE_Network_Config::instance(); |
|
946 | + }, |
|
947 | + 'EE_Config' => static function () { |
|
948 | + return EE_Config::instance(); |
|
949 | + }, |
|
950 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
951 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
952 | + }, |
|
953 | + 'EE_Admin_Config' => static function () { |
|
954 | + return EE_Config::instance()->admin; |
|
955 | + }, |
|
956 | + 'EE_Organization_Config' => static function () { |
|
957 | + return EE_Config::instance()->organization; |
|
958 | + }, |
|
959 | + 'EE_Network_Core_Config' => static function () { |
|
960 | + return EE_Network_Config::instance()->core; |
|
961 | + }, |
|
962 | + 'EE_Environment_Config' => static function () { |
|
963 | + return EE_Config::instance()->environment; |
|
964 | + }, |
|
965 | + 'EED_Core_Rest_Api' => static function () { |
|
966 | + return EED_Core_Rest_Api::instance(); |
|
967 | + }, |
|
968 | + 'WP_REST_Server' => static function () { |
|
969 | + return rest_get_server(); |
|
970 | + }, |
|
971 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
972 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
973 | + }, |
|
974 | + ]; |
|
975 | + } |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * can be used for supplying alternate names for classes, |
|
980 | + * or for connecting interface names to instantiable classes |
|
981 | + * |
|
982 | + * @throws InvalidAliasException |
|
983 | + */ |
|
984 | + protected function _register_core_aliases() |
|
985 | + { |
|
986 | + $aliases = [ |
|
987 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
988 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
989 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
990 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
991 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
992 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
993 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
994 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
995 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
996 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
997 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
998 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
999 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1000 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1001 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1002 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1003 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1004 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1005 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1006 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1007 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1008 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1009 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1010 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1011 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1012 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1013 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1014 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1015 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1016 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1017 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1018 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1019 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1020 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1021 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1022 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1023 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1024 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1025 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1026 | + ]; |
|
1027 | + foreach ($aliases as $alias => $fqn) { |
|
1028 | + if (is_array($fqn)) { |
|
1029 | + foreach ($fqn as $class => $for_class) { |
|
1030 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1031 | + } |
|
1032 | + continue; |
|
1033 | + } |
|
1034 | + $this->class_cache->addAlias($fqn, $alias); |
|
1035 | + } |
|
1036 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1037 | + $this->class_cache->addAlias( |
|
1038 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1039 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1040 | + ); |
|
1041 | + } |
|
1042 | + } |
|
1043 | + |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1047 | + * request Primarily used by unit tests. |
|
1048 | + */ |
|
1049 | + public function reset() |
|
1050 | + { |
|
1051 | + $this->_register_core_class_loaders(); |
|
1052 | + $this->_register_core_dependencies(); |
|
1053 | + } |
|
1054 | + |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1058 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1059 | + * WHY? |
|
1060 | + * Because if a class is type hinting for a concretion, |
|
1061 | + * then why would we need to find another class to supply it? |
|
1062 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1063 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1064 | + * Don't go looking for some substitute. |
|
1065 | + * Whereas if a class is type hinting for an interface... |
|
1066 | + * then we need to find an actual class to use. |
|
1067 | + * So the interface IS the alias for some other FQN, |
|
1068 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1069 | + * represents some other class. |
|
1070 | + * |
|
1071 | + * @param string $fqn |
|
1072 | + * @param string $for_class |
|
1073 | + * @return bool |
|
1074 | + * @deprecated 4.9.62.p |
|
1075 | + */ |
|
1076 | + public function has_alias($fqn = '', $for_class = '') |
|
1077 | + { |
|
1078 | + return $this->isAlias($fqn, $for_class); |
|
1079 | + } |
|
1080 | + |
|
1081 | + |
|
1082 | + /** |
|
1083 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1084 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1085 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1086 | + * for example: |
|
1087 | + * if the following two entries were added to the _aliases array: |
|
1088 | + * array( |
|
1089 | + * 'interface_alias' => 'some\namespace\interface' |
|
1090 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1091 | + * ) |
|
1092 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1093 | + * to load an instance of 'some\namespace\classname' |
|
1094 | + * |
|
1095 | + * @param string $alias |
|
1096 | + * @param string $for_class |
|
1097 | + * @return string |
|
1098 | + * @deprecated 4.9.62.p |
|
1099 | + */ |
|
1100 | + public function get_alias($alias = '', $for_class = '') |
|
1101 | + { |
|
1102 | + return $this->getFqnForAlias($alias, $for_class); |
|
1103 | + } |
|
1104 | 1104 | } |
@@ -15,163 +15,163 @@ |
||
15 | 15 | |
16 | 16 | class QuestionGroupRegForm extends EE_Form_Section_Proper |
17 | 17 | { |
18 | - /** |
|
19 | - * @var RegFormQuestionFactory |
|
20 | - */ |
|
21 | - public $reg_form_question_factory; |
|
18 | + /** |
|
19 | + * @var RegFormQuestionFactory |
|
20 | + */ |
|
21 | + public $reg_form_question_factory; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * QuestionGroupRegForm constructor. |
|
26 | - * |
|
27 | - * @param EE_Registration $registration |
|
28 | - * @param EE_Question_Group $question_group |
|
29 | - * @param bool $admin_request |
|
30 | - * @param RegFormQuestionFactory $reg_form_question_factory |
|
31 | - * @throws EE_Error |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - public function __construct( |
|
35 | - EE_Registration $registration, |
|
36 | - EE_Question_Group $question_group, |
|
37 | - bool $admin_request, |
|
38 | - RegFormQuestionFactory $reg_form_question_factory |
|
39 | - ) { |
|
40 | - $this->reg_form_question_factory = $reg_form_question_factory; |
|
41 | - parent::__construct($this->generateFormArgs($registration, $question_group, $admin_request)); |
|
42 | - } |
|
24 | + /** |
|
25 | + * QuestionGroupRegForm constructor. |
|
26 | + * |
|
27 | + * @param EE_Registration $registration |
|
28 | + * @param EE_Question_Group $question_group |
|
29 | + * @param bool $admin_request |
|
30 | + * @param RegFormQuestionFactory $reg_form_question_factory |
|
31 | + * @throws EE_Error |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + public function __construct( |
|
35 | + EE_Registration $registration, |
|
36 | + EE_Question_Group $question_group, |
|
37 | + bool $admin_request, |
|
38 | + RegFormQuestionFactory $reg_form_question_factory |
|
39 | + ) { |
|
40 | + $this->reg_form_question_factory = $reg_form_question_factory; |
|
41 | + parent::__construct($this->generateFormArgs($registration, $question_group, $admin_request)); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @param EE_Registration $registration |
|
47 | - * @param EE_Question_Group $question_group |
|
48 | - * @param bool $admin_request |
|
49 | - * @return array |
|
50 | - * @throws EE_Error |
|
51 | - * @throws ReflectionException |
|
52 | - */ |
|
53 | - private function generateFormArgs( |
|
54 | - EE_Registration $registration, |
|
55 | - EE_Question_Group $question_group, |
|
56 | - bool $admin_request |
|
57 | - ): array { |
|
58 | - // array of params to pass to parent constructor |
|
59 | - $form_args = [ |
|
60 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
61 | - 'html_class' => $admin_request |
|
62 | - ? 'form-table ee-reg-form-qstn-grp-dv' |
|
63 | - : 'ee-reg-form-qstn-grp-dv', |
|
64 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
65 | - . $registration->ID() . '-lbl', |
|
66 | - 'subsections' => [ |
|
67 | - 'reg_form_qstn_grp_hdr' => $this->questionGroupHeader($question_group, $admin_request), |
|
68 | - ], |
|
69 | - 'layout_strategy' => $admin_request |
|
70 | - ? new EE_Admin_Two_Column_Layout() |
|
71 | - : new EE_Div_Per_Section_Layout(), |
|
72 | - ]; |
|
73 | - // where params |
|
74 | - $query_params = ['QST_deleted' => 0]; |
|
75 | - // don't load admin only questions on the frontend |
|
76 | - if (! $admin_request) { |
|
77 | - $query_params['QST_admin_only'] = ['!=', true]; |
|
78 | - } |
|
79 | - $questions = $question_group->get_many_related( |
|
80 | - 'Question', |
|
81 | - apply_filters( |
|
82 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
83 | - [ |
|
84 | - $query_params, |
|
85 | - 'order_by' => [ |
|
86 | - 'Question_Group_Question.QGQ_order' => 'ASC', |
|
87 | - ], |
|
88 | - ], |
|
89 | - $question_group, |
|
90 | - $registration, |
|
91 | - $this |
|
92 | - ) |
|
93 | - ); |
|
94 | - // filter for additional content before questions |
|
95 | - $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
96 | - apply_filters( |
|
97 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
98 | - '', |
|
99 | - $registration, |
|
100 | - $question_group, |
|
101 | - $this |
|
102 | - ) |
|
103 | - ); |
|
104 | - // loop thru questions |
|
105 | - foreach ($questions as $question) { |
|
106 | - if ($question instanceof EE_Question) { |
|
107 | - $identifier = $question->is_system_question() |
|
108 | - ? $question->system_ID() |
|
109 | - : $question->ID(); |
|
45 | + /** |
|
46 | + * @param EE_Registration $registration |
|
47 | + * @param EE_Question_Group $question_group |
|
48 | + * @param bool $admin_request |
|
49 | + * @return array |
|
50 | + * @throws EE_Error |
|
51 | + * @throws ReflectionException |
|
52 | + */ |
|
53 | + private function generateFormArgs( |
|
54 | + EE_Registration $registration, |
|
55 | + EE_Question_Group $question_group, |
|
56 | + bool $admin_request |
|
57 | + ): array { |
|
58 | + // array of params to pass to parent constructor |
|
59 | + $form_args = [ |
|
60 | + 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
61 | + 'html_class' => $admin_request |
|
62 | + ? 'form-table ee-reg-form-qstn-grp-dv' |
|
63 | + : 'ee-reg-form-qstn-grp-dv', |
|
64 | + 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
65 | + . $registration->ID() . '-lbl', |
|
66 | + 'subsections' => [ |
|
67 | + 'reg_form_qstn_grp_hdr' => $this->questionGroupHeader($question_group, $admin_request), |
|
68 | + ], |
|
69 | + 'layout_strategy' => $admin_request |
|
70 | + ? new EE_Admin_Two_Column_Layout() |
|
71 | + : new EE_Div_Per_Section_Layout(), |
|
72 | + ]; |
|
73 | + // where params |
|
74 | + $query_params = ['QST_deleted' => 0]; |
|
75 | + // don't load admin only questions on the frontend |
|
76 | + if (! $admin_request) { |
|
77 | + $query_params['QST_admin_only'] = ['!=', true]; |
|
78 | + } |
|
79 | + $questions = $question_group->get_many_related( |
|
80 | + 'Question', |
|
81 | + apply_filters( |
|
82 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
83 | + [ |
|
84 | + $query_params, |
|
85 | + 'order_by' => [ |
|
86 | + 'Question_Group_Question.QGQ_order' => 'ASC', |
|
87 | + ], |
|
88 | + ], |
|
89 | + $question_group, |
|
90 | + $registration, |
|
91 | + $this |
|
92 | + ) |
|
93 | + ); |
|
94 | + // filter for additional content before questions |
|
95 | + $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
96 | + apply_filters( |
|
97 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
98 | + '', |
|
99 | + $registration, |
|
100 | + $question_group, |
|
101 | + $this |
|
102 | + ) |
|
103 | + ); |
|
104 | + // loop thru questions |
|
105 | + foreach ($questions as $question) { |
|
106 | + if ($question instanceof EE_Question) { |
|
107 | + $identifier = $question->is_system_question() |
|
108 | + ? $question->system_ID() |
|
109 | + : $question->ID(); |
|
110 | 110 | |
111 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question_factory->create( |
|
112 | - $registration, |
|
113 | - $question |
|
114 | - ); |
|
115 | - } |
|
116 | - } |
|
117 | - $form_args['subsections'] = apply_filters( |
|
118 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
119 | - $form_args['subsections'], |
|
120 | - $registration, |
|
121 | - $question_group, |
|
122 | - $this |
|
123 | - ); |
|
124 | - // filter for additional content after questions |
|
125 | - $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
126 | - apply_filters( |
|
127 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
128 | - '', |
|
129 | - $registration, |
|
130 | - $question_group, |
|
131 | - $this |
|
132 | - ) |
|
133 | - ); |
|
111 | + $form_args['subsections'][ $identifier ] = $this->reg_form_question_factory->create( |
|
112 | + $registration, |
|
113 | + $question |
|
114 | + ); |
|
115 | + } |
|
116 | + } |
|
117 | + $form_args['subsections'] = apply_filters( |
|
118 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
119 | + $form_args['subsections'], |
|
120 | + $registration, |
|
121 | + $question_group, |
|
122 | + $this |
|
123 | + ); |
|
124 | + // filter for additional content after questions |
|
125 | + $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
126 | + apply_filters( |
|
127 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
128 | + '', |
|
129 | + $registration, |
|
130 | + $question_group, |
|
131 | + $this |
|
132 | + ) |
|
133 | + ); |
|
134 | 134 | |
135 | - return $form_args; |
|
136 | - } |
|
135 | + return $form_args; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * @param EE_Question_Group $question_group |
|
141 | - * @param bool $admin_request |
|
142 | - * @return EE_Form_Section_HTML |
|
143 | - */ |
|
144 | - private function questionGroupHeader(EE_Question_Group $question_group, bool $admin_request): EE_Form_Section_HTML |
|
145 | - { |
|
146 | - $html = ''; |
|
147 | - // group_name |
|
148 | - if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
149 | - if ($admin_request) { |
|
150 | - $html .= EEH_HTML::br(); |
|
151 | - $html .= EEH_HTML::h3( |
|
152 | - $question_group->name(), |
|
153 | - '', |
|
154 | - 'ee-reg-form-qstn-grp-title title', |
|
155 | - 'font-size: 1.3em; padding-left:0;' |
|
156 | - ); |
|
157 | - } else { |
|
158 | - $html .= EEH_HTML::h4( |
|
159 | - $question_group->name(), |
|
160 | - '', |
|
161 | - 'ee-reg-form-qstn-grp-title section-title' |
|
162 | - ); |
|
163 | - } |
|
164 | - } |
|
165 | - // group_desc |
|
166 | - if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
167 | - $html .= EEH_HTML::p( |
|
168 | - $question_group->desc(), |
|
169 | - '', |
|
170 | - $admin_request |
|
171 | - ? 'ee-reg-form-qstn-grp-desc-pg' |
|
172 | - : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
173 | - ); |
|
174 | - } |
|
175 | - return new EE_Form_Section_HTML($html); |
|
176 | - } |
|
139 | + /** |
|
140 | + * @param EE_Question_Group $question_group |
|
141 | + * @param bool $admin_request |
|
142 | + * @return EE_Form_Section_HTML |
|
143 | + */ |
|
144 | + private function questionGroupHeader(EE_Question_Group $question_group, bool $admin_request): EE_Form_Section_HTML |
|
145 | + { |
|
146 | + $html = ''; |
|
147 | + // group_name |
|
148 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
149 | + if ($admin_request) { |
|
150 | + $html .= EEH_HTML::br(); |
|
151 | + $html .= EEH_HTML::h3( |
|
152 | + $question_group->name(), |
|
153 | + '', |
|
154 | + 'ee-reg-form-qstn-grp-title title', |
|
155 | + 'font-size: 1.3em; padding-left:0;' |
|
156 | + ); |
|
157 | + } else { |
|
158 | + $html .= EEH_HTML::h4( |
|
159 | + $question_group->name(), |
|
160 | + '', |
|
161 | + 'ee-reg-form-qstn-grp-title section-title' |
|
162 | + ); |
|
163 | + } |
|
164 | + } |
|
165 | + // group_desc |
|
166 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
167 | + $html .= EEH_HTML::p( |
|
168 | + $question_group->desc(), |
|
169 | + '', |
|
170 | + $admin_request |
|
171 | + ? 'ee-reg-form-qstn-grp-desc-pg' |
|
172 | + : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
173 | + ); |
|
174 | + } |
|
175 | + return new EE_Form_Section_HTML($html); |
|
176 | + } |
|
177 | 177 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | ): array { |
58 | 58 | // array of params to pass to parent constructor |
59 | 59 | $form_args = [ |
60 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
60 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'.$registration->ID(), |
|
61 | 61 | 'html_class' => $admin_request |
62 | 62 | ? 'form-table ee-reg-form-qstn-grp-dv' |
63 | 63 | : 'ee-reg-form-qstn-grp-dv', |
64 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
65 | - . $registration->ID() . '-lbl', |
|
64 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-' |
|
65 | + . $registration->ID().'-lbl', |
|
66 | 66 | 'subsections' => [ |
67 | 67 | 'reg_form_qstn_grp_hdr' => $this->questionGroupHeader($question_group, $admin_request), |
68 | 68 | ], |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // where params |
74 | 74 | $query_params = ['QST_deleted' => 0]; |
75 | 75 | // don't load admin only questions on the frontend |
76 | - if (! $admin_request) { |
|
76 | + if ( ! $admin_request) { |
|
77 | 77 | $query_params['QST_admin_only'] = ['!=', true]; |
78 | 78 | } |
79 | 79 | $questions = $question_group->get_many_related( |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ? $question->system_ID() |
109 | 109 | : $question->ID(); |
110 | 110 | |
111 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question_factory->create( |
|
111 | + $form_args['subsections'][$identifier] = $this->reg_form_question_factory->create( |
|
112 | 112 | $registration, |
113 | 113 | $question |
114 | 114 | ); |
@@ -8,21 +8,21 @@ |
||
8 | 8 | class AutoCopyAttendeeInfoForm extends EE_Form_Section_HTML |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * CopyAttendeeInfoForm constructor. |
|
13 | - */ |
|
14 | - public function __construct(string $slug) |
|
15 | - { |
|
16 | - parent::__construct( |
|
17 | - EEH_Template::locate_template( |
|
18 | - SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php', |
|
19 | - apply_filters( |
|
20 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
21 | - [] |
|
22 | - ), |
|
23 | - true, |
|
24 | - true |
|
25 | - ) |
|
26 | - ); |
|
27 | - } |
|
11 | + /** |
|
12 | + * CopyAttendeeInfoForm constructor. |
|
13 | + */ |
|
14 | + public function __construct(string $slug) |
|
15 | + { |
|
16 | + parent::__construct( |
|
17 | + EEH_Template::locate_template( |
|
18 | + SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php', |
|
19 | + apply_filters( |
|
20 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
21 | + [] |
|
22 | + ), |
|
23 | + true, |
|
24 | + true |
|
25 | + ) |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | } |
@@ -15,108 +15,108 @@ |
||
15 | 15 | |
16 | 16 | class RegFormQuestionFactory |
17 | 17 | { |
18 | - /** |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - private $required_questions = []; |
|
18 | + /** |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + private $required_questions = []; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - public function requiredQuestions(): array |
|
28 | - { |
|
29 | - return $this->required_questions; |
|
30 | - } |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + public function requiredQuestions(): array |
|
28 | + { |
|
29 | + return $this->required_questions; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param EE_Registration $registration |
|
35 | - * @param EE_Question $question |
|
36 | - * @return EE_Form_Input_Base |
|
37 | - * @throws EE_Error |
|
38 | - * @throws InvalidArgumentException |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - * @throws InvalidInterfaceException |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - public function create(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
44 | - { |
|
45 | - // if this question was for an attendee detail, then check for that answer |
|
46 | - $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
47 | - $registration, |
|
48 | - $question->system_ID() |
|
49 | - ); |
|
50 | - $answer = $answer_value === null |
|
51 | - ? EEM_Answer::instance()->get_one( |
|
52 | - [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
53 | - ) |
|
54 | - : null; |
|
55 | - // if NOT returning to edit an existing registration |
|
56 | - // OR if this question is for an attendee property |
|
57 | - // OR we still don't have an EE_Answer object |
|
58 | - if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
59 | - // create an EE_Answer object for storing everything in |
|
60 | - $answer = EE_Answer::new_instance( |
|
61 | - [ |
|
62 | - 'QST_ID' => $question->ID(), |
|
63 | - 'REG_ID' => $registration->ID(), |
|
64 | - ] |
|
65 | - ); |
|
66 | - } |
|
67 | - // verify instance |
|
68 | - if ($answer instanceof EE_Answer) { |
|
69 | - if (! empty($answer_value)) { |
|
70 | - $answer->set('ANS_value', $answer_value); |
|
71 | - } |
|
72 | - $answer->cache('Question', $question); |
|
73 | - // remember system ID had a bug where sometimes it could be null |
|
74 | - $answer_cache_id = $question->is_system_question() |
|
75 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
76 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
77 | - $registration->cache('Answer', $answer, $answer_cache_id); |
|
78 | - } |
|
79 | - return $this->generateQuestionInput($registration, $question, $answer); |
|
80 | - } |
|
33 | + /** |
|
34 | + * @param EE_Registration $registration |
|
35 | + * @param EE_Question $question |
|
36 | + * @return EE_Form_Input_Base |
|
37 | + * @throws EE_Error |
|
38 | + * @throws InvalidArgumentException |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + * @throws InvalidInterfaceException |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + public function create(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
44 | + { |
|
45 | + // if this question was for an attendee detail, then check for that answer |
|
46 | + $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
47 | + $registration, |
|
48 | + $question->system_ID() |
|
49 | + ); |
|
50 | + $answer = $answer_value === null |
|
51 | + ? EEM_Answer::instance()->get_one( |
|
52 | + [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
|
53 | + ) |
|
54 | + : null; |
|
55 | + // if NOT returning to edit an existing registration |
|
56 | + // OR if this question is for an attendee property |
|
57 | + // OR we still don't have an EE_Answer object |
|
58 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
59 | + // create an EE_Answer object for storing everything in |
|
60 | + $answer = EE_Answer::new_instance( |
|
61 | + [ |
|
62 | + 'QST_ID' => $question->ID(), |
|
63 | + 'REG_ID' => $registration->ID(), |
|
64 | + ] |
|
65 | + ); |
|
66 | + } |
|
67 | + // verify instance |
|
68 | + if ($answer instanceof EE_Answer) { |
|
69 | + if (! empty($answer_value)) { |
|
70 | + $answer->set('ANS_value', $answer_value); |
|
71 | + } |
|
72 | + $answer->cache('Question', $question); |
|
73 | + // remember system ID had a bug where sometimes it could be null |
|
74 | + $answer_cache_id = $question->is_system_question() |
|
75 | + ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
76 | + : $question->ID() . '-' . $registration->reg_url_link(); |
|
77 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
78 | + } |
|
79 | + return $this->generateQuestionInput($registration, $question, $answer); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * @param EE_Registration $registration |
|
85 | - * @param EE_Question $question |
|
86 | - * @param $answer |
|
87 | - * @return EE_Form_Input_Base |
|
88 | - * @throws EE_Error |
|
89 | - * @throws InvalidArgumentException |
|
90 | - * @throws ReflectionException |
|
91 | - * @throws InvalidDataTypeException |
|
92 | - * @throws InvalidInterfaceException |
|
93 | - */ |
|
94 | - private function generateQuestionInput( |
|
95 | - EE_Registration $registration, |
|
96 | - EE_Question $question, |
|
97 | - $answer |
|
98 | - ): EE_Form_Input_Base { |
|
99 | - $identifier = $question->is_system_question() |
|
100 | - ? $question->system_ID() |
|
101 | - : $question->ID(); |
|
102 | - $this->required_questions[ $identifier ] = $question->required(); |
|
103 | - $input_constructor_args = [ |
|
104 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
105 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
106 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
107 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
108 | - 'html_label_class' => 'ee-reg-qstn', |
|
109 | - ]; |
|
110 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
111 | - if ($answer instanceof EE_Answer && $answer->ID()) { |
|
112 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
113 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
114 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
115 | - } |
|
116 | - return $question->generate_form_input( |
|
117 | - $registration, |
|
118 | - $answer, |
|
119 | - $input_constructor_args |
|
120 | - ); |
|
121 | - } |
|
83 | + /** |
|
84 | + * @param EE_Registration $registration |
|
85 | + * @param EE_Question $question |
|
86 | + * @param $answer |
|
87 | + * @return EE_Form_Input_Base |
|
88 | + * @throws EE_Error |
|
89 | + * @throws InvalidArgumentException |
|
90 | + * @throws ReflectionException |
|
91 | + * @throws InvalidDataTypeException |
|
92 | + * @throws InvalidInterfaceException |
|
93 | + */ |
|
94 | + private function generateQuestionInput( |
|
95 | + EE_Registration $registration, |
|
96 | + EE_Question $question, |
|
97 | + $answer |
|
98 | + ): EE_Form_Input_Base { |
|
99 | + $identifier = $question->is_system_question() |
|
100 | + ? $question->system_ID() |
|
101 | + : $question->ID(); |
|
102 | + $this->required_questions[ $identifier ] = $question->required(); |
|
103 | + $input_constructor_args = [ |
|
104 | + 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
105 | + 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
106 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
107 | + 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
108 | + 'html_label_class' => 'ee-reg-qstn', |
|
109 | + ]; |
|
110 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
111 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
112 | + $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
113 | + $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
114 | + $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
115 | + } |
|
116 | + return $question->generate_form_input( |
|
117 | + $registration, |
|
118 | + $answer, |
|
119 | + $input_constructor_args |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $registration, |
48 | 48 | $question->system_ID() |
49 | 49 | ); |
50 | - $answer = $answer_value === null |
|
50 | + $answer = $answer_value === null |
|
51 | 51 | ? EEM_Answer::instance()->get_one( |
52 | 52 | [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]] |
53 | 53 | ) |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | } |
67 | 67 | // verify instance |
68 | 68 | if ($answer instanceof EE_Answer) { |
69 | - if (! empty($answer_value)) { |
|
69 | + if ( ! empty($answer_value)) { |
|
70 | 70 | $answer->set('ANS_value', $answer_value); |
71 | 71 | } |
72 | 72 | $answer->cache('Question', $question); |
73 | 73 | // remember system ID had a bug where sometimes it could be null |
74 | 74 | $answer_cache_id = $question->is_system_question() |
75 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
76 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
75 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
76 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
77 | 77 | $registration->cache('Answer', $answer, $answer_cache_id); |
78 | 78 | } |
79 | 79 | return $this->generateQuestionInput($registration, $question, $answer); |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | $identifier = $question->is_system_question() |
100 | 100 | ? $question->system_ID() |
101 | 101 | : $question->ID(); |
102 | - $this->required_questions[ $identifier ] = $question->required(); |
|
102 | + $this->required_questions[$identifier] = $question->required(); |
|
103 | 103 | $input_constructor_args = [ |
104 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
105 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
106 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
107 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
104 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
105 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
106 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
107 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
108 | 108 | 'html_label_class' => 'ee-reg-qstn', |
109 | 109 | ]; |
110 | 110 | $input_constructor_args['html_label_id'] .= '-lbl'; |
111 | 111 | if ($answer instanceof EE_Answer && $answer->ID()) { |
112 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
113 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
114 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
112 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
113 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
114 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
115 | 115 | } |
116 | 116 | return $question->generate_form_input( |
117 | 117 | $registration, |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | // Increment the reg forms number if form is valid. |
189 | 189 | if ($registrant_form->hasQuestions()) { |
190 | 190 | $this->reg_form_count++; |
191 | - $subsections[ $reg_url_link ] = $registrant_form; |
|
191 | + $subsections[$reg_url_link] = $registrant_form; |
|
192 | 192 | } else { |
193 | 193 | // or just add a blank section if there are no questions |
194 | - $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
194 | + $subsections[$reg_url_link] = new EE_Form_Section_HTML(); |
|
195 | 195 | } |
196 | 196 | |
197 | - $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
198 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
199 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
197 | + $this->template_args['registrations'][$reg_url_link] = $registration; |
|
198 | + $this->template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
199 | + $this->template_args['ticket_count'][$registration->ticket()->ID()] |
|
200 | 200 | ) |
201 | - ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
201 | + ? $this->template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
202 | 202 | : 1; |
203 | 203 | $ticket_line_item |
204 | 204 | = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | 'Ticket', |
207 | 207 | [$registration->ticket()->ID()] |
208 | 208 | ); |
209 | - $ticket_line_item = is_array($ticket_line_item) |
|
209 | + $ticket_line_item = is_array($ticket_line_item) |
|
210 | 210 | ? reset($ticket_line_item) |
211 | 211 | : $ticket_line_item; |
212 | - $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] |
|
212 | + $this->template_args['ticket_line_item'][$registration->ticket()->ID()] |
|
213 | 213 | = $Line_Item_Display->display_line_item($ticket_line_item); |
214 | 214 | if ($registration->is_primary_registrant()) { |
215 | 215 | $primary_registrant = $reg_url_link; |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
224 | 224 | // generate hidden input |
225 | 225 | if ( |
226 | - isset($subsections[ $primary_registrant ]) |
|
227 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
226 | + isset($subsections[$primary_registrant]) |
|
227 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
228 | 228 | ) { |
229 | - $subsections[ $primary_registrant ]->add_subsections( |
|
229 | + $subsections[$primary_registrant]->add_subsections( |
|
230 | 230 | $copy_options, |
231 | 231 | 'primary_registrant', |
232 | 232 | false |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | // Set the registration form template (default: one form per ticket details table). |
239 | 239 | // We decide the template to used based on the number of forms. |
240 | 240 | $template = $this->reg_form_count > 1 |
241 | - ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
242 | - : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
241 | + ? SPCO_REG_STEPS_PATH . $this->reg_step->slug().'/attendee_info_main.template.php' |
|
242 | + : SPCO_REG_STEPS_PATH.$this->reg_step->slug().'/attendee_info_single.template.php'; |
|
243 | 243 | $this->reg_step->setTemplate($template); |
244 | 244 | |
245 | 245 | return $subsections; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
254 | 254 | { |
255 | 255 | // if this isn't a revisit, and they have the privacy consent box enabled, add it |
256 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
256 | + if ( ! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
257 | 257 | $extra_inputs_section->add_subsections( |
258 | 258 | [ |
259 | 259 | 'consent_box' => new EE_Form_Section_Proper( |
@@ -33,265 +33,265 @@ |
||
33 | 33 | class RegForm extends EE_Form_Section_Proper |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var bool |
|
38 | - */ |
|
39 | - private $print_copy_info = false; |
|
36 | + /** |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | + private $print_copy_info = false; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var EE_Registration_Config |
|
43 | - */ |
|
44 | - public $reg_config; |
|
41 | + /** |
|
42 | + * @var EE_Registration_Config |
|
43 | + */ |
|
44 | + public $reg_config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var int |
|
48 | - */ |
|
49 | - protected $reg_form_count = 0; |
|
46 | + /** |
|
47 | + * @var int |
|
48 | + */ |
|
49 | + protected $reg_form_count = 0; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var EE_SPCO_Reg_Step_Attendee_Information |
|
53 | - */ |
|
54 | - public $reg_step; |
|
51 | + /** |
|
52 | + * @var EE_SPCO_Reg_Step_Attendee_Information |
|
53 | + */ |
|
54 | + public $reg_step; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @var array |
|
58 | - */ |
|
59 | - private $template_args = []; |
|
56 | + /** |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + private $template_args = []; |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * RegForm constructor. |
|
64 | - * |
|
65 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
66 | - * @param EE_Registration_Config $reg_config |
|
67 | - * @throws ReflectionException |
|
68 | - * @throws EE_Error |
|
69 | - */ |
|
70 | - public function __construct( |
|
71 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
72 | - EE_Registration_Config $reg_config |
|
73 | - ) { |
|
74 | - $this->reg_step = $reg_step; |
|
75 | - $this->reg_config = $reg_config; |
|
76 | - LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
77 | - LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
78 | - parent::__construct( |
|
79 | - [ |
|
80 | - 'name' => $this->reg_step->reg_form_name(), |
|
81 | - 'html_id' => $this->reg_step->reg_form_name(), |
|
82 | - 'subsections' => $this->generateSubsections(), |
|
83 | - 'layout_strategy' => new EE_Template_Layout( |
|
84 | - [ |
|
85 | - 'layout_template_file' => $this->reg_step->template(), // layout_template |
|
86 | - 'template_args' => $this->template_args, |
|
87 | - ] |
|
88 | - ), |
|
89 | - ] |
|
90 | - ); |
|
91 | - } |
|
62 | + /** |
|
63 | + * RegForm constructor. |
|
64 | + * |
|
65 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
66 | + * @param EE_Registration_Config $reg_config |
|
67 | + * @throws ReflectionException |
|
68 | + * @throws EE_Error |
|
69 | + */ |
|
70 | + public function __construct( |
|
71 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
72 | + EE_Registration_Config $reg_config |
|
73 | + ) { |
|
74 | + $this->reg_step = $reg_step; |
|
75 | + $this->reg_config = $reg_config; |
|
76 | + LoaderFactory::getShared(CountryOptions::class, [$this->reg_step->checkout->action]); |
|
77 | + LoaderFactory::getShared(StateOptions::class, [$this->reg_step->checkout->action]); |
|
78 | + parent::__construct( |
|
79 | + [ |
|
80 | + 'name' => $this->reg_step->reg_form_name(), |
|
81 | + 'html_id' => $this->reg_step->reg_form_name(), |
|
82 | + 'subsections' => $this->generateSubsections(), |
|
83 | + 'layout_strategy' => new EE_Template_Layout( |
|
84 | + [ |
|
85 | + 'layout_template_file' => $this->reg_step->template(), // layout_template |
|
86 | + 'template_args' => $this->template_args, |
|
87 | + ] |
|
88 | + ), |
|
89 | + ] |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * @return bool |
|
96 | - */ |
|
97 | - public function printCopyInfo(): bool |
|
98 | - { |
|
99 | - return $this->print_copy_info; |
|
100 | - } |
|
94 | + /** |
|
95 | + * @return bool |
|
96 | + */ |
|
97 | + public function printCopyInfo(): bool |
|
98 | + { |
|
99 | + return $this->print_copy_info; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function enablePrintCopyInfo(): void |
|
107 | - { |
|
108 | - $this->print_copy_info = true; |
|
109 | - } |
|
103 | + /** |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function enablePrintCopyInfo(): void |
|
107 | + { |
|
108 | + $this->print_copy_info = true; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - public function regFormCount(): int |
|
116 | - { |
|
117 | - return $this->reg_form_count; |
|
118 | - } |
|
112 | + /** |
|
113 | + * @return int |
|
114 | + */ |
|
115 | + public function regFormCount(): int |
|
116 | + { |
|
117 | + return $this->reg_form_count; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * @param EE_Registration $registration |
|
123 | - * @param EE_Question $question |
|
124 | - * @return EE_Form_Input_Base |
|
125 | - * @throws EE_Error |
|
126 | - * @throws ReflectionException |
|
127 | - */ |
|
128 | - public function regFormQuestion(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
129 | - { |
|
130 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
131 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
132 | - return $reg_form_question_factory->create($registration, $question); |
|
133 | - } |
|
121 | + /** |
|
122 | + * @param EE_Registration $registration |
|
123 | + * @param EE_Question $question |
|
124 | + * @return EE_Form_Input_Base |
|
125 | + * @throws EE_Error |
|
126 | + * @throws ReflectionException |
|
127 | + */ |
|
128 | + public function regFormQuestion(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
129 | + { |
|
130 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
131 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
132 | + return $reg_form_question_factory->create($registration, $question); |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | - /** |
|
137 | - * @return EE_Form_Section_Proper[] |
|
138 | - * @throws DomainException |
|
139 | - * @throws EE_Error |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws ReflectionException |
|
142 | - * @throws EntityNotFoundException |
|
143 | - * @throws InvalidDataTypeException |
|
144 | - * @throws InvalidInterfaceException |
|
145 | - */ |
|
146 | - private function generateSubsections(): array |
|
147 | - { |
|
148 | - // Init reg forms count. |
|
149 | - $this->reg_form_count = 0; |
|
136 | + /** |
|
137 | + * @return EE_Form_Section_Proper[] |
|
138 | + * @throws DomainException |
|
139 | + * @throws EE_Error |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws ReflectionException |
|
142 | + * @throws EntityNotFoundException |
|
143 | + * @throws InvalidDataTypeException |
|
144 | + * @throws InvalidInterfaceException |
|
145 | + */ |
|
146 | + private function generateSubsections(): array |
|
147 | + { |
|
148 | + // Init reg forms count. |
|
149 | + $this->reg_form_count = 0; |
|
150 | 150 | |
151 | - $primary_registrant = null; |
|
152 | - // autoload Line_Item_Display classes |
|
153 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
154 | - $Line_Item_Display = new EE_Line_Item_Display(); |
|
155 | - // calculate taxes |
|
156 | - $Line_Item_Display->display_line_item( |
|
157 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
158 | - ['set_tax_rate' => true] |
|
159 | - ); |
|
160 | - $extra_inputs_section = $this->reg_step->reg_step_hidden_inputs(); |
|
161 | - $this->addPrivacyConsentCheckbox($extra_inputs_section); |
|
162 | - $subsections = [ |
|
163 | - 'default_hidden_inputs' => $extra_inputs_section, |
|
164 | - ]; |
|
151 | + $primary_registrant = null; |
|
152 | + // autoload Line_Item_Display classes |
|
153 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
154 | + $Line_Item_Display = new EE_Line_Item_Display(); |
|
155 | + // calculate taxes |
|
156 | + $Line_Item_Display->display_line_item( |
|
157 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
158 | + ['set_tax_rate' => true] |
|
159 | + ); |
|
160 | + $extra_inputs_section = $this->reg_step->reg_step_hidden_inputs(); |
|
161 | + $this->addPrivacyConsentCheckbox($extra_inputs_section); |
|
162 | + $subsections = [ |
|
163 | + 'default_hidden_inputs' => $extra_inputs_section, |
|
164 | + ]; |
|
165 | 165 | |
166 | - $this->template_args = [ |
|
167 | - 'revisit' => $this->reg_step->checkout->revisit, |
|
168 | - 'registrations' => [], |
|
169 | - 'ticket_count' => [], |
|
170 | - ]; |
|
171 | - // grab the saved registrations from the transaction |
|
172 | - $registrations = $this->reg_step->checkout->transaction->registrations( |
|
173 | - $this->reg_step->checkout->reg_cache_where_params |
|
174 | - ); |
|
175 | - if ($registrations) { |
|
176 | - foreach ($registrations as $registration) { |
|
177 | - // can this registration be processed during this visit ? |
|
178 | - if ( |
|
179 | - $registration instanceof EE_Registration |
|
180 | - && $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration) |
|
181 | - ) { |
|
182 | - $reg_url_link = $registration->reg_url_link(); |
|
183 | - /** @var RegistrationForm $registrant_form */ |
|
184 | - $registrant_form = LoaderFactory::getNew( |
|
185 | - RegistrationForm::class, |
|
186 | - [ |
|
187 | - $registration, |
|
188 | - $this->reg_step->checkout->admin_request, |
|
189 | - $this->reg_config->copyAttendeeInfo(), |
|
190 | - [$this, 'enablePrintCopyInfo'], |
|
191 | - ] |
|
192 | - ); |
|
193 | - // Increment the reg forms number if form is valid. |
|
194 | - if ($registrant_form->hasQuestions()) { |
|
195 | - $this->reg_form_count++; |
|
196 | - $subsections[ $reg_url_link ] = $registrant_form; |
|
197 | - } else { |
|
198 | - // or just add a blank section if there are no questions |
|
199 | - $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
200 | - } |
|
166 | + $this->template_args = [ |
|
167 | + 'revisit' => $this->reg_step->checkout->revisit, |
|
168 | + 'registrations' => [], |
|
169 | + 'ticket_count' => [], |
|
170 | + ]; |
|
171 | + // grab the saved registrations from the transaction |
|
172 | + $registrations = $this->reg_step->checkout->transaction->registrations( |
|
173 | + $this->reg_step->checkout->reg_cache_where_params |
|
174 | + ); |
|
175 | + if ($registrations) { |
|
176 | + foreach ($registrations as $registration) { |
|
177 | + // can this registration be processed during this visit ? |
|
178 | + if ( |
|
179 | + $registration instanceof EE_Registration |
|
180 | + && $this->reg_step->checkout->visit_allows_processing_of_this_registration($registration) |
|
181 | + ) { |
|
182 | + $reg_url_link = $registration->reg_url_link(); |
|
183 | + /** @var RegistrationForm $registrant_form */ |
|
184 | + $registrant_form = LoaderFactory::getNew( |
|
185 | + RegistrationForm::class, |
|
186 | + [ |
|
187 | + $registration, |
|
188 | + $this->reg_step->checkout->admin_request, |
|
189 | + $this->reg_config->copyAttendeeInfo(), |
|
190 | + [$this, 'enablePrintCopyInfo'], |
|
191 | + ] |
|
192 | + ); |
|
193 | + // Increment the reg forms number if form is valid. |
|
194 | + if ($registrant_form->hasQuestions()) { |
|
195 | + $this->reg_form_count++; |
|
196 | + $subsections[ $reg_url_link ] = $registrant_form; |
|
197 | + } else { |
|
198 | + // or just add a blank section if there are no questions |
|
199 | + $subsections[ $reg_url_link ] = new EE_Form_Section_HTML(); |
|
200 | + } |
|
201 | 201 | |
202 | - $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
203 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
204 | - $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
205 | - ) |
|
206 | - ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
207 | - : 1; |
|
208 | - $ticket_line_item |
|
209 | - = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
210 | - $this->reg_step->checkout->cart->get_grand_total(), |
|
211 | - 'Ticket', |
|
212 | - [$registration->ticket()->ID()] |
|
213 | - ); |
|
214 | - $ticket_line_item = is_array($ticket_line_item) |
|
215 | - ? reset($ticket_line_item) |
|
216 | - : $ticket_line_item; |
|
217 | - $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] |
|
218 | - = $Line_Item_Display->display_line_item($ticket_line_item); |
|
219 | - if ($registration->is_primary_registrant()) { |
|
220 | - $primary_registrant = $reg_url_link; |
|
221 | - } |
|
222 | - } |
|
223 | - } |
|
202 | + $this->template_args['registrations'][ $reg_url_link ] = $registration; |
|
203 | + $this->template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
204 | + $this->template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
205 | + ) |
|
206 | + ? $this->template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
207 | + : 1; |
|
208 | + $ticket_line_item |
|
209 | + = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
210 | + $this->reg_step->checkout->cart->get_grand_total(), |
|
211 | + 'Ticket', |
|
212 | + [$registration->ticket()->ID()] |
|
213 | + ); |
|
214 | + $ticket_line_item = is_array($ticket_line_item) |
|
215 | + ? reset($ticket_line_item) |
|
216 | + : $ticket_line_item; |
|
217 | + $this->template_args['ticket_line_item'][ $registration->ticket()->ID() ] |
|
218 | + = $Line_Item_Display->display_line_item($ticket_line_item); |
|
219 | + if ($registration->is_primary_registrant()) { |
|
220 | + $primary_registrant = $reg_url_link; |
|
221 | + } |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - if ($primary_registrant && count($registrations) > 1) { |
|
226 | - $copy_options['spco_copy_attendee_chk'] = $this->print_copy_info |
|
227 | - ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
228 | - : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
|
229 | - // generate hidden input |
|
230 | - if ( |
|
231 | - isset($subsections[ $primary_registrant ]) |
|
232 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
233 | - ) { |
|
234 | - $subsections[ $primary_registrant ]->add_subsections( |
|
235 | - $copy_options, |
|
236 | - 'primary_registrant', |
|
237 | - false |
|
238 | - ); |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
225 | + if ($primary_registrant && count($registrations) > 1) { |
|
226 | + $copy_options['spco_copy_attendee_chk'] = $this->print_copy_info |
|
227 | + ? new CopyAttendeeInfoForm($registrations, $this->reg_step->slug()) |
|
228 | + : new AutoCopyAttendeeInfoForm($this->reg_step->slug()); |
|
229 | + // generate hidden input |
|
230 | + if ( |
|
231 | + isset($subsections[ $primary_registrant ]) |
|
232 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
233 | + ) { |
|
234 | + $subsections[ $primary_registrant ]->add_subsections( |
|
235 | + $copy_options, |
|
236 | + 'primary_registrant', |
|
237 | + false |
|
238 | + ); |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - // Set the registration form template (default: one form per ticket details table). |
|
244 | - // We decide the template to used based on the number of forms. |
|
245 | - $template = $this->reg_form_count > 1 |
|
246 | - ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
247 | - : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
248 | - $this->reg_step->setTemplate($template); |
|
243 | + // Set the registration form template (default: one form per ticket details table). |
|
244 | + // We decide the template to used based on the number of forms. |
|
245 | + $template = $this->reg_form_count > 1 |
|
246 | + ? SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_main.template.php' |
|
247 | + : SPCO_REG_STEPS_PATH . $this->reg_step->slug() . '/attendee_info_single.template.php'; |
|
248 | + $this->reg_step->setTemplate($template); |
|
249 | 249 | |
250 | - return $subsections; |
|
251 | - } |
|
250 | + return $subsections; |
|
251 | + } |
|
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * @param EE_Form_Section_Proper $extra_inputs_section |
|
256 | - * @throws EE_Error |
|
257 | - */ |
|
258 | - private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
|
259 | - { |
|
260 | - // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
261 | - if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
262 | - $extra_inputs_section->add_subsections( |
|
263 | - [ |
|
264 | - 'consent_box' => new EE_Form_Section_Proper( |
|
265 | - [ |
|
266 | - 'layout_strategy' => |
|
267 | - new EE_Template_Layout( |
|
268 | - [ |
|
269 | - 'input_template_file' => SPCO_REG_STEPS_PATH |
|
270 | - . $this->reg_step->slug() |
|
271 | - . '/privacy_consent.template.php', |
|
272 | - ] |
|
273 | - ), |
|
274 | - 'subsections' => [ |
|
275 | - 'consent' => new EE_Checkbox_Multi_Input( |
|
276 | - [ |
|
277 | - 'consent' => $this->reg_config->getConsentCheckboxLabelText(), |
|
278 | - ], |
|
279 | - [ |
|
280 | - 'required' => true, |
|
281 | - 'required_validation_error_message' => esc_html__( |
|
282 | - 'You must consent to these terms in order to register.', |
|
283 | - 'event_espresso' |
|
284 | - ), |
|
285 | - 'html_label_text' => '', |
|
286 | - ] |
|
287 | - ), |
|
288 | - ], |
|
289 | - ] |
|
290 | - ), |
|
291 | - ], |
|
292 | - null, |
|
293 | - false |
|
294 | - ); |
|
295 | - } |
|
296 | - } |
|
254 | + /** |
|
255 | + * @param EE_Form_Section_Proper $extra_inputs_section |
|
256 | + * @throws EE_Error |
|
257 | + */ |
|
258 | + private function addPrivacyConsentCheckbox(EE_Form_Section_Proper $extra_inputs_section) |
|
259 | + { |
|
260 | + // if this isn't a revisit, and they have the privacy consent box enabled, add it |
|
261 | + if (! $this->reg_step->checkout->revisit && $this->reg_config->isConsentCheckboxEnabled()) { |
|
262 | + $extra_inputs_section->add_subsections( |
|
263 | + [ |
|
264 | + 'consent_box' => new EE_Form_Section_Proper( |
|
265 | + [ |
|
266 | + 'layout_strategy' => |
|
267 | + new EE_Template_Layout( |
|
268 | + [ |
|
269 | + 'input_template_file' => SPCO_REG_STEPS_PATH |
|
270 | + . $this->reg_step->slug() |
|
271 | + . '/privacy_consent.template.php', |
|
272 | + ] |
|
273 | + ), |
|
274 | + 'subsections' => [ |
|
275 | + 'consent' => new EE_Checkbox_Multi_Input( |
|
276 | + [ |
|
277 | + 'consent' => $this->reg_config->getConsentCheckboxLabelText(), |
|
278 | + ], |
|
279 | + [ |
|
280 | + 'required' => true, |
|
281 | + 'required_validation_error_message' => esc_html__( |
|
282 | + 'You must consent to these terms in order to register.', |
|
283 | + 'event_espresso' |
|
284 | + ), |
|
285 | + 'html_label_text' => '', |
|
286 | + ] |
|
287 | + ), |
|
288 | + ], |
|
289 | + ] |
|
290 | + ), |
|
291 | + ], |
|
292 | + null, |
|
293 | + false |
|
294 | + ); |
|
295 | + } |
|
296 | + } |
|
297 | 297 | } |
@@ -12,76 +12,76 @@ |
||
12 | 12 | |
13 | 13 | class CopyAttendeeInfoForm extends EE_Form_Section_Proper |
14 | 14 | { |
15 | - /** |
|
16 | - * CopyAttendeeInfoForm constructor. |
|
17 | - * |
|
18 | - * @param EE_Registration[] $registrations |
|
19 | - * @param string $slug |
|
20 | - * @throws EE_Error |
|
21 | - * @throws ReflectionException |
|
22 | - */ |
|
23 | - public function __construct(array $registrations, string $slug) |
|
24 | - { |
|
25 | - parent::__construct( |
|
26 | - [ |
|
27 | - 'subsections' => $this->copyAttendeeInfoInputs($registrations), |
|
28 | - 'layout_strategy' => new EE_Template_Layout( |
|
29 | - [ |
|
30 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
31 | - . $slug |
|
32 | - . '/copy_attendee_info.template.php', |
|
33 | - 'begin_template_file' => null, |
|
34 | - 'input_template_file' => null, |
|
35 | - 'subsection_template_file' => null, |
|
36 | - 'end_template_file' => null, |
|
37 | - ] |
|
38 | - ), |
|
39 | - ]); |
|
40 | - } |
|
15 | + /** |
|
16 | + * CopyAttendeeInfoForm constructor. |
|
17 | + * |
|
18 | + * @param EE_Registration[] $registrations |
|
19 | + * @param string $slug |
|
20 | + * @throws EE_Error |
|
21 | + * @throws ReflectionException |
|
22 | + */ |
|
23 | + public function __construct(array $registrations, string $slug) |
|
24 | + { |
|
25 | + parent::__construct( |
|
26 | + [ |
|
27 | + 'subsections' => $this->copyAttendeeInfoInputs($registrations), |
|
28 | + 'layout_strategy' => new EE_Template_Layout( |
|
29 | + [ |
|
30 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
31 | + . $slug |
|
32 | + . '/copy_attendee_info.template.php', |
|
33 | + 'begin_template_file' => null, |
|
34 | + 'input_template_file' => null, |
|
35 | + 'subsection_template_file' => null, |
|
36 | + 'end_template_file' => null, |
|
37 | + ] |
|
38 | + ), |
|
39 | + ]); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param array $registrations |
|
45 | - * @return array |
|
46 | - * @throws EE_Error |
|
47 | - * @throws ReflectionException |
|
48 | - */ |
|
49 | - private function copyAttendeeInfoInputs(array $registrations): array |
|
50 | - { |
|
51 | - $copy_attendee_info_inputs = []; |
|
52 | - $prev_ticket = null; |
|
53 | - foreach ($registrations as $registration) { |
|
54 | - // for all attendees other than the primary attendee |
|
55 | - if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
56 | - // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
57 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
58 | - $item_name = $registration->ticket()->name(); |
|
59 | - $item_name .= $registration->ticket()->description() !== '' |
|
60 | - ? ' - ' . $registration->ticket()->description() |
|
61 | - : ''; |
|
62 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] |
|
63 | - = new EE_Form_Section_HTML( |
|
64 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
65 | - ); |
|
66 | - $prev_ticket = $registration->ticket()->ID(); |
|
67 | - } |
|
43 | + /** |
|
44 | + * @param array $registrations |
|
45 | + * @return array |
|
46 | + * @throws EE_Error |
|
47 | + * @throws ReflectionException |
|
48 | + */ |
|
49 | + private function copyAttendeeInfoInputs(array $registrations): array |
|
50 | + { |
|
51 | + $copy_attendee_info_inputs = []; |
|
52 | + $prev_ticket = null; |
|
53 | + foreach ($registrations as $registration) { |
|
54 | + // for all attendees other than the primary attendee |
|
55 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
56 | + // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
57 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
58 | + $item_name = $registration->ticket()->name(); |
|
59 | + $item_name .= $registration->ticket()->description() !== '' |
|
60 | + ? ' - ' . $registration->ticket()->description() |
|
61 | + : ''; |
|
62 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] |
|
63 | + = new EE_Form_Section_HTML( |
|
64 | + '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
65 | + ); |
|
66 | + $prev_ticket = $registration->ticket()->ID(); |
|
67 | + } |
|
68 | 68 | |
69 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] |
|
70 | - = new EE_Checkbox_Multi_Input( |
|
71 | - [ |
|
72 | - $registration->ID() => sprintf( |
|
73 | - esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
74 | - $registration->count() |
|
75 | - ), |
|
76 | - ], |
|
77 | - [ |
|
78 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
79 | - 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
80 | - 'display_html_label_text' => false, |
|
81 | - ] |
|
82 | - ); |
|
83 | - } |
|
84 | - } |
|
85 | - return $copy_attendee_info_inputs; |
|
86 | - } |
|
69 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] |
|
70 | + = new EE_Checkbox_Multi_Input( |
|
71 | + [ |
|
72 | + $registration->ID() => sprintf( |
|
73 | + esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
74 | + $registration->count() |
|
75 | + ), |
|
76 | + ], |
|
77 | + [ |
|
78 | + 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
79 | + 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
80 | + 'display_html_label_text' => false, |
|
81 | + ] |
|
82 | + ); |
|
83 | + } |
|
84 | + } |
|
85 | + return $copy_attendee_info_inputs; |
|
86 | + } |
|
87 | 87 | } |
@@ -71,71 +71,71 @@ |
||
71 | 71 | class LoaderFactory |
72 | 72 | { |
73 | 73 | |
74 | - /** |
|
75 | - * @var LoaderInterface $loader ; |
|
76 | - */ |
|
77 | - private static $loader; |
|
74 | + /** |
|
75 | + * @var LoaderInterface $loader ; |
|
76 | + */ |
|
77 | + private static $loader; |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @param EE_Registry|CoffeeShop $generator provided during very first instantiation in |
|
82 | - * BootstrapDependencyInjectionContainer::buildLoader() |
|
83 | - * otherwise can be left null |
|
84 | - * @param ClassInterfaceCache|null $class_cache also provided during first instantiation |
|
85 | - * @param ObjectIdentifier|null $object_identifier |
|
86 | - * @return LoaderInterface |
|
87 | - * @throws InvalidArgumentException |
|
88 | - * @throws InvalidDataTypeException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - */ |
|
91 | - public static function getLoader( |
|
92 | - $generator = null, |
|
93 | - ClassInterfaceCache $class_cache = null, |
|
94 | - ObjectIdentifier $object_identifier = null |
|
95 | - ): LoaderInterface { |
|
96 | - if ( |
|
97 | - ! LoaderFactory::$loader instanceof LoaderInterface |
|
98 | - && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop) |
|
99 | - && $class_cache instanceof ClassInterfaceCache |
|
100 | - && $object_identifier instanceof ObjectIdentifier |
|
101 | - ) { |
|
102 | - $core_loader = new CoreLoader($generator); |
|
103 | - LoaderFactory::$loader = new Loader( |
|
104 | - $core_loader, |
|
105 | - new CachingLoader( |
|
106 | - $core_loader, |
|
107 | - new LooseCollection(''), |
|
108 | - $object_identifier |
|
109 | - ), |
|
110 | - $class_cache |
|
111 | - ); |
|
112 | - } |
|
113 | - return LoaderFactory::$loader; |
|
114 | - } |
|
80 | + /** |
|
81 | + * @param EE_Registry|CoffeeShop $generator provided during very first instantiation in |
|
82 | + * BootstrapDependencyInjectionContainer::buildLoader() |
|
83 | + * otherwise can be left null |
|
84 | + * @param ClassInterfaceCache|null $class_cache also provided during first instantiation |
|
85 | + * @param ObjectIdentifier|null $object_identifier |
|
86 | + * @return LoaderInterface |
|
87 | + * @throws InvalidArgumentException |
|
88 | + * @throws InvalidDataTypeException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + */ |
|
91 | + public static function getLoader( |
|
92 | + $generator = null, |
|
93 | + ClassInterfaceCache $class_cache = null, |
|
94 | + ObjectIdentifier $object_identifier = null |
|
95 | + ): LoaderInterface { |
|
96 | + if ( |
|
97 | + ! LoaderFactory::$loader instanceof LoaderInterface |
|
98 | + && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop) |
|
99 | + && $class_cache instanceof ClassInterfaceCache |
|
100 | + && $object_identifier instanceof ObjectIdentifier |
|
101 | + ) { |
|
102 | + $core_loader = new CoreLoader($generator); |
|
103 | + LoaderFactory::$loader = new Loader( |
|
104 | + $core_loader, |
|
105 | + new CachingLoader( |
|
106 | + $core_loader, |
|
107 | + new LooseCollection(''), |
|
108 | + $object_identifier |
|
109 | + ), |
|
110 | + $class_cache |
|
111 | + ); |
|
112 | + } |
|
113 | + return LoaderFactory::$loader; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * Used for instantiating a new instance of a class |
|
119 | - * |
|
120 | - * @param FullyQualifiedName|string $fqcn |
|
121 | - * @param array $arguments |
|
122 | - * @return mixed |
|
123 | - */ |
|
124 | - public static function getNew($fqcn, array $arguments = []) |
|
125 | - { |
|
126 | - return LoaderFactory::getLoader()->getNew($fqcn, $arguments); |
|
127 | - } |
|
117 | + /** |
|
118 | + * Used for instantiating a new instance of a class |
|
119 | + * |
|
120 | + * @param FullyQualifiedName|string $fqcn |
|
121 | + * @param array $arguments |
|
122 | + * @return mixed |
|
123 | + */ |
|
124 | + public static function getNew($fqcn, array $arguments = []) |
|
125 | + { |
|
126 | + return LoaderFactory::getLoader()->getNew($fqcn, $arguments); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Used for getting a shared instance of a class |
|
132 | - * |
|
133 | - * @param FullyQualifiedName|string $fqcn |
|
134 | - * @param array $arguments |
|
135 | - * @return mixed |
|
136 | - */ |
|
137 | - public static function getShared($fqcn, array $arguments = []) |
|
138 | - { |
|
139 | - return LoaderFactory::getLoader()->getShared($fqcn, $arguments); |
|
140 | - } |
|
130 | + /** |
|
131 | + * Used for getting a shared instance of a class |
|
132 | + * |
|
133 | + * @param FullyQualifiedName|string $fqcn |
|
134 | + * @param array $arguments |
|
135 | + * @return mixed |
|
136 | + */ |
|
137 | + public static function getShared($fqcn, array $arguments = []) |
|
138 | + { |
|
139 | + return LoaderFactory::getLoader()->getShared($fqcn, $arguments); |
|
140 | + } |
|
141 | 141 | } |
@@ -22,932 +22,932 @@ |
||
22 | 22 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - private $_print_copy_info = false; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - private $_attendee_data = array(); |
|
34 | - |
|
35 | - /** |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - private $_required_questions = array(); |
|
39 | - |
|
40 | - /** |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - private $_registration_answers = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * @var int |
|
47 | - */ |
|
48 | - protected $reg_form_count = 0; |
|
49 | - |
|
50 | - /** |
|
51 | - * class constructor |
|
52 | - * |
|
53 | - * @access public |
|
54 | - * @param EE_Checkout $checkout |
|
55 | - */ |
|
56 | - public function __construct(EE_Checkout $checkout) |
|
57 | - { |
|
58 | - $this->_slug = 'attendee_information'; |
|
59 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
60 | - $this->checkout = $checkout; |
|
61 | - $this->_reset_success_message(); |
|
62 | - $this->set_instructions( |
|
63 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - public function translate_js_strings() |
|
69 | - { |
|
70 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
71 | - ' is a required question.', |
|
72 | - 'event_espresso' |
|
73 | - ); |
|
74 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
75 | - ' is a required question. Please enter a value for at least one of the options.', |
|
76 | - 'event_espresso' |
|
77 | - ); |
|
78 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
79 | - 'Please answer all required questions correctly before proceeding.', |
|
80 | - 'event_espresso' |
|
81 | - ); |
|
82 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
83 | - esc_html_x( |
|
84 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
85 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - '<br/>' |
|
89 | - ); |
|
90 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
91 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
92 | - 'event_espresso' |
|
93 | - ); |
|
94 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
95 | - 'You must enter a valid email address.', |
|
96 | - 'event_espresso' |
|
97 | - ); |
|
98 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
99 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
100 | - 'event_espresso' |
|
101 | - ); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - public function enqueue_styles_and_scripts() |
|
106 | - { |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return boolean |
|
112 | - */ |
|
113 | - public function initialize_reg_step(): bool |
|
114 | - { |
|
115 | - return true; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return RegForm |
|
121 | - * @throws DomainException |
|
122 | - * @throws InvalidArgumentException |
|
123 | - * @throws EntityNotFoundException |
|
124 | - * @throws InvalidDataTypeException |
|
125 | - * @throws InvalidInterfaceException |
|
126 | - */ |
|
127 | - public function generate_reg_form(): RegForm |
|
128 | - { |
|
129 | - // TODO detect if event has a reg form UUID and swap this out for new reg form builder generated form |
|
130 | - return LoaderFactory::getShared(RegForm::class, [$this]); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * looking for hooks? |
|
136 | - * this method has been replaced by: |
|
137 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
138 | - * |
|
139 | - * @deprecated $VID:$ |
|
140 | - */ |
|
141 | - private function _registrations_reg_form() |
|
142 | - { |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * looking for hooks? |
|
148 | - * this method has been replaced by: |
|
149 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
150 | - * |
|
151 | - * @deprecated $VID:$ |
|
152 | - */ |
|
153 | - private function _additional_attendee_reg_info_input() { |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * looking for hooks? |
|
159 | - * this method has been replaced by: |
|
160 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
161 | - * |
|
162 | - * @deprecated $VID:$ |
|
163 | - */ |
|
164 | - private function _question_group_reg_form() |
|
165 | - { |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * looking for hooks? |
|
171 | - * this method has been replaced by: |
|
172 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
173 | - * |
|
174 | - * @deprecated $VID:$ |
|
175 | - */ |
|
176 | - private function _question_group_header() |
|
177 | - { |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * looking for hooks? |
|
183 | - * this method has been replaced by: |
|
184 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
185 | - * |
|
186 | - * @deprecated $VID:$ |
|
187 | - */ |
|
188 | - private function _copy_attendee_info_form() |
|
189 | - { |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * looking for hooks? |
|
195 | - * this method has been replaced by: |
|
196 | - * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
197 | - * |
|
198 | - * @deprecated $VID:$ |
|
199 | - */ |
|
200 | - private function _auto_copy_attendee_info() |
|
201 | - { |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * looking for hooks? |
|
207 | - * this method has been replaced by: |
|
208 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
209 | - * |
|
210 | - * @deprecated $VID:$ |
|
211 | - */ |
|
212 | - private function _copy_attendee_info_inputs() |
|
213 | - { |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * looking for hooks? |
|
219 | - * this method has been replaced by: |
|
220 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
221 | - * |
|
222 | - * @deprecated $VID:$ |
|
223 | - */ |
|
224 | - private function _additional_primary_registrant_inputs() |
|
225 | - { |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * looking for hooks? |
|
231 | - * this method has been replaced by: |
|
232 | - * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
233 | - * |
|
234 | - * @param EE_Registration $registration |
|
235 | - * @param EE_Question $question |
|
236 | - * @return EE_Form_Input_Base |
|
237 | - * @throws EE_Error |
|
238 | - * @throws ReflectionException |
|
239 | - * @deprecated $VID:$ |
|
240 | - */ |
|
241 | - public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
242 | - { |
|
243 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
244 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
245 | - return $reg_form_question_factory->create($registration, $question); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * looking for hooks? |
|
251 | - * this method has been replaced by: |
|
252 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
253 | - * |
|
254 | - * @deprecated $VID:$ |
|
255 | - */ |
|
256 | - private function _generate_question_input() |
|
257 | - { |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * looking for hooks? |
|
263 | - * this method has been replaced by: |
|
264 | - * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
265 | - * |
|
266 | - * @param array|null $countries_list |
|
267 | - * @param EE_Question|null $question |
|
268 | - * @param EE_Registration|null $registration |
|
269 | - * @param EE_Answer|null $answer |
|
270 | - * @return array 2d keys are country IDs, values are their names |
|
271 | - * @throws EE_Error |
|
272 | - * @throws ReflectionException |
|
273 | - * @deprecated $VID:$ |
|
274 | - */ |
|
275 | - public function use_cached_countries_for_form_input( |
|
276 | - array $countries_list = null, |
|
277 | - EE_Question $question = null, |
|
278 | - EE_Registration $registration = null, |
|
279 | - EE_Answer $answer = null |
|
280 | - ): array { |
|
281 | - /** @var CountryOptions $country_options */ |
|
282 | - $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
283 | - return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * looking for hooks? |
|
289 | - * this method has been replaced by: |
|
290 | - * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
291 | - * |
|
292 | - * @param array|null $states_list |
|
293 | - * @param EE_Question|null $question |
|
294 | - * @param EE_Registration|null $registration |
|
295 | - * @param EE_Answer|null $answer |
|
296 | - * @return array 2d keys are state IDs, values are their names |
|
297 | - * @throws EE_Error |
|
298 | - * @throws ReflectionException |
|
299 | - * @deprecated $VID:$ |
|
300 | - */ |
|
301 | - public function use_cached_states_for_form_input( |
|
302 | - array $states_list = null, |
|
303 | - EE_Question $question = null, |
|
304 | - EE_Registration $registration = null, |
|
305 | - EE_Answer $answer = null |
|
306 | - ): array { |
|
307 | - /** @var StateOptions $state_options */ |
|
308 | - $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
309 | - return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /********************************************************************************************************/ |
|
314 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
315 | - /********************************************************************************************************/ |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * @return bool |
|
320 | - * @throws EE_Error |
|
321 | - * @throws InvalidArgumentException |
|
322 | - * @throws ReflectionException |
|
323 | - * @throws RuntimeException |
|
324 | - * @throws InvalidDataTypeException |
|
325 | - * @throws InvalidInterfaceException |
|
326 | - */ |
|
327 | - public function process_reg_step() |
|
328 | - { |
|
329 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
330 | - // grab validated data from form |
|
331 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
332 | - // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
333 | - // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
334 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
335 | - if (empty($valid_data)) { |
|
336 | - EE_Error::add_error( |
|
337 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
338 | - __FILE__, |
|
339 | - __FUNCTION__, |
|
340 | - __LINE__ |
|
341 | - ); |
|
342 | - return false; |
|
343 | - } |
|
344 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
345 | - EE_Error::add_error( |
|
346 | - esc_html__( |
|
347 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
348 | - 'event_espresso' |
|
349 | - ), |
|
350 | - __FILE__, |
|
351 | - __FUNCTION__, |
|
352 | - __LINE__ |
|
353 | - ); |
|
354 | - return false; |
|
355 | - } |
|
356 | - // get cached registrations |
|
357 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
358 | - // verify we got the goods |
|
359 | - if (empty($registrations)) { |
|
360 | - // combine the old translated string with a new one, in order to not break translations |
|
361 | - $error_message = esc_html__( |
|
362 | - 'Your form data could not be applied to any valid registrations.', |
|
363 | - 'event_espresso' |
|
364 | - ) |
|
365 | - . sprintf( |
|
366 | - esc_html_x( |
|
367 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
368 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
369 | - 'event_espresso' |
|
370 | - ), |
|
371 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
372 | - '</a>', |
|
373 | - '<br />' |
|
374 | - ); |
|
375 | - EE_Error::add_error( |
|
376 | - $error_message, |
|
377 | - __FILE__, |
|
378 | - __FUNCTION__, |
|
379 | - __LINE__ |
|
380 | - ); |
|
381 | - return false; |
|
382 | - } |
|
383 | - // extract attendee info from form data and save to model objects |
|
384 | - $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
385 | - // if first pass thru SPCO, |
|
386 | - // then let's check processed registrations against the total number of tickets in the cart |
|
387 | - if ($registrations_processed === false) { |
|
388 | - // but return immediately if the previous step exited early due to errors |
|
389 | - return false; |
|
390 | - } |
|
391 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
392 | - // generate a correctly translated string for all possible singular/plural combinations |
|
393 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
394 | - $error_msg = sprintf( |
|
395 | - esc_html_x( |
|
396 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
397 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
398 | - 'event_espresso' |
|
399 | - ), |
|
400 | - $this->checkout->total_ticket_count, |
|
401 | - $registrations_processed |
|
402 | - ); |
|
403 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
404 | - $error_msg = sprintf( |
|
405 | - esc_html_x( |
|
406 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
407 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
408 | - 'event_espresso' |
|
409 | - ), |
|
410 | - $this->checkout->total_ticket_count, |
|
411 | - $registrations_processed |
|
412 | - ); |
|
413 | - } else { |
|
414 | - $error_msg = sprintf( |
|
415 | - esc_html__( |
|
416 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
417 | - 'event_espresso' |
|
418 | - ), |
|
419 | - $this->checkout->total_ticket_count, |
|
420 | - $registrations_processed |
|
421 | - ); |
|
422 | - } |
|
423 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
424 | - return false; |
|
425 | - } |
|
426 | - // mark this reg step as completed |
|
427 | - $this->set_completed(); |
|
428 | - $this->_set_success_message( |
|
429 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
430 | - ); |
|
431 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
432 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
433 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
434 | - return true; |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * _process_registrations |
|
440 | - * |
|
441 | - * @param EE_Registration[] $registrations |
|
442 | - * @param array[][] $valid_data |
|
443 | - * @return bool|int |
|
444 | - * @throws EntityNotFoundException |
|
445 | - * @throws EE_Error |
|
446 | - * @throws InvalidArgumentException |
|
447 | - * @throws ReflectionException |
|
448 | - * @throws RuntimeException |
|
449 | - * @throws InvalidDataTypeException |
|
450 | - * @throws InvalidInterfaceException |
|
451 | - */ |
|
452 | - private function _process_registrations($registrations = array(), $valid_data = array()) |
|
453 | - { |
|
454 | - // load resources and set some defaults |
|
455 | - EE_Registry::instance()->load_model('Attendee'); |
|
456 | - // holder for primary registrant attendee object |
|
457 | - $this->checkout->primary_attendee_obj = null; |
|
458 | - // array for tracking reg form data for the primary registrant |
|
459 | - $primary_registrant = array( |
|
460 | - 'line_item_id' => null, |
|
461 | - ); |
|
462 | - $copy_primary = false; |
|
463 | - // reg form sections that do not contain inputs |
|
464 | - $non_input_form_sections = array( |
|
465 | - 'primary_registrant', |
|
466 | - 'additional_attendee_reg_info', |
|
467 | - 'spco_copy_attendee_chk', |
|
468 | - ); |
|
469 | - // attendee counter |
|
470 | - $att_nmbr = 0; |
|
471 | - // grab the saved registrations from the transaction |
|
472 | - foreach ($registrations as $registration) { |
|
473 | - // verify EE_Registration object |
|
474 | - if (! $registration instanceof EE_Registration) { |
|
475 | - EE_Error::add_error( |
|
476 | - esc_html__( |
|
477 | - 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
478 | - 'event_espresso' |
|
479 | - ), |
|
480 | - __FILE__, |
|
481 | - __FUNCTION__, |
|
482 | - __LINE__ |
|
483 | - ); |
|
484 | - return false; |
|
485 | - } |
|
486 | - /** @var string $reg_url_link */ |
|
487 | - $reg_url_link = $registration->reg_url_link(); |
|
488 | - // reg_url_link exists ? |
|
489 | - if (! empty($reg_url_link)) { |
|
490 | - // should this registration be processed during this visit ? |
|
491 | - if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
492 | - // if NOT revisiting, then let's save the registration now, |
|
493 | - // so that we have a REG_ID to use when generating other objects |
|
494 | - if (! $this->checkout->revisit) { |
|
495 | - $registration->save(); |
|
496 | - } |
|
497 | - /** |
|
498 | - * This allows plugins to trigger a fail on processing of a |
|
499 | - * registration for any conditions they may have for it to pass. |
|
500 | - * |
|
501 | - * @var bool if true is returned by the plugin then the |
|
502 | - * registration processing is halted. |
|
503 | - */ |
|
504 | - if ( |
|
505 | - apply_filters( |
|
506 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
507 | - false, |
|
508 | - $att_nmbr, |
|
509 | - $registration, |
|
510 | - $registrations, |
|
511 | - $valid_data, |
|
512 | - $this |
|
513 | - ) |
|
514 | - ) { |
|
515 | - return false; |
|
516 | - } |
|
517 | - |
|
518 | - // Houston, we have a registration! |
|
519 | - $att_nmbr++; |
|
520 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
521 | - // grab any existing related answer objects |
|
522 | - $this->_registration_answers = $registration->answers(); |
|
523 | - // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
524 | - if (isset($valid_data[ $reg_url_link ])) { |
|
525 | - // do we need to copy basic info from primary attendee ? |
|
526 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
527 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
528 | - // filter form input data for this registration |
|
529 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
530 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
531 | - $valid_data[ $reg_url_link ] |
|
532 | - ); |
|
533 | - if (isset($valid_data['primary_attendee'])) { |
|
534 | - $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
535 | - ? $valid_data['primary_attendee'] |
|
536 | - : false; |
|
537 | - unset($valid_data['primary_attendee']); |
|
538 | - } |
|
539 | - // now loop through our array of valid post data && process attendee reg forms |
|
540 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
541 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
542 | - foreach ($form_inputs as $form_input => $input_value) { |
|
543 | - // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
544 | - // check for critical inputs |
|
545 | - if ( |
|
546 | - ! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
547 | - $form_input, |
|
548 | - $input_value |
|
549 | - ) |
|
550 | - ) { |
|
551 | - return false; |
|
552 | - } |
|
553 | - // store a bit of data about the primary attendee |
|
554 | - if ( |
|
555 | - $att_nmbr === 1 |
|
556 | - && ! empty($input_value) |
|
557 | - && $reg_url_link === $primary_registrant['line_item_id'] |
|
558 | - ) { |
|
559 | - $primary_registrant[ $form_input ] = $input_value; |
|
560 | - } elseif ( |
|
561 | - $copy_primary |
|
562 | - && $input_value === null |
|
563 | - && isset($primary_registrant[ $form_input ]) |
|
564 | - ) { |
|
565 | - $input_value = $primary_registrant[ $form_input ]; |
|
566 | - } |
|
567 | - // now attempt to save the input data |
|
568 | - if ( |
|
569 | - ! $this->_save_registration_form_input( |
|
570 | - $registration, |
|
571 | - $form_input, |
|
572 | - $input_value |
|
573 | - ) |
|
574 | - ) { |
|
575 | - EE_Error::add_error( |
|
576 | - sprintf( |
|
577 | - esc_html_x( |
|
578 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
579 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
580 | - 'event_espresso' |
|
581 | - ), |
|
582 | - $form_input, |
|
583 | - $input_value |
|
584 | - ), |
|
585 | - __FILE__, |
|
586 | - __FUNCTION__, |
|
587 | - __LINE__ |
|
588 | - ); |
|
589 | - return false; |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
594 | - } |
|
595 | - // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
596 | - // this registration does not require additional attendee information ? |
|
597 | - if ( |
|
598 | - $copy_primary |
|
599 | - && $att_nmbr > 1 |
|
600 | - && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
601 | - ) { |
|
602 | - // just copy the primary registrant |
|
603 | - $attendee = $this->checkout->primary_attendee_obj; |
|
604 | - } else { |
|
605 | - // ensure critical details are set for additional attendees |
|
606 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
607 | - ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
608 | - $this->_attendee_data[ $reg_url_link ] |
|
609 | - ) |
|
610 | - : $this->_attendee_data[ $reg_url_link ]; |
|
611 | - // execute create attendee command (which may return an existing attendee) |
|
612 | - $attendee = EE_Registry::instance()->BUS->execute( |
|
613 | - new CreateAttendeeCommand( |
|
614 | - $this->_attendee_data[ $reg_url_link ], |
|
615 | - $registration |
|
616 | - ) |
|
617 | - ); |
|
618 | - // who's #1 ? |
|
619 | - if ($att_nmbr === 1) { |
|
620 | - $this->checkout->primary_attendee_obj = $attendee; |
|
621 | - } |
|
622 | - } |
|
623 | - // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
624 | - // add relation to registration, set attendee ID, and cache attendee |
|
625 | - $this->_associate_attendee_with_registration($registration, $attendee); |
|
626 | - // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
627 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
628 | - EE_Error::add_error( |
|
629 | - sprintf( |
|
630 | - esc_html_x( |
|
631 | - 'Registration %s has an invalid or missing Attendee object.', |
|
632 | - 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
633 | - 'event_espresso' |
|
634 | - ), |
|
635 | - $reg_url_link |
|
636 | - ), |
|
637 | - __FILE__, |
|
638 | - __FUNCTION__, |
|
639 | - __LINE__ |
|
640 | - ); |
|
641 | - return false; |
|
642 | - } |
|
643 | - /** @type EE_Registration_Processor $registration_processor */ |
|
644 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
645 | - // at this point, we should have enough details about the registrant to consider the registration |
|
646 | - // NOT incomplete |
|
647 | - $registration_processor->toggle_incomplete_registration_status_to_default( |
|
648 | - $registration, |
|
649 | - false, |
|
650 | - new Context( |
|
651 | - 'spco_reg_step_attendee_information_process_registrations', |
|
652 | - esc_html__( |
|
653 | - 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
654 | - 'event_espresso' |
|
655 | - ) |
|
656 | - ) |
|
657 | - ); |
|
658 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
659 | - // abandoned |
|
660 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
661 | - // if we've gotten this far, then let's save what we have |
|
662 | - $registration->save(); |
|
663 | - // add relation between TXN and registration |
|
664 | - $this->_associate_registration_with_transaction($registration); |
|
665 | - } |
|
666 | - } else { |
|
667 | - EE_Error::add_error( |
|
668 | - esc_html__( |
|
669 | - 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
670 | - 'event_espresso' |
|
671 | - ), |
|
672 | - __FILE__, |
|
673 | - __FUNCTION__, |
|
674 | - __LINE__ |
|
675 | - ); |
|
676 | - // remove malformed data |
|
677 | - unset($valid_data[ $reg_url_link ]); |
|
678 | - return false; |
|
679 | - } |
|
680 | - } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
681 | - return $att_nmbr; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * _save_registration_form_input |
|
687 | - * |
|
688 | - * @param EE_Registration $registration |
|
689 | - * @param string $form_input |
|
690 | - * @param string $input_value |
|
691 | - * @return bool |
|
692 | - * @throws EE_Error |
|
693 | - * @throws InvalidArgumentException |
|
694 | - * @throws InvalidDataTypeException |
|
695 | - * @throws InvalidInterfaceException |
|
696 | - * @throws ReflectionException |
|
697 | - */ |
|
698 | - private function _save_registration_form_input( |
|
699 | - EE_Registration $registration, |
|
700 | - $form_input = '', |
|
701 | - $input_value = '' |
|
702 | - ) { |
|
703 | - // If email_confirm is sent it's not saved |
|
704 | - if ((string) $form_input === 'email_confirm') { |
|
705 | - return true; |
|
706 | - } |
|
707 | - |
|
708 | - // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
709 | - // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
710 | - // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
711 | - // allow for plugins to hook in and do their own processing of the form input. |
|
712 | - // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
713 | - if ( |
|
714 | - apply_filters( |
|
715 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
716 | - false, |
|
717 | - $registration, |
|
718 | - $form_input, |
|
719 | - $input_value, |
|
720 | - $this |
|
721 | - ) |
|
722 | - ) { |
|
723 | - return true; |
|
724 | - } |
|
725 | - /* |
|
25 | + /** |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + private $_print_copy_info = false; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + private $_attendee_data = array(); |
|
34 | + |
|
35 | + /** |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + private $_required_questions = array(); |
|
39 | + |
|
40 | + /** |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + private $_registration_answers = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * @var int |
|
47 | + */ |
|
48 | + protected $reg_form_count = 0; |
|
49 | + |
|
50 | + /** |
|
51 | + * class constructor |
|
52 | + * |
|
53 | + * @access public |
|
54 | + * @param EE_Checkout $checkout |
|
55 | + */ |
|
56 | + public function __construct(EE_Checkout $checkout) |
|
57 | + { |
|
58 | + $this->_slug = 'attendee_information'; |
|
59 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
60 | + $this->checkout = $checkout; |
|
61 | + $this->_reset_success_message(); |
|
62 | + $this->set_instructions( |
|
63 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + public function translate_js_strings() |
|
69 | + { |
|
70 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
71 | + ' is a required question.', |
|
72 | + 'event_espresso' |
|
73 | + ); |
|
74 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
75 | + ' is a required question. Please enter a value for at least one of the options.', |
|
76 | + 'event_espresso' |
|
77 | + ); |
|
78 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
79 | + 'Please answer all required questions correctly before proceeding.', |
|
80 | + 'event_espresso' |
|
81 | + ); |
|
82 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
83 | + esc_html_x( |
|
84 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
85 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + '<br/>' |
|
89 | + ); |
|
90 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
91 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
92 | + 'event_espresso' |
|
93 | + ); |
|
94 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
95 | + 'You must enter a valid email address.', |
|
96 | + 'event_espresso' |
|
97 | + ); |
|
98 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
99 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
100 | + 'event_espresso' |
|
101 | + ); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + public function enqueue_styles_and_scripts() |
|
106 | + { |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return boolean |
|
112 | + */ |
|
113 | + public function initialize_reg_step(): bool |
|
114 | + { |
|
115 | + return true; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return RegForm |
|
121 | + * @throws DomainException |
|
122 | + * @throws InvalidArgumentException |
|
123 | + * @throws EntityNotFoundException |
|
124 | + * @throws InvalidDataTypeException |
|
125 | + * @throws InvalidInterfaceException |
|
126 | + */ |
|
127 | + public function generate_reg_form(): RegForm |
|
128 | + { |
|
129 | + // TODO detect if event has a reg form UUID and swap this out for new reg form builder generated form |
|
130 | + return LoaderFactory::getShared(RegForm::class, [$this]); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * looking for hooks? |
|
136 | + * this method has been replaced by: |
|
137 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
138 | + * |
|
139 | + * @deprecated $VID:$ |
|
140 | + */ |
|
141 | + private function _registrations_reg_form() |
|
142 | + { |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * looking for hooks? |
|
148 | + * this method has been replaced by: |
|
149 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
150 | + * |
|
151 | + * @deprecated $VID:$ |
|
152 | + */ |
|
153 | + private function _additional_attendee_reg_info_input() { |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * looking for hooks? |
|
159 | + * this method has been replaced by: |
|
160 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
161 | + * |
|
162 | + * @deprecated $VID:$ |
|
163 | + */ |
|
164 | + private function _question_group_reg_form() |
|
165 | + { |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * looking for hooks? |
|
171 | + * this method has been replaced by: |
|
172 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
173 | + * |
|
174 | + * @deprecated $VID:$ |
|
175 | + */ |
|
176 | + private function _question_group_header() |
|
177 | + { |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * looking for hooks? |
|
183 | + * this method has been replaced by: |
|
184 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
185 | + * |
|
186 | + * @deprecated $VID:$ |
|
187 | + */ |
|
188 | + private function _copy_attendee_info_form() |
|
189 | + { |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * looking for hooks? |
|
195 | + * this method has been replaced by: |
|
196 | + * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
197 | + * |
|
198 | + * @deprecated $VID:$ |
|
199 | + */ |
|
200 | + private function _auto_copy_attendee_info() |
|
201 | + { |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * looking for hooks? |
|
207 | + * this method has been replaced by: |
|
208 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
209 | + * |
|
210 | + * @deprecated $VID:$ |
|
211 | + */ |
|
212 | + private function _copy_attendee_info_inputs() |
|
213 | + { |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * looking for hooks? |
|
219 | + * this method has been replaced by: |
|
220 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
221 | + * |
|
222 | + * @deprecated $VID:$ |
|
223 | + */ |
|
224 | + private function _additional_primary_registrant_inputs() |
|
225 | + { |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * looking for hooks? |
|
231 | + * this method has been replaced by: |
|
232 | + * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
233 | + * |
|
234 | + * @param EE_Registration $registration |
|
235 | + * @param EE_Question $question |
|
236 | + * @return EE_Form_Input_Base |
|
237 | + * @throws EE_Error |
|
238 | + * @throws ReflectionException |
|
239 | + * @deprecated $VID:$ |
|
240 | + */ |
|
241 | + public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
242 | + { |
|
243 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
244 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
245 | + return $reg_form_question_factory->create($registration, $question); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * looking for hooks? |
|
251 | + * this method has been replaced by: |
|
252 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
253 | + * |
|
254 | + * @deprecated $VID:$ |
|
255 | + */ |
|
256 | + private function _generate_question_input() |
|
257 | + { |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * looking for hooks? |
|
263 | + * this method has been replaced by: |
|
264 | + * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
265 | + * |
|
266 | + * @param array|null $countries_list |
|
267 | + * @param EE_Question|null $question |
|
268 | + * @param EE_Registration|null $registration |
|
269 | + * @param EE_Answer|null $answer |
|
270 | + * @return array 2d keys are country IDs, values are their names |
|
271 | + * @throws EE_Error |
|
272 | + * @throws ReflectionException |
|
273 | + * @deprecated $VID:$ |
|
274 | + */ |
|
275 | + public function use_cached_countries_for_form_input( |
|
276 | + array $countries_list = null, |
|
277 | + EE_Question $question = null, |
|
278 | + EE_Registration $registration = null, |
|
279 | + EE_Answer $answer = null |
|
280 | + ): array { |
|
281 | + /** @var CountryOptions $country_options */ |
|
282 | + $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
283 | + return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * looking for hooks? |
|
289 | + * this method has been replaced by: |
|
290 | + * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
291 | + * |
|
292 | + * @param array|null $states_list |
|
293 | + * @param EE_Question|null $question |
|
294 | + * @param EE_Registration|null $registration |
|
295 | + * @param EE_Answer|null $answer |
|
296 | + * @return array 2d keys are state IDs, values are their names |
|
297 | + * @throws EE_Error |
|
298 | + * @throws ReflectionException |
|
299 | + * @deprecated $VID:$ |
|
300 | + */ |
|
301 | + public function use_cached_states_for_form_input( |
|
302 | + array $states_list = null, |
|
303 | + EE_Question $question = null, |
|
304 | + EE_Registration $registration = null, |
|
305 | + EE_Answer $answer = null |
|
306 | + ): array { |
|
307 | + /** @var StateOptions $state_options */ |
|
308 | + $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
309 | + return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /********************************************************************************************************/ |
|
314 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
315 | + /********************************************************************************************************/ |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * @return bool |
|
320 | + * @throws EE_Error |
|
321 | + * @throws InvalidArgumentException |
|
322 | + * @throws ReflectionException |
|
323 | + * @throws RuntimeException |
|
324 | + * @throws InvalidDataTypeException |
|
325 | + * @throws InvalidInterfaceException |
|
326 | + */ |
|
327 | + public function process_reg_step() |
|
328 | + { |
|
329 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
330 | + // grab validated data from form |
|
331 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
332 | + // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
333 | + // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
334 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
335 | + if (empty($valid_data)) { |
|
336 | + EE_Error::add_error( |
|
337 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
338 | + __FILE__, |
|
339 | + __FUNCTION__, |
|
340 | + __LINE__ |
|
341 | + ); |
|
342 | + return false; |
|
343 | + } |
|
344 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
345 | + EE_Error::add_error( |
|
346 | + esc_html__( |
|
347 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
348 | + 'event_espresso' |
|
349 | + ), |
|
350 | + __FILE__, |
|
351 | + __FUNCTION__, |
|
352 | + __LINE__ |
|
353 | + ); |
|
354 | + return false; |
|
355 | + } |
|
356 | + // get cached registrations |
|
357 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
358 | + // verify we got the goods |
|
359 | + if (empty($registrations)) { |
|
360 | + // combine the old translated string with a new one, in order to not break translations |
|
361 | + $error_message = esc_html__( |
|
362 | + 'Your form data could not be applied to any valid registrations.', |
|
363 | + 'event_espresso' |
|
364 | + ) |
|
365 | + . sprintf( |
|
366 | + esc_html_x( |
|
367 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
368 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
369 | + 'event_espresso' |
|
370 | + ), |
|
371 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
372 | + '</a>', |
|
373 | + '<br />' |
|
374 | + ); |
|
375 | + EE_Error::add_error( |
|
376 | + $error_message, |
|
377 | + __FILE__, |
|
378 | + __FUNCTION__, |
|
379 | + __LINE__ |
|
380 | + ); |
|
381 | + return false; |
|
382 | + } |
|
383 | + // extract attendee info from form data and save to model objects |
|
384 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
385 | + // if first pass thru SPCO, |
|
386 | + // then let's check processed registrations against the total number of tickets in the cart |
|
387 | + if ($registrations_processed === false) { |
|
388 | + // but return immediately if the previous step exited early due to errors |
|
389 | + return false; |
|
390 | + } |
|
391 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
392 | + // generate a correctly translated string for all possible singular/plural combinations |
|
393 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
394 | + $error_msg = sprintf( |
|
395 | + esc_html_x( |
|
396 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
397 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
398 | + 'event_espresso' |
|
399 | + ), |
|
400 | + $this->checkout->total_ticket_count, |
|
401 | + $registrations_processed |
|
402 | + ); |
|
403 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
404 | + $error_msg = sprintf( |
|
405 | + esc_html_x( |
|
406 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
407 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
408 | + 'event_espresso' |
|
409 | + ), |
|
410 | + $this->checkout->total_ticket_count, |
|
411 | + $registrations_processed |
|
412 | + ); |
|
413 | + } else { |
|
414 | + $error_msg = sprintf( |
|
415 | + esc_html__( |
|
416 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
417 | + 'event_espresso' |
|
418 | + ), |
|
419 | + $this->checkout->total_ticket_count, |
|
420 | + $registrations_processed |
|
421 | + ); |
|
422 | + } |
|
423 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
424 | + return false; |
|
425 | + } |
|
426 | + // mark this reg step as completed |
|
427 | + $this->set_completed(); |
|
428 | + $this->_set_success_message( |
|
429 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
430 | + ); |
|
431 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
432 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
433 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
434 | + return true; |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * _process_registrations |
|
440 | + * |
|
441 | + * @param EE_Registration[] $registrations |
|
442 | + * @param array[][] $valid_data |
|
443 | + * @return bool|int |
|
444 | + * @throws EntityNotFoundException |
|
445 | + * @throws EE_Error |
|
446 | + * @throws InvalidArgumentException |
|
447 | + * @throws ReflectionException |
|
448 | + * @throws RuntimeException |
|
449 | + * @throws InvalidDataTypeException |
|
450 | + * @throws InvalidInterfaceException |
|
451 | + */ |
|
452 | + private function _process_registrations($registrations = array(), $valid_data = array()) |
|
453 | + { |
|
454 | + // load resources and set some defaults |
|
455 | + EE_Registry::instance()->load_model('Attendee'); |
|
456 | + // holder for primary registrant attendee object |
|
457 | + $this->checkout->primary_attendee_obj = null; |
|
458 | + // array for tracking reg form data for the primary registrant |
|
459 | + $primary_registrant = array( |
|
460 | + 'line_item_id' => null, |
|
461 | + ); |
|
462 | + $copy_primary = false; |
|
463 | + // reg form sections that do not contain inputs |
|
464 | + $non_input_form_sections = array( |
|
465 | + 'primary_registrant', |
|
466 | + 'additional_attendee_reg_info', |
|
467 | + 'spco_copy_attendee_chk', |
|
468 | + ); |
|
469 | + // attendee counter |
|
470 | + $att_nmbr = 0; |
|
471 | + // grab the saved registrations from the transaction |
|
472 | + foreach ($registrations as $registration) { |
|
473 | + // verify EE_Registration object |
|
474 | + if (! $registration instanceof EE_Registration) { |
|
475 | + EE_Error::add_error( |
|
476 | + esc_html__( |
|
477 | + 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
478 | + 'event_espresso' |
|
479 | + ), |
|
480 | + __FILE__, |
|
481 | + __FUNCTION__, |
|
482 | + __LINE__ |
|
483 | + ); |
|
484 | + return false; |
|
485 | + } |
|
486 | + /** @var string $reg_url_link */ |
|
487 | + $reg_url_link = $registration->reg_url_link(); |
|
488 | + // reg_url_link exists ? |
|
489 | + if (! empty($reg_url_link)) { |
|
490 | + // should this registration be processed during this visit ? |
|
491 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
492 | + // if NOT revisiting, then let's save the registration now, |
|
493 | + // so that we have a REG_ID to use when generating other objects |
|
494 | + if (! $this->checkout->revisit) { |
|
495 | + $registration->save(); |
|
496 | + } |
|
497 | + /** |
|
498 | + * This allows plugins to trigger a fail on processing of a |
|
499 | + * registration for any conditions they may have for it to pass. |
|
500 | + * |
|
501 | + * @var bool if true is returned by the plugin then the |
|
502 | + * registration processing is halted. |
|
503 | + */ |
|
504 | + if ( |
|
505 | + apply_filters( |
|
506 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
507 | + false, |
|
508 | + $att_nmbr, |
|
509 | + $registration, |
|
510 | + $registrations, |
|
511 | + $valid_data, |
|
512 | + $this |
|
513 | + ) |
|
514 | + ) { |
|
515 | + return false; |
|
516 | + } |
|
517 | + |
|
518 | + // Houston, we have a registration! |
|
519 | + $att_nmbr++; |
|
520 | + $this->_attendee_data[ $reg_url_link ] = array(); |
|
521 | + // grab any existing related answer objects |
|
522 | + $this->_registration_answers = $registration->answers(); |
|
523 | + // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
524 | + if (isset($valid_data[ $reg_url_link ])) { |
|
525 | + // do we need to copy basic info from primary attendee ? |
|
526 | + $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
527 | + && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
528 | + // filter form input data for this registration |
|
529 | + $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
530 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
531 | + $valid_data[ $reg_url_link ] |
|
532 | + ); |
|
533 | + if (isset($valid_data['primary_attendee'])) { |
|
534 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
535 | + ? $valid_data['primary_attendee'] |
|
536 | + : false; |
|
537 | + unset($valid_data['primary_attendee']); |
|
538 | + } |
|
539 | + // now loop through our array of valid post data && process attendee reg forms |
|
540 | + foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
541 | + if (! in_array($form_section, $non_input_form_sections, true)) { |
|
542 | + foreach ($form_inputs as $form_input => $input_value) { |
|
543 | + // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
544 | + // check for critical inputs |
|
545 | + if ( |
|
546 | + ! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
547 | + $form_input, |
|
548 | + $input_value |
|
549 | + ) |
|
550 | + ) { |
|
551 | + return false; |
|
552 | + } |
|
553 | + // store a bit of data about the primary attendee |
|
554 | + if ( |
|
555 | + $att_nmbr === 1 |
|
556 | + && ! empty($input_value) |
|
557 | + && $reg_url_link === $primary_registrant['line_item_id'] |
|
558 | + ) { |
|
559 | + $primary_registrant[ $form_input ] = $input_value; |
|
560 | + } elseif ( |
|
561 | + $copy_primary |
|
562 | + && $input_value === null |
|
563 | + && isset($primary_registrant[ $form_input ]) |
|
564 | + ) { |
|
565 | + $input_value = $primary_registrant[ $form_input ]; |
|
566 | + } |
|
567 | + // now attempt to save the input data |
|
568 | + if ( |
|
569 | + ! $this->_save_registration_form_input( |
|
570 | + $registration, |
|
571 | + $form_input, |
|
572 | + $input_value |
|
573 | + ) |
|
574 | + ) { |
|
575 | + EE_Error::add_error( |
|
576 | + sprintf( |
|
577 | + esc_html_x( |
|
578 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
579 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
580 | + 'event_espresso' |
|
581 | + ), |
|
582 | + $form_input, |
|
583 | + $input_value |
|
584 | + ), |
|
585 | + __FILE__, |
|
586 | + __FUNCTION__, |
|
587 | + __LINE__ |
|
588 | + ); |
|
589 | + return false; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
594 | + } |
|
595 | + // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
596 | + // this registration does not require additional attendee information ? |
|
597 | + if ( |
|
598 | + $copy_primary |
|
599 | + && $att_nmbr > 1 |
|
600 | + && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
601 | + ) { |
|
602 | + // just copy the primary registrant |
|
603 | + $attendee = $this->checkout->primary_attendee_obj; |
|
604 | + } else { |
|
605 | + // ensure critical details are set for additional attendees |
|
606 | + $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
607 | + ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
608 | + $this->_attendee_data[ $reg_url_link ] |
|
609 | + ) |
|
610 | + : $this->_attendee_data[ $reg_url_link ]; |
|
611 | + // execute create attendee command (which may return an existing attendee) |
|
612 | + $attendee = EE_Registry::instance()->BUS->execute( |
|
613 | + new CreateAttendeeCommand( |
|
614 | + $this->_attendee_data[ $reg_url_link ], |
|
615 | + $registration |
|
616 | + ) |
|
617 | + ); |
|
618 | + // who's #1 ? |
|
619 | + if ($att_nmbr === 1) { |
|
620 | + $this->checkout->primary_attendee_obj = $attendee; |
|
621 | + } |
|
622 | + } |
|
623 | + // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
624 | + // add relation to registration, set attendee ID, and cache attendee |
|
625 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
626 | + // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
627 | + if (! $registration->attendee() instanceof EE_Attendee) { |
|
628 | + EE_Error::add_error( |
|
629 | + sprintf( |
|
630 | + esc_html_x( |
|
631 | + 'Registration %s has an invalid or missing Attendee object.', |
|
632 | + 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
633 | + 'event_espresso' |
|
634 | + ), |
|
635 | + $reg_url_link |
|
636 | + ), |
|
637 | + __FILE__, |
|
638 | + __FUNCTION__, |
|
639 | + __LINE__ |
|
640 | + ); |
|
641 | + return false; |
|
642 | + } |
|
643 | + /** @type EE_Registration_Processor $registration_processor */ |
|
644 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
645 | + // at this point, we should have enough details about the registrant to consider the registration |
|
646 | + // NOT incomplete |
|
647 | + $registration_processor->toggle_incomplete_registration_status_to_default( |
|
648 | + $registration, |
|
649 | + false, |
|
650 | + new Context( |
|
651 | + 'spco_reg_step_attendee_information_process_registrations', |
|
652 | + esc_html__( |
|
653 | + 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
654 | + 'event_espresso' |
|
655 | + ) |
|
656 | + ) |
|
657 | + ); |
|
658 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
659 | + // abandoned |
|
660 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
661 | + // if we've gotten this far, then let's save what we have |
|
662 | + $registration->save(); |
|
663 | + // add relation between TXN and registration |
|
664 | + $this->_associate_registration_with_transaction($registration); |
|
665 | + } |
|
666 | + } else { |
|
667 | + EE_Error::add_error( |
|
668 | + esc_html__( |
|
669 | + 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
670 | + 'event_espresso' |
|
671 | + ), |
|
672 | + __FILE__, |
|
673 | + __FUNCTION__, |
|
674 | + __LINE__ |
|
675 | + ); |
|
676 | + // remove malformed data |
|
677 | + unset($valid_data[ $reg_url_link ]); |
|
678 | + return false; |
|
679 | + } |
|
680 | + } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
681 | + return $att_nmbr; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * _save_registration_form_input |
|
687 | + * |
|
688 | + * @param EE_Registration $registration |
|
689 | + * @param string $form_input |
|
690 | + * @param string $input_value |
|
691 | + * @return bool |
|
692 | + * @throws EE_Error |
|
693 | + * @throws InvalidArgumentException |
|
694 | + * @throws InvalidDataTypeException |
|
695 | + * @throws InvalidInterfaceException |
|
696 | + * @throws ReflectionException |
|
697 | + */ |
|
698 | + private function _save_registration_form_input( |
|
699 | + EE_Registration $registration, |
|
700 | + $form_input = '', |
|
701 | + $input_value = '' |
|
702 | + ) { |
|
703 | + // If email_confirm is sent it's not saved |
|
704 | + if ((string) $form_input === 'email_confirm') { |
|
705 | + return true; |
|
706 | + } |
|
707 | + |
|
708 | + // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
709 | + // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
710 | + // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
711 | + // allow for plugins to hook in and do their own processing of the form input. |
|
712 | + // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
713 | + if ( |
|
714 | + apply_filters( |
|
715 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
716 | + false, |
|
717 | + $registration, |
|
718 | + $form_input, |
|
719 | + $input_value, |
|
720 | + $this |
|
721 | + ) |
|
722 | + ) { |
|
723 | + return true; |
|
724 | + } |
|
725 | + /* |
|
726 | 726 | * $answer_cache_id is the key used to find the EE_Answer we want |
727 | 727 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
728 | 728 | */ |
729 | - $answer_cache_id = $this->checkout->reg_url_link |
|
730 | - ? $form_input . '-' . $registration->reg_url_link() |
|
731 | - : $form_input; |
|
732 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
733 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
734 | - // rename form_inputs if they are EE_Attendee properties |
|
735 | - switch ((string) $form_input) { |
|
736 | - case 'state': |
|
737 | - case 'STA_ID': |
|
738 | - $attendee_property = true; |
|
739 | - $form_input = 'STA_ID'; |
|
740 | - break; |
|
741 | - |
|
742 | - case 'country': |
|
743 | - case 'CNT_ISO': |
|
744 | - $attendee_property = true; |
|
745 | - $form_input = 'CNT_ISO'; |
|
746 | - break; |
|
747 | - |
|
748 | - default: |
|
749 | - $ATT_input = 'ATT_' . $form_input; |
|
750 | - // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
751 | - $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
752 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
753 | - } |
|
754 | - // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
755 | - // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
756 | - // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
757 | - // if this form input has a corresponding attendee property |
|
758 | - if ($attendee_property) { |
|
759 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
760 | - if ($answer_is_obj) { |
|
761 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
762 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
763 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
764 | - } |
|
765 | - return true; |
|
766 | - } |
|
767 | - if ($answer_is_obj) { |
|
768 | - // save this data to the answer object |
|
769 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
770 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
771 | - return $result !== false; |
|
772 | - } |
|
773 | - foreach ($this->_registration_answers as $answer) { |
|
774 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
775 | - $answer->set_value($input_value); |
|
776 | - $result = $answer->save(); |
|
777 | - return $result !== false; |
|
778 | - } |
|
779 | - } |
|
780 | - return false; |
|
781 | - } |
|
782 | - |
|
783 | - |
|
784 | - /** |
|
785 | - * _verify_critical_attendee_details_are_set |
|
786 | - * |
|
787 | - * @param string $form_input |
|
788 | - * @param string $input_value |
|
789 | - * @return boolean |
|
790 | - */ |
|
791 | - private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
792 | - $form_input = '', |
|
793 | - $input_value = '' |
|
794 | - ) { |
|
795 | - if (empty($input_value)) { |
|
796 | - // if the form input isn't marked as being required, then just return |
|
797 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
798 | - return true; |
|
799 | - } |
|
800 | - switch ($form_input) { |
|
801 | - case 'fname': |
|
802 | - EE_Error::add_error( |
|
803 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
804 | - __FILE__, |
|
805 | - __FUNCTION__, |
|
806 | - __LINE__ |
|
807 | - ); |
|
808 | - return false; |
|
809 | - break; |
|
810 | - case 'lname': |
|
811 | - EE_Error::add_error( |
|
812 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
813 | - __FILE__, |
|
814 | - __FUNCTION__, |
|
815 | - __LINE__ |
|
816 | - ); |
|
817 | - return false; |
|
818 | - break; |
|
819 | - case 'email': |
|
820 | - EE_Error::add_error( |
|
821 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
822 | - __FILE__, |
|
823 | - __FUNCTION__, |
|
824 | - __LINE__ |
|
825 | - ); |
|
826 | - return false; |
|
827 | - break; |
|
828 | - } |
|
829 | - } |
|
830 | - return true; |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * _associate_attendee_with_registration |
|
836 | - * |
|
837 | - * @param EE_Registration $registration |
|
838 | - * @param EE_Attendee $attendee |
|
839 | - * @return void |
|
840 | - * @throws EE_Error |
|
841 | - * @throws InvalidArgumentException |
|
842 | - * @throws ReflectionException |
|
843 | - * @throws RuntimeException |
|
844 | - * @throws InvalidDataTypeException |
|
845 | - * @throws InvalidInterfaceException |
|
846 | - */ |
|
847 | - private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
848 | - { |
|
849 | - // add relation to attendee |
|
850 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
851 | - $registration->set_attendee_id($attendee->ID()); |
|
852 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * _associate_registration_with_transaction |
|
858 | - * |
|
859 | - * @param EE_Registration $registration |
|
860 | - * @return void |
|
861 | - * @throws EE_Error |
|
862 | - * @throws InvalidArgumentException |
|
863 | - * @throws ReflectionException |
|
864 | - * @throws InvalidDataTypeException |
|
865 | - * @throws InvalidInterfaceException |
|
866 | - */ |
|
867 | - private function _associate_registration_with_transaction(EE_Registration $registration) |
|
868 | - { |
|
869 | - // add relation to registration |
|
870 | - $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
871 | - $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
872 | - } |
|
873 | - |
|
874 | - |
|
875 | - /** |
|
876 | - * _copy_critical_attendee_details_from_primary_registrant |
|
877 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
878 | - * |
|
879 | - * @param array $attendee_data |
|
880 | - * @return array |
|
881 | - * @throws EE_Error |
|
882 | - * @throws InvalidArgumentException |
|
883 | - * @throws ReflectionException |
|
884 | - * @throws InvalidDataTypeException |
|
885 | - * @throws InvalidInterfaceException |
|
886 | - */ |
|
887 | - private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
888 | - { |
|
889 | - // bare minimum critical details include first name, last name, email address |
|
890 | - $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
891 | - // add address info to critical details? |
|
892 | - if ( |
|
893 | - apply_filters( |
|
894 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
895 | - false |
|
896 | - ) |
|
897 | - ) { |
|
898 | - $address_details = array( |
|
899 | - 'ATT_address', |
|
900 | - 'ATT_address2', |
|
901 | - 'ATT_city', |
|
902 | - 'STA_ID', |
|
903 | - 'CNT_ISO', |
|
904 | - 'ATT_zip', |
|
905 | - 'ATT_phone', |
|
906 | - ); |
|
907 | - $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
908 | - } |
|
909 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
910 | - if ( |
|
911 | - ! isset($attendee_data[ $critical_attendee_detail ]) |
|
912 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
913 | - ) { |
|
914 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
915 | - $critical_attendee_detail |
|
916 | - ); |
|
917 | - } |
|
918 | - } |
|
919 | - return $attendee_data; |
|
920 | - } |
|
921 | - |
|
922 | - |
|
923 | - /** |
|
924 | - * update_reg_step |
|
925 | - * this is the final step after a user revisits the site to edit their attendee information |
|
926 | - * this gets called AFTER the process_reg_step() method above |
|
927 | - * |
|
928 | - * @return bool |
|
929 | - * @throws EE_Error |
|
930 | - * @throws InvalidArgumentException |
|
931 | - * @throws ReflectionException |
|
932 | - * @throws RuntimeException |
|
933 | - * @throws InvalidDataTypeException |
|
934 | - * @throws InvalidInterfaceException |
|
935 | - */ |
|
936 | - public function update_reg_step() |
|
937 | - { |
|
938 | - // save everything |
|
939 | - if ($this->process_reg_step()) { |
|
940 | - $this->checkout->redirect = true; |
|
941 | - $this->checkout->redirect_url = add_query_arg( |
|
942 | - array( |
|
943 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
944 | - 'revisit' => true, |
|
945 | - ), |
|
946 | - $this->checkout->thank_you_page_url |
|
947 | - ); |
|
948 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
949 | - return true; |
|
950 | - } |
|
951 | - return false; |
|
952 | - } |
|
729 | + $answer_cache_id = $this->checkout->reg_url_link |
|
730 | + ? $form_input . '-' . $registration->reg_url_link() |
|
731 | + : $form_input; |
|
732 | + $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
733 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
734 | + // rename form_inputs if they are EE_Attendee properties |
|
735 | + switch ((string) $form_input) { |
|
736 | + case 'state': |
|
737 | + case 'STA_ID': |
|
738 | + $attendee_property = true; |
|
739 | + $form_input = 'STA_ID'; |
|
740 | + break; |
|
741 | + |
|
742 | + case 'country': |
|
743 | + case 'CNT_ISO': |
|
744 | + $attendee_property = true; |
|
745 | + $form_input = 'CNT_ISO'; |
|
746 | + break; |
|
747 | + |
|
748 | + default: |
|
749 | + $ATT_input = 'ATT_' . $form_input; |
|
750 | + // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
751 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
752 | + $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
753 | + } |
|
754 | + // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
755 | + // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
756 | + // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
757 | + // if this form input has a corresponding attendee property |
|
758 | + if ($attendee_property) { |
|
759 | + $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
760 | + if ($answer_is_obj) { |
|
761 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
762 | + $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
763 | + $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
764 | + } |
|
765 | + return true; |
|
766 | + } |
|
767 | + if ($answer_is_obj) { |
|
768 | + // save this data to the answer object |
|
769 | + $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
770 | + $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
771 | + return $result !== false; |
|
772 | + } |
|
773 | + foreach ($this->_registration_answers as $answer) { |
|
774 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
775 | + $answer->set_value($input_value); |
|
776 | + $result = $answer->save(); |
|
777 | + return $result !== false; |
|
778 | + } |
|
779 | + } |
|
780 | + return false; |
|
781 | + } |
|
782 | + |
|
783 | + |
|
784 | + /** |
|
785 | + * _verify_critical_attendee_details_are_set |
|
786 | + * |
|
787 | + * @param string $form_input |
|
788 | + * @param string $input_value |
|
789 | + * @return boolean |
|
790 | + */ |
|
791 | + private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
792 | + $form_input = '', |
|
793 | + $input_value = '' |
|
794 | + ) { |
|
795 | + if (empty($input_value)) { |
|
796 | + // if the form input isn't marked as being required, then just return |
|
797 | + if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
798 | + return true; |
|
799 | + } |
|
800 | + switch ($form_input) { |
|
801 | + case 'fname': |
|
802 | + EE_Error::add_error( |
|
803 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
804 | + __FILE__, |
|
805 | + __FUNCTION__, |
|
806 | + __LINE__ |
|
807 | + ); |
|
808 | + return false; |
|
809 | + break; |
|
810 | + case 'lname': |
|
811 | + EE_Error::add_error( |
|
812 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
813 | + __FILE__, |
|
814 | + __FUNCTION__, |
|
815 | + __LINE__ |
|
816 | + ); |
|
817 | + return false; |
|
818 | + break; |
|
819 | + case 'email': |
|
820 | + EE_Error::add_error( |
|
821 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
822 | + __FILE__, |
|
823 | + __FUNCTION__, |
|
824 | + __LINE__ |
|
825 | + ); |
|
826 | + return false; |
|
827 | + break; |
|
828 | + } |
|
829 | + } |
|
830 | + return true; |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * _associate_attendee_with_registration |
|
836 | + * |
|
837 | + * @param EE_Registration $registration |
|
838 | + * @param EE_Attendee $attendee |
|
839 | + * @return void |
|
840 | + * @throws EE_Error |
|
841 | + * @throws InvalidArgumentException |
|
842 | + * @throws ReflectionException |
|
843 | + * @throws RuntimeException |
|
844 | + * @throws InvalidDataTypeException |
|
845 | + * @throws InvalidInterfaceException |
|
846 | + */ |
|
847 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
848 | + { |
|
849 | + // add relation to attendee |
|
850 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
851 | + $registration->set_attendee_id($attendee->ID()); |
|
852 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * _associate_registration_with_transaction |
|
858 | + * |
|
859 | + * @param EE_Registration $registration |
|
860 | + * @return void |
|
861 | + * @throws EE_Error |
|
862 | + * @throws InvalidArgumentException |
|
863 | + * @throws ReflectionException |
|
864 | + * @throws InvalidDataTypeException |
|
865 | + * @throws InvalidInterfaceException |
|
866 | + */ |
|
867 | + private function _associate_registration_with_transaction(EE_Registration $registration) |
|
868 | + { |
|
869 | + // add relation to registration |
|
870 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
871 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
872 | + } |
|
873 | + |
|
874 | + |
|
875 | + /** |
|
876 | + * _copy_critical_attendee_details_from_primary_registrant |
|
877 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
878 | + * |
|
879 | + * @param array $attendee_data |
|
880 | + * @return array |
|
881 | + * @throws EE_Error |
|
882 | + * @throws InvalidArgumentException |
|
883 | + * @throws ReflectionException |
|
884 | + * @throws InvalidDataTypeException |
|
885 | + * @throws InvalidInterfaceException |
|
886 | + */ |
|
887 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
888 | + { |
|
889 | + // bare minimum critical details include first name, last name, email address |
|
890 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
891 | + // add address info to critical details? |
|
892 | + if ( |
|
893 | + apply_filters( |
|
894 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
895 | + false |
|
896 | + ) |
|
897 | + ) { |
|
898 | + $address_details = array( |
|
899 | + 'ATT_address', |
|
900 | + 'ATT_address2', |
|
901 | + 'ATT_city', |
|
902 | + 'STA_ID', |
|
903 | + 'CNT_ISO', |
|
904 | + 'ATT_zip', |
|
905 | + 'ATT_phone', |
|
906 | + ); |
|
907 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
908 | + } |
|
909 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
910 | + if ( |
|
911 | + ! isset($attendee_data[ $critical_attendee_detail ]) |
|
912 | + || empty($attendee_data[ $critical_attendee_detail ]) |
|
913 | + ) { |
|
914 | + $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
915 | + $critical_attendee_detail |
|
916 | + ); |
|
917 | + } |
|
918 | + } |
|
919 | + return $attendee_data; |
|
920 | + } |
|
921 | + |
|
922 | + |
|
923 | + /** |
|
924 | + * update_reg_step |
|
925 | + * this is the final step after a user revisits the site to edit their attendee information |
|
926 | + * this gets called AFTER the process_reg_step() method above |
|
927 | + * |
|
928 | + * @return bool |
|
929 | + * @throws EE_Error |
|
930 | + * @throws InvalidArgumentException |
|
931 | + * @throws ReflectionException |
|
932 | + * @throws RuntimeException |
|
933 | + * @throws InvalidDataTypeException |
|
934 | + * @throws InvalidInterfaceException |
|
935 | + */ |
|
936 | + public function update_reg_step() |
|
937 | + { |
|
938 | + // save everything |
|
939 | + if ($this->process_reg_step()) { |
|
940 | + $this->checkout->redirect = true; |
|
941 | + $this->checkout->redirect_url = add_query_arg( |
|
942 | + array( |
|
943 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
944 | + 'revisit' => true, |
|
945 | + ), |
|
946 | + $this->checkout->thank_you_page_url |
|
947 | + ); |
|
948 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
949 | + return true; |
|
950 | + } |
|
951 | + return false; |
|
952 | + } |
|
953 | 953 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | ); |
342 | 342 | return false; |
343 | 343 | } |
344 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
344 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
345 | 345 | EE_Error::add_error( |
346 | 346 | esc_html__( |
347 | 347 | 'A valid transaction could not be initiated for processing your registrations.', |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
369 | 369 | 'event_espresso' |
370 | 370 | ), |
371 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
371 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
372 | 372 | '</a>', |
373 | 373 | '<br />' |
374 | 374 | ); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | // but return immediately if the previous step exited early due to errors |
389 | 389 | return false; |
390 | 390 | } |
391 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
391 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
392 | 392 | // generate a correctly translated string for all possible singular/plural combinations |
393 | 393 | if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
394 | 394 | $error_msg = sprintf( |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | // grab the saved registrations from the transaction |
472 | 472 | foreach ($registrations as $registration) { |
473 | 473 | // verify EE_Registration object |
474 | - if (! $registration instanceof EE_Registration) { |
|
474 | + if ( ! $registration instanceof EE_Registration) { |
|
475 | 475 | EE_Error::add_error( |
476 | 476 | esc_html__( |
477 | 477 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | /** @var string $reg_url_link */ |
487 | 487 | $reg_url_link = $registration->reg_url_link(); |
488 | 488 | // reg_url_link exists ? |
489 | - if (! empty($reg_url_link)) { |
|
489 | + if ( ! empty($reg_url_link)) { |
|
490 | 490 | // should this registration be processed during this visit ? |
491 | 491 | if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
492 | 492 | // if NOT revisiting, then let's save the registration now, |
493 | 493 | // so that we have a REG_ID to use when generating other objects |
494 | - if (! $this->checkout->revisit) { |
|
494 | + if ( ! $this->checkout->revisit) { |
|
495 | 495 | $registration->save(); |
496 | 496 | } |
497 | 497 | /** |
@@ -517,18 +517,18 @@ discard block |
||
517 | 517 | |
518 | 518 | // Houston, we have a registration! |
519 | 519 | $att_nmbr++; |
520 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
520 | + $this->_attendee_data[$reg_url_link] = array(); |
|
521 | 521 | // grab any existing related answer objects |
522 | 522 | $this->_registration_answers = $registration->answers(); |
523 | 523 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
524 | - if (isset($valid_data[ $reg_url_link ])) { |
|
524 | + if (isset($valid_data[$reg_url_link])) { |
|
525 | 525 | // do we need to copy basic info from primary attendee ? |
526 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
527 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
526 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
527 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0; |
|
528 | 528 | // filter form input data for this registration |
529 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
529 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
530 | 530 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
531 | - $valid_data[ $reg_url_link ] |
|
531 | + $valid_data[$reg_url_link] |
|
532 | 532 | ); |
533 | 533 | if (isset($valid_data['primary_attendee'])) { |
534 | 534 | $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | unset($valid_data['primary_attendee']); |
538 | 538 | } |
539 | 539 | // now loop through our array of valid post data && process attendee reg forms |
540 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
541 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
540 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
541 | + if ( ! in_array($form_section, $non_input_form_sections, true)) { |
|
542 | 542 | foreach ($form_inputs as $form_input => $input_value) { |
543 | 543 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
544 | 544 | // check for critical inputs |
@@ -556,13 +556,13 @@ discard block |
||
556 | 556 | && ! empty($input_value) |
557 | 557 | && $reg_url_link === $primary_registrant['line_item_id'] |
558 | 558 | ) { |
559 | - $primary_registrant[ $form_input ] = $input_value; |
|
559 | + $primary_registrant[$form_input] = $input_value; |
|
560 | 560 | } elseif ( |
561 | 561 | $copy_primary |
562 | 562 | && $input_value === null |
563 | - && isset($primary_registrant[ $form_input ]) |
|
563 | + && isset($primary_registrant[$form_input]) |
|
564 | 564 | ) { |
565 | - $input_value = $primary_registrant[ $form_input ]; |
|
565 | + $input_value = $primary_registrant[$form_input]; |
|
566 | 566 | } |
567 | 567 | // now attempt to save the input data |
568 | 568 | if ( |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | $attendee = $this->checkout->primary_attendee_obj; |
604 | 604 | } else { |
605 | 605 | // ensure critical details are set for additional attendees |
606 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
606 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
607 | 607 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
608 | - $this->_attendee_data[ $reg_url_link ] |
|
608 | + $this->_attendee_data[$reg_url_link] |
|
609 | 609 | ) |
610 | - : $this->_attendee_data[ $reg_url_link ]; |
|
610 | + : $this->_attendee_data[$reg_url_link]; |
|
611 | 611 | // execute create attendee command (which may return an existing attendee) |
612 | 612 | $attendee = EE_Registry::instance()->BUS->execute( |
613 | 613 | new CreateAttendeeCommand( |
614 | - $this->_attendee_data[ $reg_url_link ], |
|
614 | + $this->_attendee_data[$reg_url_link], |
|
615 | 615 | $registration |
616 | 616 | ) |
617 | 617 | ); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | // add relation to registration, set attendee ID, and cache attendee |
625 | 625 | $this->_associate_attendee_with_registration($registration, $attendee); |
626 | 626 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
627 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
627 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
628 | 628 | EE_Error::add_error( |
629 | 629 | sprintf( |
630 | 630 | esc_html_x( |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | __LINE__ |
675 | 675 | ); |
676 | 676 | // remove malformed data |
677 | - unset($valid_data[ $reg_url_link ]); |
|
677 | + unset($valid_data[$reg_url_link]); |
|
678 | 678 | return false; |
679 | 679 | } |
680 | 680 | } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
@@ -727,10 +727,10 @@ discard block |
||
727 | 727 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
728 | 728 | */ |
729 | 729 | $answer_cache_id = $this->checkout->reg_url_link |
730 | - ? $form_input . '-' . $registration->reg_url_link() |
|
730 | + ? $form_input.'-'.$registration->reg_url_link() |
|
731 | 731 | : $form_input; |
732 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
733 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
732 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
733 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer; |
|
734 | 734 | // rename form_inputs if they are EE_Attendee properties |
735 | 735 | switch ((string) $form_input) { |
736 | 736 | case 'state': |
@@ -746,28 +746,28 @@ discard block |
||
746 | 746 | break; |
747 | 747 | |
748 | 748 | default: |
749 | - $ATT_input = 'ATT_' . $form_input; |
|
749 | + $ATT_input = 'ATT_'.$form_input; |
|
750 | 750 | // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
751 | 751 | $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
752 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
752 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
753 | 753 | } |
754 | 754 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
755 | 755 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
756 | 756 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
757 | 757 | // if this form input has a corresponding attendee property |
758 | 758 | if ($attendee_property) { |
759 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
759 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
760 | 760 | if ($answer_is_obj) { |
761 | 761 | // and delete the corresponding answer since we won't be storing this data in that object |
762 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
763 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
762 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
763 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
764 | 764 | } |
765 | 765 | return true; |
766 | 766 | } |
767 | 767 | if ($answer_is_obj) { |
768 | 768 | // save this data to the answer object |
769 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
770 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
769 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
770 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
771 | 771 | return $result !== false; |
772 | 772 | } |
773 | 773 | foreach ($this->_registration_answers as $answer) { |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | ) { |
795 | 795 | if (empty($input_value)) { |
796 | 796 | // if the form input isn't marked as being required, then just return |
797 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
797 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
798 | 798 | return true; |
799 | 799 | } |
800 | 800 | switch ($form_input) { |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | } |
909 | 909 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
910 | 910 | if ( |
911 | - ! isset($attendee_data[ $critical_attendee_detail ]) |
|
912 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
911 | + ! isset($attendee_data[$critical_attendee_detail]) |
|
912 | + || empty($attendee_data[$critical_attendee_detail]) |
|
913 | 913 | ) { |
914 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
914 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
915 | 915 | $critical_attendee_detail |
916 | 916 | ); |
917 | 917 | } |
@@ -17,190 +17,190 @@ |
||
17 | 17 | class RegistrationForm extends EE_Form_Section_Proper |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var EEM_Event_Question_Group |
|
22 | - */ |
|
23 | - public $event_question_group_model; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - private $has_questions = false; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * RegistrationForm constructor. |
|
33 | - * |
|
34 | - * @param EE_Registration $registration |
|
35 | - * @param bool $admin_request |
|
36 | - * @param bool $copy_attendee_info |
|
37 | - * @param callable $enablePrintCopyInfo |
|
38 | - * @param EEM_Event_Question_Group $event_question_group_model |
|
39 | - * @throws EE_Error |
|
40 | - * @throws ReflectionException |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - EE_Registration $registration, |
|
44 | - bool $admin_request, |
|
45 | - bool $copy_attendee_info, |
|
46 | - callable $enablePrintCopyInfo, |
|
47 | - EEM_Event_Question_Group $event_question_group_model |
|
48 | - ) { |
|
49 | - $this->event_question_group_model = $event_question_group_model; |
|
50 | - parent::__construct( |
|
51 | - $this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo) |
|
52 | - ); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function hasQuestions(): bool |
|
60 | - { |
|
61 | - return $this->has_questions; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param EE_Registration $registration |
|
67 | - * @param bool $admin_request |
|
68 | - * @param bool $copy_attendee_info |
|
69 | - * @param callable $enablePrintCopyInfo |
|
70 | - * @return array |
|
71 | - * @throws EE_Error |
|
72 | - * @throws ReflectionException |
|
73 | - */ |
|
74 | - private function generateFormArgs( |
|
75 | - EE_Registration $registration, |
|
76 | - bool $admin_request, |
|
77 | - bool $copy_attendee_info, |
|
78 | - callable $enablePrintCopyInfo |
|
79 | - ): array { |
|
80 | - static $attendee_nmbr = 1; |
|
81 | - $form_args = []; |
|
82 | - // verify that registration has valid event |
|
83 | - if ($registration->event() instanceof EE_Event) { |
|
84 | - $field_name = 'Event_Question_Group.' . $this->event_question_group_model->fieldNameForContext( |
|
85 | - $registration->is_primary_registrant() |
|
86 | - ); |
|
87 | - $question_groups = $registration->event()->question_groups( |
|
88 | - apply_filters( |
|
89 | - // @codingStandardsIgnoreStart |
|
90 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
91 | - // @codingStandardsIgnoreEnd |
|
92 | - [ |
|
93 | - [ |
|
94 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
95 | - $field_name => true, |
|
96 | - ], |
|
97 | - 'order_by' => ['QSG_order' => 'ASC'], |
|
98 | - ], |
|
99 | - $registration, |
|
100 | - $this |
|
101 | - ) |
|
102 | - ); |
|
103 | - if ($question_groups) { |
|
104 | - // array of params to pass to parent constructor |
|
105 | - $form_args = [ |
|
106 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
107 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
108 | - 'html_style' => $admin_request |
|
109 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
110 | - : '', |
|
111 | - 'subsections' => [], |
|
112 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
113 | - [ |
|
114 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
115 | - 'legend_text' => sprintf( |
|
116 | - esc_html_x( |
|
117 | - 'Attendee %d', |
|
118 | - 'Attendee 123', |
|
119 | - 'event_espresso' |
|
120 | - ), |
|
121 | - $attendee_nmbr |
|
122 | - ), |
|
123 | - ] |
|
124 | - ), |
|
125 | - ]; |
|
126 | - foreach ($question_groups as $question_group) { |
|
127 | - if ($question_group instanceof EE_Question_Group) { |
|
128 | - $question_group_reg_form = LoaderFactory::getNew( |
|
129 | - QuestionGroupRegForm::class, |
|
130 | - [$registration, $question_group, $admin_request] |
|
131 | - ); |
|
132 | - $form_args['subsections'][ $question_group->identifier() ] = apply_filters( |
|
133 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
134 | - $question_group_reg_form, |
|
135 | - $registration, |
|
136 | - $question_group, |
|
137 | - $this |
|
138 | - ); |
|
139 | - } |
|
140 | - } |
|
141 | - // add hidden input |
|
142 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->additionalAttendeeRegInfoInput( |
|
143 | - $registration |
|
144 | - ); |
|
145 | - |
|
146 | - // If we have question groups for additional attendees, then display the copy options |
|
147 | - $enablePrintCopyInfo( |
|
148 | - apply_filters( |
|
149 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
150 | - $attendee_nmbr > 1 && $copy_attendee_info, |
|
151 | - $attendee_nmbr |
|
152 | - ) |
|
153 | - ); |
|
154 | - |
|
155 | - if ($registration->is_primary_registrant()) { |
|
156 | - // generate hidden input |
|
157 | - $form_args['subsections']['primary_registrant'] = $this->additionalPrimaryRegistrantInputs( |
|
158 | - $registration |
|
159 | - ); |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - $attendee_nmbr++; |
|
164 | - |
|
165 | - // Increment the reg forms number if form is valid. |
|
166 | - if (! empty($form_args)) { |
|
167 | - $this->has_questions = true; |
|
168 | - } |
|
169 | - |
|
170 | - return $form_args; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @param EE_Registration $registration |
|
176 | - * @return EE_Form_Input_Base |
|
177 | - * @throws EE_Error |
|
178 | - */ |
|
179 | - private function additionalAttendeeRegInfoInput(EE_Registration $registration) |
|
180 | - { |
|
181 | - // generate hidden input |
|
182 | - return new EE_Hidden_Input( |
|
183 | - [ |
|
184 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
185 | - 'default' => true, |
|
186 | - ] |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param EE_Registration $registration |
|
193 | - * @return EE_Form_Input_Base |
|
194 | - * @throws EE_Error |
|
195 | - */ |
|
196 | - private function additionalPrimaryRegistrantInputs(EE_Registration $registration) |
|
197 | - { |
|
198 | - // generate hidden input |
|
199 | - return new EE_Hidden_Input( |
|
200 | - [ |
|
201 | - 'html_id' => 'primary_registrant', |
|
202 | - 'default' => $registration->reg_url_link(), |
|
203 | - ] |
|
204 | - ); |
|
205 | - } |
|
20 | + /** |
|
21 | + * @var EEM_Event_Question_Group |
|
22 | + */ |
|
23 | + public $event_question_group_model; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + private $has_questions = false; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * RegistrationForm constructor. |
|
33 | + * |
|
34 | + * @param EE_Registration $registration |
|
35 | + * @param bool $admin_request |
|
36 | + * @param bool $copy_attendee_info |
|
37 | + * @param callable $enablePrintCopyInfo |
|
38 | + * @param EEM_Event_Question_Group $event_question_group_model |
|
39 | + * @throws EE_Error |
|
40 | + * @throws ReflectionException |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + EE_Registration $registration, |
|
44 | + bool $admin_request, |
|
45 | + bool $copy_attendee_info, |
|
46 | + callable $enablePrintCopyInfo, |
|
47 | + EEM_Event_Question_Group $event_question_group_model |
|
48 | + ) { |
|
49 | + $this->event_question_group_model = $event_question_group_model; |
|
50 | + parent::__construct( |
|
51 | + $this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo) |
|
52 | + ); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function hasQuestions(): bool |
|
60 | + { |
|
61 | + return $this->has_questions; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param EE_Registration $registration |
|
67 | + * @param bool $admin_request |
|
68 | + * @param bool $copy_attendee_info |
|
69 | + * @param callable $enablePrintCopyInfo |
|
70 | + * @return array |
|
71 | + * @throws EE_Error |
|
72 | + * @throws ReflectionException |
|
73 | + */ |
|
74 | + private function generateFormArgs( |
|
75 | + EE_Registration $registration, |
|
76 | + bool $admin_request, |
|
77 | + bool $copy_attendee_info, |
|
78 | + callable $enablePrintCopyInfo |
|
79 | + ): array { |
|
80 | + static $attendee_nmbr = 1; |
|
81 | + $form_args = []; |
|
82 | + // verify that registration has valid event |
|
83 | + if ($registration->event() instanceof EE_Event) { |
|
84 | + $field_name = 'Event_Question_Group.' . $this->event_question_group_model->fieldNameForContext( |
|
85 | + $registration->is_primary_registrant() |
|
86 | + ); |
|
87 | + $question_groups = $registration->event()->question_groups( |
|
88 | + apply_filters( |
|
89 | + // @codingStandardsIgnoreStart |
|
90 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
91 | + // @codingStandardsIgnoreEnd |
|
92 | + [ |
|
93 | + [ |
|
94 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
95 | + $field_name => true, |
|
96 | + ], |
|
97 | + 'order_by' => ['QSG_order' => 'ASC'], |
|
98 | + ], |
|
99 | + $registration, |
|
100 | + $this |
|
101 | + ) |
|
102 | + ); |
|
103 | + if ($question_groups) { |
|
104 | + // array of params to pass to parent constructor |
|
105 | + $form_args = [ |
|
106 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
107 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
108 | + 'html_style' => $admin_request |
|
109 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
110 | + : '', |
|
111 | + 'subsections' => [], |
|
112 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
113 | + [ |
|
114 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
115 | + 'legend_text' => sprintf( |
|
116 | + esc_html_x( |
|
117 | + 'Attendee %d', |
|
118 | + 'Attendee 123', |
|
119 | + 'event_espresso' |
|
120 | + ), |
|
121 | + $attendee_nmbr |
|
122 | + ), |
|
123 | + ] |
|
124 | + ), |
|
125 | + ]; |
|
126 | + foreach ($question_groups as $question_group) { |
|
127 | + if ($question_group instanceof EE_Question_Group) { |
|
128 | + $question_group_reg_form = LoaderFactory::getNew( |
|
129 | + QuestionGroupRegForm::class, |
|
130 | + [$registration, $question_group, $admin_request] |
|
131 | + ); |
|
132 | + $form_args['subsections'][ $question_group->identifier() ] = apply_filters( |
|
133 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
134 | + $question_group_reg_form, |
|
135 | + $registration, |
|
136 | + $question_group, |
|
137 | + $this |
|
138 | + ); |
|
139 | + } |
|
140 | + } |
|
141 | + // add hidden input |
|
142 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->additionalAttendeeRegInfoInput( |
|
143 | + $registration |
|
144 | + ); |
|
145 | + |
|
146 | + // If we have question groups for additional attendees, then display the copy options |
|
147 | + $enablePrintCopyInfo( |
|
148 | + apply_filters( |
|
149 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
150 | + $attendee_nmbr > 1 && $copy_attendee_info, |
|
151 | + $attendee_nmbr |
|
152 | + ) |
|
153 | + ); |
|
154 | + |
|
155 | + if ($registration->is_primary_registrant()) { |
|
156 | + // generate hidden input |
|
157 | + $form_args['subsections']['primary_registrant'] = $this->additionalPrimaryRegistrantInputs( |
|
158 | + $registration |
|
159 | + ); |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + $attendee_nmbr++; |
|
164 | + |
|
165 | + // Increment the reg forms number if form is valid. |
|
166 | + if (! empty($form_args)) { |
|
167 | + $this->has_questions = true; |
|
168 | + } |
|
169 | + |
|
170 | + return $form_args; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @param EE_Registration $registration |
|
176 | + * @return EE_Form_Input_Base |
|
177 | + * @throws EE_Error |
|
178 | + */ |
|
179 | + private function additionalAttendeeRegInfoInput(EE_Registration $registration) |
|
180 | + { |
|
181 | + // generate hidden input |
|
182 | + return new EE_Hidden_Input( |
|
183 | + [ |
|
184 | + 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
185 | + 'default' => true, |
|
186 | + ] |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param EE_Registration $registration |
|
193 | + * @return EE_Form_Input_Base |
|
194 | + * @throws EE_Error |
|
195 | + */ |
|
196 | + private function additionalPrimaryRegistrantInputs(EE_Registration $registration) |
|
197 | + { |
|
198 | + // generate hidden input |
|
199 | + return new EE_Hidden_Input( |
|
200 | + [ |
|
201 | + 'html_id' => 'primary_registrant', |
|
202 | + 'default' => $registration->reg_url_link(), |
|
203 | + ] |
|
204 | + ); |
|
205 | + } |
|
206 | 206 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $form_args = []; |
82 | 82 | // verify that registration has valid event |
83 | 83 | if ($registration->event() instanceof EE_Event) { |
84 | - $field_name = 'Event_Question_Group.' . $this->event_question_group_model->fieldNameForContext( |
|
84 | + $field_name = 'Event_Question_Group.'.$this->event_question_group_model->fieldNameForContext( |
|
85 | 85 | $registration->is_primary_registrant() |
86 | 86 | ); |
87 | 87 | $question_groups = $registration->event()->question_groups( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | if ($question_groups) { |
104 | 104 | // array of params to pass to parent constructor |
105 | 105 | $form_args = [ |
106 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
106 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
107 | 107 | 'html_class' => 'ee-reg-form-attendee-dv', |
108 | 108 | 'html_style' => $admin_request |
109 | 109 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | QuestionGroupRegForm::class, |
130 | 130 | [$registration, $question_group, $admin_request] |
131 | 131 | ); |
132 | - $form_args['subsections'][ $question_group->identifier() ] = apply_filters( |
|
132 | + $form_args['subsections'][$question_group->identifier()] = apply_filters( |
|
133 | 133 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
134 | 134 | $question_group_reg_form, |
135 | 135 | $registration, |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $attendee_nmbr++; |
164 | 164 | |
165 | 165 | // Increment the reg forms number if form is valid. |
166 | - if (! empty($form_args)) { |
|
166 | + if ( ! empty($form_args)) { |
|
167 | 167 | $this->has_questions = true; |
168 | 168 | } |
169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | // generate hidden input |
182 | 182 | return new EE_Hidden_Input( |
183 | 183 | [ |
184 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
184 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
185 | 185 | 'default' => true, |
186 | 186 | ] |
187 | 187 | ); |