@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use EventEspresso\core\services\loaders\LoaderInterface; |
| 6 | 6 | |
| 7 | 7 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 8 | - exit('No direct script access allowed'); |
|
| 8 | + exit('No direct script access allowed'); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | |
@@ -22,805 +22,805 @@ discard block |
||
| 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 | - |
|
| 56 | - /** |
|
| 57 | - * @type EE_Dependency_Map $_instance |
|
| 58 | - */ |
|
| 59 | - protected static $_instance; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @type EE_Request $request |
|
| 63 | - */ |
|
| 64 | - protected $_request; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @type EE_Response $response |
|
| 68 | - */ |
|
| 69 | - protected $_response; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @type LoaderInterface $loader |
|
| 73 | - */ |
|
| 74 | - protected $loader; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @type array $_dependency_map |
|
| 78 | - */ |
|
| 79 | - protected $_dependency_map = array(); |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @type array $_class_loaders |
|
| 83 | - */ |
|
| 84 | - protected $_class_loaders = array(); |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @type array $_aliases |
|
| 88 | - */ |
|
| 89 | - protected $_aliases = array(); |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * EE_Dependency_Map constructor. |
|
| 95 | - * |
|
| 96 | - * @param EE_Request $request |
|
| 97 | - * @param EE_Response $response |
|
| 98 | - */ |
|
| 99 | - protected function __construct(EE_Request $request, EE_Response $response) |
|
| 100 | - { |
|
| 101 | - $this->_request = $request; |
|
| 102 | - $this->_response = $response; |
|
| 103 | - add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 104 | - do_action('EE_Dependency_Map____construct'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @throws InvalidDataTypeException |
|
| 111 | - * @throws InvalidInterfaceException |
|
| 112 | - * @throws InvalidArgumentException |
|
| 113 | - */ |
|
| 114 | - public function initialize() |
|
| 115 | - { |
|
| 116 | - $this->_register_core_dependencies(); |
|
| 117 | - $this->_register_core_class_loaders(); |
|
| 118 | - $this->_register_core_aliases(); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @singleton method used to instantiate class object |
|
| 125 | - * @access public |
|
| 126 | - * @param EE_Request $request |
|
| 127 | - * @param EE_Response $response |
|
| 128 | - * @return EE_Dependency_Map |
|
| 129 | - */ |
|
| 130 | - public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
| 131 | - { |
|
| 132 | - // check if class object is instantiated, and instantiated properly |
|
| 133 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
| 134 | - self::$_instance = new EE_Dependency_Map($request, $response); |
|
| 135 | - } |
|
| 136 | - return self::$_instance; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param LoaderInterface $loader |
|
| 143 | - */ |
|
| 144 | - public function setLoader(LoaderInterface $loader) |
|
| 145 | - { |
|
| 146 | - $this->loader = $loader; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @param string $class |
|
| 153 | - * @param array $dependencies |
|
| 154 | - * @param int $overwrite |
|
| 155 | - * @return bool |
|
| 156 | - */ |
|
| 157 | - public static function register_dependencies( |
|
| 158 | - $class, |
|
| 159 | - array $dependencies, |
|
| 160 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 161 | - ) { |
|
| 162 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 169 | - * to the class specified by the first parameter. |
|
| 170 | - * IMPORTANT !!! |
|
| 171 | - * The order of elements in the incoming $dependencies array MUST match |
|
| 172 | - * the order of the constructor parameters for the class in question. |
|
| 173 | - * This is especially important when overriding any existing dependencies that are registered. |
|
| 174 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 175 | - * |
|
| 176 | - * @param string $class |
|
| 177 | - * @param array $dependencies |
|
| 178 | - * @param int $overwrite |
|
| 179 | - * @return bool |
|
| 180 | - */ |
|
| 181 | - public function registerDependencies( |
|
| 182 | - $class, |
|
| 183 | - array $dependencies, |
|
| 184 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 185 | - ) { |
|
| 186 | - $class = trim($class, '\\'); |
|
| 187 | - $registered = false; |
|
| 188 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 189 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
| 190 | - } |
|
| 191 | - // we need to make sure that any aliases used when registering a dependency |
|
| 192 | - // get resolved to the correct class name |
|
| 193 | - foreach ((array)$dependencies as $dependency => $load_source) { |
|
| 194 | - $alias = self::$_instance->get_alias($dependency); |
|
| 195 | - if ( |
|
| 196 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 197 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 198 | - ) { |
|
| 199 | - unset($dependencies[$dependency]); |
|
| 200 | - $dependencies[$alias] = $load_source; |
|
| 201 | - $registered = true; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - // now add our two lists of dependencies together. |
|
| 205 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 206 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 207 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 208 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 209 | - // especially with numerically indexed arrays |
|
| 210 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 211 | - // now we need to ensure that the resulting dependencies |
|
| 212 | - // array only has the entries that are required for the class |
|
| 213 | - // so first count how many dependencies were originally registered for the class |
|
| 214 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 215 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 216 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 217 | - // then truncate the final array to match that count |
|
| 218 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 219 | - // otherwise just take the incoming array because nothing previously existed |
|
| 220 | - : $dependencies; |
|
| 221 | - return $registered; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * @param string $class_name |
|
| 228 | - * @param string $loader |
|
| 229 | - * @return bool |
|
| 230 | - * @throws DomainException |
|
| 231 | - */ |
|
| 232 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 233 | - { |
|
| 234 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 235 | - throw new DomainException( |
|
| 236 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 240 | - if ( |
|
| 241 | - ! is_callable($loader) |
|
| 242 | - && ( |
|
| 243 | - strpos($loader, 'load_') !== 0 |
|
| 244 | - || ! method_exists('EE_Registry', $loader) |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - throw new DomainException( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $loader |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - $class_name = self::$_instance->get_alias($class_name); |
|
| 258 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 259 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 260 | - return true; |
|
| 261 | - } |
|
| 262 | - return false; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * @return array |
|
| 269 | - */ |
|
| 270 | - public function dependency_map() |
|
| 271 | - { |
|
| 272 | - return $this->_dependency_map; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 279 | - * |
|
| 280 | - * @param string $class_name |
|
| 281 | - * @return boolean |
|
| 282 | - */ |
|
| 283 | - public function has($class_name = '') |
|
| 284 | - { |
|
| 285 | - // all legacy models have the same dependencies |
|
| 286 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 287 | - $class_name = 'LEGACY_MODELS'; |
|
| 288 | - } |
|
| 289 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 296 | - * |
|
| 297 | - * @param string $class_name |
|
| 298 | - * @param string $dependency |
|
| 299 | - * @return bool |
|
| 300 | - */ |
|
| 301 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 302 | - { |
|
| 303 | - // all legacy models have the same dependencies |
|
| 304 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 305 | - $class_name = 'LEGACY_MODELS'; |
|
| 306 | - } |
|
| 307 | - $dependency = $this->get_alias($dependency); |
|
| 308 | - return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
| 309 | - ? true |
|
| 310 | - : false; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 317 | - * |
|
| 318 | - * @param string $class_name |
|
| 319 | - * @param string $dependency |
|
| 320 | - * @return int |
|
| 321 | - */ |
|
| 322 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 323 | - { |
|
| 324 | - // all legacy models have the same dependencies |
|
| 325 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 326 | - $class_name = 'LEGACY_MODELS'; |
|
| 327 | - } |
|
| 328 | - $dependency = $this->get_alias($dependency); |
|
| 329 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 330 | - ? $this->_dependency_map[$class_name][$dependency] |
|
| 331 | - : EE_Dependency_Map::not_registered; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @param string $class_name |
|
| 338 | - * @return string | Closure |
|
| 339 | - */ |
|
| 340 | - public function class_loader($class_name) |
|
| 341 | - { |
|
| 342 | - // all legacy models use load_model() |
|
| 343 | - if(strpos($class_name, 'EEM_') === 0){ |
|
| 344 | - return 'load_model'; |
|
| 345 | - } |
|
| 346 | - $class_name = $this->get_alias($class_name); |
|
| 347 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * @return array |
|
| 354 | - */ |
|
| 355 | - public function class_loaders() |
|
| 356 | - { |
|
| 357 | - return $this->_class_loaders; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * adds an alias for a classname |
|
| 364 | - * |
|
| 365 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
| 366 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 367 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 368 | - */ |
|
| 369 | - public function add_alias($class_name, $alias, $for_class = '') |
|
| 370 | - { |
|
| 371 | - if ($for_class !== '') { |
|
| 372 | - if (! isset($this->_aliases[$for_class])) { |
|
| 373 | - $this->_aliases[$for_class] = array(); |
|
| 374 | - } |
|
| 375 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
| 376 | - } |
|
| 377 | - $this->_aliases[$class_name] = $alias; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * returns TRUE if the provided class name has an alias |
|
| 384 | - * |
|
| 385 | - * @param string $class_name |
|
| 386 | - * @param string $for_class |
|
| 387 | - * @return bool |
|
| 388 | - */ |
|
| 389 | - public function has_alias($class_name = '', $for_class = '') |
|
| 390 | - { |
|
| 391 | - return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
| 392 | - || ( |
|
| 393 | - isset($this->_aliases[$class_name]) |
|
| 394 | - && ! is_array($this->_aliases[$class_name]) |
|
| 395 | - ); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
| 402 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
| 403 | - * for example: |
|
| 404 | - * if the following two entries were added to the _aliases array: |
|
| 405 | - * array( |
|
| 406 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 407 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 408 | - * ) |
|
| 409 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 410 | - * to load an instance of 'some\namespace\classname' |
|
| 411 | - * |
|
| 412 | - * @param string $class_name |
|
| 413 | - * @param string $for_class |
|
| 414 | - * @return string |
|
| 415 | - */ |
|
| 416 | - public function get_alias($class_name = '', $for_class = '') |
|
| 417 | - { |
|
| 418 | - if (! $this->has_alias($class_name, $for_class)) { |
|
| 419 | - return $class_name; |
|
| 420 | - } |
|
| 421 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
| 422 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
| 423 | - } |
|
| 424 | - return $this->get_alias($this->_aliases[$class_name]); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 431 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 432 | - * This is done by using the following class constants: |
|
| 433 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 434 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 435 | - */ |
|
| 436 | - protected function _register_core_dependencies() |
|
| 437 | - { |
|
| 438 | - $this->_dependency_map = array( |
|
| 439 | - 'EE_Request_Handler' => array( |
|
| 440 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 441 | - ), |
|
| 442 | - 'EE_System' => array( |
|
| 443 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 444 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 445 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 446 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 447 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 448 | - ), |
|
| 449 | - 'EE_Session' => array( |
|
| 450 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 451 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 452 | - ), |
|
| 453 | - 'EE_Cart' => array( |
|
| 454 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 455 | - ), |
|
| 456 | - 'EE_Front_Controller' => array( |
|
| 457 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 458 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 459 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 460 | - ), |
|
| 461 | - 'EE_Messenger_Collection_Loader' => array( |
|
| 462 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 463 | - ), |
|
| 464 | - 'EE_Message_Type_Collection_Loader' => array( |
|
| 465 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 466 | - ), |
|
| 467 | - 'EE_Message_Resource_Manager' => array( |
|
| 468 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 469 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 470 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 471 | - ), |
|
| 472 | - 'EE_Message_Factory' => array( |
|
| 473 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 474 | - ), |
|
| 475 | - 'EE_messages' => array( |
|
| 476 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 477 | - ), |
|
| 478 | - 'EE_Messages_Generator' => array( |
|
| 479 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 480 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 481 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 482 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 483 | - ), |
|
| 484 | - 'EE_Messages_Processor' => array( |
|
| 485 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 486 | - ), |
|
| 487 | - 'EE_Messages_Queue' => array( |
|
| 488 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 489 | - ), |
|
| 490 | - 'EE_Messages_Template_Defaults' => array( |
|
| 491 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 492 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 493 | - ), |
|
| 494 | - 'EE_Message_To_Generate_From_Request' => array( |
|
| 495 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 496 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 497 | - ), |
|
| 498 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 499 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 500 | - ), |
|
| 501 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 502 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 503 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 504 | - ), |
|
| 505 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 506 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 507 | - ), |
|
| 508 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 509 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 510 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 511 | - ), |
|
| 512 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 513 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 514 | - ), |
|
| 515 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 516 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 517 | - ), |
|
| 518 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 519 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 520 | - ), |
|
| 521 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 522 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - ), |
|
| 524 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 525 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 526 | - ), |
|
| 527 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 528 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 529 | - ), |
|
| 530 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 531 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 532 | - ), |
|
| 533 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 534 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 535 | - ), |
|
| 536 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 537 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 538 | - ), |
|
| 539 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 540 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 541 | - ), |
|
| 542 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 543 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 544 | - ), |
|
| 545 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 546 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 547 | - ), |
|
| 548 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 549 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 550 | - ), |
|
| 551 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
| 552 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 553 | - ), |
|
| 554 | - 'EE_Data_Migration_Class_Base' => array( |
|
| 555 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 556 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 557 | - ), |
|
| 558 | - 'EE_DMS_Core_4_1_0' => array( |
|
| 559 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 560 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 561 | - ), |
|
| 562 | - 'EE_DMS_Core_4_2_0' => array( |
|
| 563 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 564 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 565 | - ), |
|
| 566 | - 'EE_DMS_Core_4_3_0' => array( |
|
| 567 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 568 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 569 | - ), |
|
| 570 | - 'EE_DMS_Core_4_4_0' => array( |
|
| 571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 572 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 573 | - ), |
|
| 574 | - 'EE_DMS_Core_4_5_0' => array( |
|
| 575 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 576 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 577 | - ), |
|
| 578 | - 'EE_DMS_Core_4_6_0' => array( |
|
| 579 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 580 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 581 | - ), |
|
| 582 | - 'EE_DMS_Core_4_7_0' => array( |
|
| 583 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 584 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 585 | - ), |
|
| 586 | - 'EE_DMS_Core_4_8_0' => array( |
|
| 587 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 588 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 589 | - ), |
|
| 590 | - 'EE_DMS_Core_4_9_0' => array( |
|
| 591 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 592 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 593 | - ), |
|
| 594 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
| 595 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 596 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 597 | - ), |
|
| 598 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 599 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | - ), |
|
| 601 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 602 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 603 | - ), |
|
| 604 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 605 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | - ), |
|
| 607 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 608 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 609 | - ), |
|
| 610 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 611 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | - ), |
|
| 613 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 614 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - ), |
|
| 616 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 617 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 618 | - ), |
|
| 619 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 620 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 621 | - ), |
|
| 622 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 623 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 624 | - ), |
|
| 625 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 626 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 627 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 628 | - ), |
|
| 629 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 630 | - null, |
|
| 631 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 632 | - ), |
|
| 633 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 634 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 635 | - ), |
|
| 636 | - 'LEGACY_MODELS' => array( |
|
| 637 | - null, |
|
| 638 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 639 | - ), |
|
| 640 | - 'EE_Module_Request_Router' => array( |
|
| 641 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 642 | - ), |
|
| 643 | - 'EE_Registration_Processor' => array( |
|
| 644 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 645 | - ), |
|
| 646 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 647 | - null, |
|
| 648 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 649 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 650 | - ), |
|
| 651 | - ); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * Registers how core classes are loaded. |
|
| 658 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 659 | - * 'EE_Request_Handler' => 'load_core' |
|
| 660 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 661 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 662 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 663 | - * 'Some_Class' => function () { |
|
| 664 | - * return new Some_Class(); |
|
| 665 | - * }, |
|
| 666 | - * This is required for instantiating dependencies |
|
| 667 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 668 | - * 'Required_Interface' => function () { |
|
| 669 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 670 | - * }, |
|
| 671 | - * |
|
| 672 | - * @throws InvalidInterfaceException |
|
| 673 | - * @throws InvalidDataTypeException |
|
| 674 | - * @throws InvalidArgumentException |
|
| 675 | - */ |
|
| 676 | - protected function _register_core_class_loaders() |
|
| 677 | - { |
|
| 678 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
| 679 | - //be used in a closure. |
|
| 680 | - $request = &$this->_request; |
|
| 681 | - $response = &$this->_response; |
|
| 682 | - // $loader = &$this->loader; |
|
| 683 | - $this->_class_loaders = array( |
|
| 684 | - //load_core |
|
| 685 | - 'EE_Capabilities' => 'load_core', |
|
| 686 | - 'EE_Encryption' => 'load_core', |
|
| 687 | - 'EE_Front_Controller' => 'load_core', |
|
| 688 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 689 | - 'EE_Registry' => 'load_core', |
|
| 690 | - 'EE_Request' => function () use (&$request) { |
|
| 691 | - return $request; |
|
| 692 | - }, |
|
| 693 | - 'EE_Response' => function () use (&$response) { |
|
| 694 | - return $response; |
|
| 695 | - }, |
|
| 696 | - 'EE_Request_Handler' => 'load_core', |
|
| 697 | - 'EE_Session' => 'load_core', |
|
| 698 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 699 | - 'EE_System' => 'load_core', |
|
| 700 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 701 | - 'EE_Register_CPTs' => 'load_core', |
|
| 702 | - 'EE_Admin' => 'load_core', |
|
| 703 | - //load_lib |
|
| 704 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 705 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 706 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 707 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 708 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 709 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 710 | - 'EE_Message_Repository' => 'load_lib', |
|
| 711 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 712 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 713 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 714 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 715 | - 'EE_Messages_Generator' => function () { |
|
| 716 | - return EE_Registry::instance()->load_lib( |
|
| 717 | - 'Messages_Generator', |
|
| 718 | - array(), |
|
| 719 | - false, |
|
| 720 | - false |
|
| 721 | - ); |
|
| 722 | - }, |
|
| 723 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
| 724 | - return EE_Registry::instance()->load_lib( |
|
| 725 | - 'Messages_Template_Defaults', |
|
| 726 | - $arguments, |
|
| 727 | - false, |
|
| 728 | - false |
|
| 729 | - ); |
|
| 730 | - }, |
|
| 731 | - //load_model |
|
| 732 | - // 'EEM_Attendee' => 'load_model', |
|
| 733 | - // 'EEM_Message_Template_Group' => 'load_model', |
|
| 734 | - // 'EEM_Message_Template' => 'load_model', |
|
| 735 | - //load_helper |
|
| 736 | - 'EEH_Parse_Shortcodes' => function () { |
|
| 737 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 738 | - return new EEH_Parse_Shortcodes(); |
|
| 739 | - } |
|
| 740 | - return null; |
|
| 741 | - }, |
|
| 742 | - 'EE_Template_Config' => function () { |
|
| 743 | - return EE_Config::instance()->template_settings; |
|
| 744 | - }, |
|
| 745 | - 'EE_Currency_Config' => function () { |
|
| 746 | - return EE_Config::instance()->currency; |
|
| 747 | - }, |
|
| 748 | - 'EE_Registration_Config' => function () { |
|
| 749 | - return EE_Config::instance()->registration; |
|
| 750 | - }, |
|
| 751 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
| 752 | - return LoaderFactory::getLoader(); |
|
| 753 | - }, |
|
| 754 | - ); |
|
| 755 | - } |
|
| 756 | - |
|
| 757 | - |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * can be used for supplying alternate names for classes, |
|
| 761 | - * or for connecting interface names to instantiable classes |
|
| 762 | - */ |
|
| 763 | - protected function _register_core_aliases() |
|
| 764 | - { |
|
| 765 | - $this->_aliases = array( |
|
| 766 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 767 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 768 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 769 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 770 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 771 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 772 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 773 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 774 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 775 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 776 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
| 777 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
| 778 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 779 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 780 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 781 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 782 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 783 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 784 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 785 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 786 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 787 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 788 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 789 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 790 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 791 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 792 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 793 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 794 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 795 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 796 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
| 797 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 798 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 799 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 800 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 801 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 802 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 803 | - ); |
|
| 804 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 805 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
| 806 | - } |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - |
|
| 810 | - |
|
| 811 | - /** |
|
| 812 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 813 | - * request Primarily used by unit tests. |
|
| 814 | - * |
|
| 815 | - * @throws InvalidDataTypeException |
|
| 816 | - * @throws InvalidInterfaceException |
|
| 817 | - * @throws InvalidArgumentException |
|
| 818 | - */ |
|
| 819 | - public function reset() |
|
| 820 | - { |
|
| 821 | - $this->_register_core_class_loaders(); |
|
| 822 | - $this->_register_core_dependencies(); |
|
| 823 | - } |
|
| 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 | + |
|
| 56 | + /** |
|
| 57 | + * @type EE_Dependency_Map $_instance |
|
| 58 | + */ |
|
| 59 | + protected static $_instance; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @type EE_Request $request |
|
| 63 | + */ |
|
| 64 | + protected $_request; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @type EE_Response $response |
|
| 68 | + */ |
|
| 69 | + protected $_response; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @type LoaderInterface $loader |
|
| 73 | + */ |
|
| 74 | + protected $loader; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @type array $_dependency_map |
|
| 78 | + */ |
|
| 79 | + protected $_dependency_map = array(); |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @type array $_class_loaders |
|
| 83 | + */ |
|
| 84 | + protected $_class_loaders = array(); |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @type array $_aliases |
|
| 88 | + */ |
|
| 89 | + protected $_aliases = array(); |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * EE_Dependency_Map constructor. |
|
| 95 | + * |
|
| 96 | + * @param EE_Request $request |
|
| 97 | + * @param EE_Response $response |
|
| 98 | + */ |
|
| 99 | + protected function __construct(EE_Request $request, EE_Response $response) |
|
| 100 | + { |
|
| 101 | + $this->_request = $request; |
|
| 102 | + $this->_response = $response; |
|
| 103 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 104 | + do_action('EE_Dependency_Map____construct'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @throws InvalidDataTypeException |
|
| 111 | + * @throws InvalidInterfaceException |
|
| 112 | + * @throws InvalidArgumentException |
|
| 113 | + */ |
|
| 114 | + public function initialize() |
|
| 115 | + { |
|
| 116 | + $this->_register_core_dependencies(); |
|
| 117 | + $this->_register_core_class_loaders(); |
|
| 118 | + $this->_register_core_aliases(); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @singleton method used to instantiate class object |
|
| 125 | + * @access public |
|
| 126 | + * @param EE_Request $request |
|
| 127 | + * @param EE_Response $response |
|
| 128 | + * @return EE_Dependency_Map |
|
| 129 | + */ |
|
| 130 | + public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
| 131 | + { |
|
| 132 | + // check if class object is instantiated, and instantiated properly |
|
| 133 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
| 134 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
| 135 | + } |
|
| 136 | + return self::$_instance; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param LoaderInterface $loader |
|
| 143 | + */ |
|
| 144 | + public function setLoader(LoaderInterface $loader) |
|
| 145 | + { |
|
| 146 | + $this->loader = $loader; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param string $class |
|
| 153 | + * @param array $dependencies |
|
| 154 | + * @param int $overwrite |
|
| 155 | + * @return bool |
|
| 156 | + */ |
|
| 157 | + public static function register_dependencies( |
|
| 158 | + $class, |
|
| 159 | + array $dependencies, |
|
| 160 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 161 | + ) { |
|
| 162 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 169 | + * to the class specified by the first parameter. |
|
| 170 | + * IMPORTANT !!! |
|
| 171 | + * The order of elements in the incoming $dependencies array MUST match |
|
| 172 | + * the order of the constructor parameters for the class in question. |
|
| 173 | + * This is especially important when overriding any existing dependencies that are registered. |
|
| 174 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 175 | + * |
|
| 176 | + * @param string $class |
|
| 177 | + * @param array $dependencies |
|
| 178 | + * @param int $overwrite |
|
| 179 | + * @return bool |
|
| 180 | + */ |
|
| 181 | + public function registerDependencies( |
|
| 182 | + $class, |
|
| 183 | + array $dependencies, |
|
| 184 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 185 | + ) { |
|
| 186 | + $class = trim($class, '\\'); |
|
| 187 | + $registered = false; |
|
| 188 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 189 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
| 190 | + } |
|
| 191 | + // we need to make sure that any aliases used when registering a dependency |
|
| 192 | + // get resolved to the correct class name |
|
| 193 | + foreach ((array)$dependencies as $dependency => $load_source) { |
|
| 194 | + $alias = self::$_instance->get_alias($dependency); |
|
| 195 | + if ( |
|
| 196 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 197 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 198 | + ) { |
|
| 199 | + unset($dependencies[$dependency]); |
|
| 200 | + $dependencies[$alias] = $load_source; |
|
| 201 | + $registered = true; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + // now add our two lists of dependencies together. |
|
| 205 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 206 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 207 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 208 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 209 | + // especially with numerically indexed arrays |
|
| 210 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 211 | + // now we need to ensure that the resulting dependencies |
|
| 212 | + // array only has the entries that are required for the class |
|
| 213 | + // so first count how many dependencies were originally registered for the class |
|
| 214 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 215 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 216 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 217 | + // then truncate the final array to match that count |
|
| 218 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 219 | + // otherwise just take the incoming array because nothing previously existed |
|
| 220 | + : $dependencies; |
|
| 221 | + return $registered; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * @param string $class_name |
|
| 228 | + * @param string $loader |
|
| 229 | + * @return bool |
|
| 230 | + * @throws DomainException |
|
| 231 | + */ |
|
| 232 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 233 | + { |
|
| 234 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 235 | + throw new DomainException( |
|
| 236 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 240 | + if ( |
|
| 241 | + ! is_callable($loader) |
|
| 242 | + && ( |
|
| 243 | + strpos($loader, 'load_') !== 0 |
|
| 244 | + || ! method_exists('EE_Registry', $loader) |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + throw new DomainException( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $loader |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + $class_name = self::$_instance->get_alias($class_name); |
|
| 258 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 259 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 260 | + return true; |
|
| 261 | + } |
|
| 262 | + return false; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * @return array |
|
| 269 | + */ |
|
| 270 | + public function dependency_map() |
|
| 271 | + { |
|
| 272 | + return $this->_dependency_map; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 279 | + * |
|
| 280 | + * @param string $class_name |
|
| 281 | + * @return boolean |
|
| 282 | + */ |
|
| 283 | + public function has($class_name = '') |
|
| 284 | + { |
|
| 285 | + // all legacy models have the same dependencies |
|
| 286 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 287 | + $class_name = 'LEGACY_MODELS'; |
|
| 288 | + } |
|
| 289 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 296 | + * |
|
| 297 | + * @param string $class_name |
|
| 298 | + * @param string $dependency |
|
| 299 | + * @return bool |
|
| 300 | + */ |
|
| 301 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 302 | + { |
|
| 303 | + // all legacy models have the same dependencies |
|
| 304 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 305 | + $class_name = 'LEGACY_MODELS'; |
|
| 306 | + } |
|
| 307 | + $dependency = $this->get_alias($dependency); |
|
| 308 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
| 309 | + ? true |
|
| 310 | + : false; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 317 | + * |
|
| 318 | + * @param string $class_name |
|
| 319 | + * @param string $dependency |
|
| 320 | + * @return int |
|
| 321 | + */ |
|
| 322 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 323 | + { |
|
| 324 | + // all legacy models have the same dependencies |
|
| 325 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 326 | + $class_name = 'LEGACY_MODELS'; |
|
| 327 | + } |
|
| 328 | + $dependency = $this->get_alias($dependency); |
|
| 329 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 330 | + ? $this->_dependency_map[$class_name][$dependency] |
|
| 331 | + : EE_Dependency_Map::not_registered; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @param string $class_name |
|
| 338 | + * @return string | Closure |
|
| 339 | + */ |
|
| 340 | + public function class_loader($class_name) |
|
| 341 | + { |
|
| 342 | + // all legacy models use load_model() |
|
| 343 | + if(strpos($class_name, 'EEM_') === 0){ |
|
| 344 | + return 'load_model'; |
|
| 345 | + } |
|
| 346 | + $class_name = $this->get_alias($class_name); |
|
| 347 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * @return array |
|
| 354 | + */ |
|
| 355 | + public function class_loaders() |
|
| 356 | + { |
|
| 357 | + return $this->_class_loaders; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * adds an alias for a classname |
|
| 364 | + * |
|
| 365 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
| 366 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 367 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 368 | + */ |
|
| 369 | + public function add_alias($class_name, $alias, $for_class = '') |
|
| 370 | + { |
|
| 371 | + if ($for_class !== '') { |
|
| 372 | + if (! isset($this->_aliases[$for_class])) { |
|
| 373 | + $this->_aliases[$for_class] = array(); |
|
| 374 | + } |
|
| 375 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
| 376 | + } |
|
| 377 | + $this->_aliases[$class_name] = $alias; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * returns TRUE if the provided class name has an alias |
|
| 384 | + * |
|
| 385 | + * @param string $class_name |
|
| 386 | + * @param string $for_class |
|
| 387 | + * @return bool |
|
| 388 | + */ |
|
| 389 | + public function has_alias($class_name = '', $for_class = '') |
|
| 390 | + { |
|
| 391 | + return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
| 392 | + || ( |
|
| 393 | + isset($this->_aliases[$class_name]) |
|
| 394 | + && ! is_array($this->_aliases[$class_name]) |
|
| 395 | + ); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
| 402 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
| 403 | + * for example: |
|
| 404 | + * if the following two entries were added to the _aliases array: |
|
| 405 | + * array( |
|
| 406 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 407 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 408 | + * ) |
|
| 409 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 410 | + * to load an instance of 'some\namespace\classname' |
|
| 411 | + * |
|
| 412 | + * @param string $class_name |
|
| 413 | + * @param string $for_class |
|
| 414 | + * @return string |
|
| 415 | + */ |
|
| 416 | + public function get_alias($class_name = '', $for_class = '') |
|
| 417 | + { |
|
| 418 | + if (! $this->has_alias($class_name, $for_class)) { |
|
| 419 | + return $class_name; |
|
| 420 | + } |
|
| 421 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
| 422 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
| 423 | + } |
|
| 424 | + return $this->get_alias($this->_aliases[$class_name]); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 431 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 432 | + * This is done by using the following class constants: |
|
| 433 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 434 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 435 | + */ |
|
| 436 | + protected function _register_core_dependencies() |
|
| 437 | + { |
|
| 438 | + $this->_dependency_map = array( |
|
| 439 | + 'EE_Request_Handler' => array( |
|
| 440 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 441 | + ), |
|
| 442 | + 'EE_System' => array( |
|
| 443 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 444 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 445 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 446 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 447 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 448 | + ), |
|
| 449 | + 'EE_Session' => array( |
|
| 450 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 451 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 452 | + ), |
|
| 453 | + 'EE_Cart' => array( |
|
| 454 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 455 | + ), |
|
| 456 | + 'EE_Front_Controller' => array( |
|
| 457 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 458 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 459 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 460 | + ), |
|
| 461 | + 'EE_Messenger_Collection_Loader' => array( |
|
| 462 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 463 | + ), |
|
| 464 | + 'EE_Message_Type_Collection_Loader' => array( |
|
| 465 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 466 | + ), |
|
| 467 | + 'EE_Message_Resource_Manager' => array( |
|
| 468 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 469 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 470 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 471 | + ), |
|
| 472 | + 'EE_Message_Factory' => array( |
|
| 473 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 474 | + ), |
|
| 475 | + 'EE_messages' => array( |
|
| 476 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 477 | + ), |
|
| 478 | + 'EE_Messages_Generator' => array( |
|
| 479 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 480 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 481 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 482 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 483 | + ), |
|
| 484 | + 'EE_Messages_Processor' => array( |
|
| 485 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 486 | + ), |
|
| 487 | + 'EE_Messages_Queue' => array( |
|
| 488 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 489 | + ), |
|
| 490 | + 'EE_Messages_Template_Defaults' => array( |
|
| 491 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 492 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 493 | + ), |
|
| 494 | + 'EE_Message_To_Generate_From_Request' => array( |
|
| 495 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 496 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 497 | + ), |
|
| 498 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 499 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 500 | + ), |
|
| 501 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 502 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 503 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 504 | + ), |
|
| 505 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 506 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 507 | + ), |
|
| 508 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 509 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 510 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 511 | + ), |
|
| 512 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 513 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 514 | + ), |
|
| 515 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 516 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 517 | + ), |
|
| 518 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 519 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 520 | + ), |
|
| 521 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 522 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + ), |
|
| 524 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 525 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 526 | + ), |
|
| 527 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 528 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 529 | + ), |
|
| 530 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 531 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 532 | + ), |
|
| 533 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 534 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 535 | + ), |
|
| 536 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 537 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 538 | + ), |
|
| 539 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 540 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 541 | + ), |
|
| 542 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 543 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 544 | + ), |
|
| 545 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 546 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 547 | + ), |
|
| 548 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 549 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 550 | + ), |
|
| 551 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
| 552 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 553 | + ), |
|
| 554 | + 'EE_Data_Migration_Class_Base' => array( |
|
| 555 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 556 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 557 | + ), |
|
| 558 | + 'EE_DMS_Core_4_1_0' => array( |
|
| 559 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 560 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 561 | + ), |
|
| 562 | + 'EE_DMS_Core_4_2_0' => array( |
|
| 563 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 564 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 565 | + ), |
|
| 566 | + 'EE_DMS_Core_4_3_0' => array( |
|
| 567 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 568 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 569 | + ), |
|
| 570 | + 'EE_DMS_Core_4_4_0' => array( |
|
| 571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 572 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 573 | + ), |
|
| 574 | + 'EE_DMS_Core_4_5_0' => array( |
|
| 575 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 576 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 577 | + ), |
|
| 578 | + 'EE_DMS_Core_4_6_0' => array( |
|
| 579 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 580 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 581 | + ), |
|
| 582 | + 'EE_DMS_Core_4_7_0' => array( |
|
| 583 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 584 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 585 | + ), |
|
| 586 | + 'EE_DMS_Core_4_8_0' => array( |
|
| 587 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 588 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 589 | + ), |
|
| 590 | + 'EE_DMS_Core_4_9_0' => array( |
|
| 591 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 592 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 593 | + ), |
|
| 594 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
| 595 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 596 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 597 | + ), |
|
| 598 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 599 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | + ), |
|
| 601 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 602 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 603 | + ), |
|
| 604 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 605 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | + ), |
|
| 607 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 608 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 609 | + ), |
|
| 610 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 611 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | + ), |
|
| 613 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 614 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + ), |
|
| 616 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 617 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 618 | + ), |
|
| 619 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 620 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 621 | + ), |
|
| 622 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 623 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 624 | + ), |
|
| 625 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 626 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 627 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 628 | + ), |
|
| 629 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 630 | + null, |
|
| 631 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 632 | + ), |
|
| 633 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 634 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 635 | + ), |
|
| 636 | + 'LEGACY_MODELS' => array( |
|
| 637 | + null, |
|
| 638 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 639 | + ), |
|
| 640 | + 'EE_Module_Request_Router' => array( |
|
| 641 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 642 | + ), |
|
| 643 | + 'EE_Registration_Processor' => array( |
|
| 644 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 645 | + ), |
|
| 646 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 647 | + null, |
|
| 648 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 649 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 650 | + ), |
|
| 651 | + ); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Registers how core classes are loaded. |
|
| 658 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 659 | + * 'EE_Request_Handler' => 'load_core' |
|
| 660 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 661 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 662 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 663 | + * 'Some_Class' => function () { |
|
| 664 | + * return new Some_Class(); |
|
| 665 | + * }, |
|
| 666 | + * This is required for instantiating dependencies |
|
| 667 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 668 | + * 'Required_Interface' => function () { |
|
| 669 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 670 | + * }, |
|
| 671 | + * |
|
| 672 | + * @throws InvalidInterfaceException |
|
| 673 | + * @throws InvalidDataTypeException |
|
| 674 | + * @throws InvalidArgumentException |
|
| 675 | + */ |
|
| 676 | + protected function _register_core_class_loaders() |
|
| 677 | + { |
|
| 678 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
| 679 | + //be used in a closure. |
|
| 680 | + $request = &$this->_request; |
|
| 681 | + $response = &$this->_response; |
|
| 682 | + // $loader = &$this->loader; |
|
| 683 | + $this->_class_loaders = array( |
|
| 684 | + //load_core |
|
| 685 | + 'EE_Capabilities' => 'load_core', |
|
| 686 | + 'EE_Encryption' => 'load_core', |
|
| 687 | + 'EE_Front_Controller' => 'load_core', |
|
| 688 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 689 | + 'EE_Registry' => 'load_core', |
|
| 690 | + 'EE_Request' => function () use (&$request) { |
|
| 691 | + return $request; |
|
| 692 | + }, |
|
| 693 | + 'EE_Response' => function () use (&$response) { |
|
| 694 | + return $response; |
|
| 695 | + }, |
|
| 696 | + 'EE_Request_Handler' => 'load_core', |
|
| 697 | + 'EE_Session' => 'load_core', |
|
| 698 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 699 | + 'EE_System' => 'load_core', |
|
| 700 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 701 | + 'EE_Register_CPTs' => 'load_core', |
|
| 702 | + 'EE_Admin' => 'load_core', |
|
| 703 | + //load_lib |
|
| 704 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 705 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 706 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 707 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 708 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 709 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 710 | + 'EE_Message_Repository' => 'load_lib', |
|
| 711 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 712 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 713 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 714 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 715 | + 'EE_Messages_Generator' => function () { |
|
| 716 | + return EE_Registry::instance()->load_lib( |
|
| 717 | + 'Messages_Generator', |
|
| 718 | + array(), |
|
| 719 | + false, |
|
| 720 | + false |
|
| 721 | + ); |
|
| 722 | + }, |
|
| 723 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
| 724 | + return EE_Registry::instance()->load_lib( |
|
| 725 | + 'Messages_Template_Defaults', |
|
| 726 | + $arguments, |
|
| 727 | + false, |
|
| 728 | + false |
|
| 729 | + ); |
|
| 730 | + }, |
|
| 731 | + //load_model |
|
| 732 | + // 'EEM_Attendee' => 'load_model', |
|
| 733 | + // 'EEM_Message_Template_Group' => 'load_model', |
|
| 734 | + // 'EEM_Message_Template' => 'load_model', |
|
| 735 | + //load_helper |
|
| 736 | + 'EEH_Parse_Shortcodes' => function () { |
|
| 737 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 738 | + return new EEH_Parse_Shortcodes(); |
|
| 739 | + } |
|
| 740 | + return null; |
|
| 741 | + }, |
|
| 742 | + 'EE_Template_Config' => function () { |
|
| 743 | + return EE_Config::instance()->template_settings; |
|
| 744 | + }, |
|
| 745 | + 'EE_Currency_Config' => function () { |
|
| 746 | + return EE_Config::instance()->currency; |
|
| 747 | + }, |
|
| 748 | + 'EE_Registration_Config' => function () { |
|
| 749 | + return EE_Config::instance()->registration; |
|
| 750 | + }, |
|
| 751 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
| 752 | + return LoaderFactory::getLoader(); |
|
| 753 | + }, |
|
| 754 | + ); |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * can be used for supplying alternate names for classes, |
|
| 761 | + * or for connecting interface names to instantiable classes |
|
| 762 | + */ |
|
| 763 | + protected function _register_core_aliases() |
|
| 764 | + { |
|
| 765 | + $this->_aliases = array( |
|
| 766 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 767 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 768 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 769 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 770 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 771 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 772 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 773 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 774 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 775 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 776 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
| 777 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
| 778 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 779 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 780 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 781 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 782 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 783 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 784 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 785 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 786 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 787 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 788 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 789 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 790 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 791 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 792 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 793 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 794 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 795 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 796 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
| 797 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 798 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 799 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 800 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 801 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 802 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 803 | + ); |
|
| 804 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 805 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
| 806 | + } |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + |
|
| 810 | + |
|
| 811 | + /** |
|
| 812 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 813 | + * request Primarily used by unit tests. |
|
| 814 | + * |
|
| 815 | + * @throws InvalidDataTypeException |
|
| 816 | + * @throws InvalidInterfaceException |
|
| 817 | + * @throws InvalidArgumentException |
|
| 818 | + */ |
|
| 819 | + public function reset() |
|
| 820 | + { |
|
| 821 | + $this->_register_core_class_loaders(); |
|
| 822 | + $this->_register_core_dependencies(); |
|
| 823 | + } |
|
| 824 | 824 | |
| 825 | 825 | |
| 826 | 826 | } |