@@ -14,63 +14,63 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class CapCheck implements CapCheckInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var string|array $capability |
|
| 19 | - */ |
|
| 20 | - private $capability; |
|
| 17 | + /** |
|
| 18 | + * @var string|array $capability |
|
| 19 | + */ |
|
| 20 | + private $capability; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var string $context |
|
| 24 | - */ |
|
| 25 | - private $context; |
|
| 22 | + /** |
|
| 23 | + * @var string $context |
|
| 24 | + */ |
|
| 25 | + private $context; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var int|string $ID |
|
| 29 | - */ |
|
| 30 | - private $ID; |
|
| 27 | + /** |
|
| 28 | + * @var int|string $ID |
|
| 29 | + */ |
|
| 30 | + private $ID; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
| 35 | - * or an array of capability strings |
|
| 36 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 37 | - * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 38 | - * @throws InvalidDataTypeException |
|
| 39 | - */ |
|
| 40 | - public function __construct($capability, string $context, $ID = 0) |
|
| 41 | - { |
|
| 42 | - if (! (is_string($capability) || is_array($capability))) { |
|
| 43 | - throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
| 44 | - } |
|
| 45 | - $this->capability = $capability; |
|
| 46 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
| 47 | - $this->ID = $ID; |
|
| 48 | - } |
|
| 33 | + /** |
|
| 34 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
| 35 | + * or an array of capability strings |
|
| 36 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 37 | + * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 38 | + * @throws InvalidDataTypeException |
|
| 39 | + */ |
|
| 40 | + public function __construct($capability, string $context, $ID = 0) |
|
| 41 | + { |
|
| 42 | + if (! (is_string($capability) || is_array($capability))) { |
|
| 43 | + throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
| 44 | + } |
|
| 45 | + $this->capability = $capability; |
|
| 46 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
| 47 | + $this->ID = $ID; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string|array |
|
| 53 | - */ |
|
| 54 | - public function capability() |
|
| 55 | - { |
|
| 56 | - return $this->capability; |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string|array |
|
| 53 | + */ |
|
| 54 | + public function capability() |
|
| 55 | + { |
|
| 56 | + return $this->capability; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - public function context(): string |
|
| 64 | - { |
|
| 65 | - return $this->context; |
|
| 66 | - } |
|
| 60 | + /** |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + public function context(): string |
|
| 64 | + { |
|
| 65 | + return $this->context; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return int|string |
|
| 71 | - */ |
|
| 72 | - public function ID() |
|
| 73 | - { |
|
| 74 | - return $this->ID; |
|
| 75 | - } |
|
| 69 | + /** |
|
| 70 | + * @return int|string |
|
| 71 | + */ |
|
| 72 | + public function ID() |
|
| 73 | + { |
|
| 74 | + return $this->ID; |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function __construct($capability, string $context, $ID = 0) |
| 41 | 41 | { |
| 42 | - if (! (is_string($capability) || is_array($capability))) { |
|
| 42 | + if ( ! (is_string($capability) || is_array($capability))) { |
|
| 43 | 43 | throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
| 44 | 44 | } |
| 45 | 45 | $this->capability = $capability; |
@@ -17,94 +17,94 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class CapabilitiesChecker implements CapabilitiesCheckerInterface |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @type EE_Capabilities $capabilities |
|
| 22 | - */ |
|
| 23 | - private $capabilities; |
|
| 20 | + /** |
|
| 21 | + * @type EE_Capabilities $capabilities |
|
| 22 | + */ |
|
| 23 | + private $capabilities; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * CapabilitiesChecker constructor |
|
| 28 | - * |
|
| 29 | - * @param EE_Capabilities $capabilities |
|
| 30 | - */ |
|
| 31 | - public function __construct(EE_Capabilities $capabilities) |
|
| 32 | - { |
|
| 33 | - $this->capabilities = $capabilities; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * CapabilitiesChecker constructor |
|
| 28 | + * |
|
| 29 | + * @param EE_Capabilities $capabilities |
|
| 30 | + */ |
|
| 31 | + public function __construct(EE_Capabilities $capabilities) |
|
| 32 | + { |
|
| 33 | + $this->capabilities = $capabilities; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @return EE_Capabilities |
|
| 39 | - */ |
|
| 40 | - protected function capabilities(): EE_Capabilities |
|
| 41 | - { |
|
| 42 | - return $this->capabilities; |
|
| 43 | - } |
|
| 37 | + /** |
|
| 38 | + * @return EE_Capabilities |
|
| 39 | + */ |
|
| 40 | + protected function capabilities(): EE_Capabilities |
|
| 41 | + { |
|
| 42 | + return $this->capabilities; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 48 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 49 | - * |
|
| 50 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 51 | - * @param bool $suppress_exceptions |
|
| 52 | - * @return bool |
|
| 53 | - * @throws InvalidClassException |
|
| 54 | - * @throws InsufficientPermissionsException |
|
| 55 | - */ |
|
| 56 | - public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool |
|
| 57 | - { |
|
| 58 | - if (is_array($cap_check)) { |
|
| 59 | - $passed = true; |
|
| 60 | - foreach ($cap_check as $check) { |
|
| 61 | - $passed = $this->processCapCheck($check) ? $passed : false; |
|
| 62 | - } |
|
| 63 | - return $passed; |
|
| 64 | - } |
|
| 65 | - // at this point, $cap_check should be an individual instance of CapCheck |
|
| 66 | - if (! $cap_check instanceof CapCheckInterface) { |
|
| 67 | - if ($suppress_exceptions) { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - throw new InvalidClassException( |
|
| 71 | - '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - // sometimes cap checks are conditional, and no capabilities are required |
|
| 75 | - if ($cap_check instanceof PublicCapabilities) { |
|
| 76 | - return true; |
|
| 77 | - } |
|
| 78 | - $capabilities = (array) $cap_check->capability(); |
|
| 79 | - foreach ($capabilities as $capability) { |
|
| 80 | - if ( |
|
| 81 | - ! $this->capabilities()->current_user_can( |
|
| 82 | - $capability, |
|
| 83 | - $cap_check->context(), |
|
| 84 | - $cap_check->ID() |
|
| 85 | - ) |
|
| 86 | - ) { |
|
| 87 | - if ($suppress_exceptions) { |
|
| 88 | - return false; |
|
| 89 | - } |
|
| 90 | - throw new InsufficientPermissionsException($cap_check->context()); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - return true; |
|
| 94 | - } |
|
| 46 | + /** |
|
| 47 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 48 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 49 | + * |
|
| 50 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 51 | + * @param bool $suppress_exceptions |
|
| 52 | + * @return bool |
|
| 53 | + * @throws InvalidClassException |
|
| 54 | + * @throws InsufficientPermissionsException |
|
| 55 | + */ |
|
| 56 | + public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool |
|
| 57 | + { |
|
| 58 | + if (is_array($cap_check)) { |
|
| 59 | + $passed = true; |
|
| 60 | + foreach ($cap_check as $check) { |
|
| 61 | + $passed = $this->processCapCheck($check) ? $passed : false; |
|
| 62 | + } |
|
| 63 | + return $passed; |
|
| 64 | + } |
|
| 65 | + // at this point, $cap_check should be an individual instance of CapCheck |
|
| 66 | + if (! $cap_check instanceof CapCheckInterface) { |
|
| 67 | + if ($suppress_exceptions) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + throw new InvalidClassException( |
|
| 71 | + '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + // sometimes cap checks are conditional, and no capabilities are required |
|
| 75 | + if ($cap_check instanceof PublicCapabilities) { |
|
| 76 | + return true; |
|
| 77 | + } |
|
| 78 | + $capabilities = (array) $cap_check->capability(); |
|
| 79 | + foreach ($capabilities as $capability) { |
|
| 80 | + if ( |
|
| 81 | + ! $this->capabilities()->current_user_can( |
|
| 82 | + $capability, |
|
| 83 | + $cap_check->context(), |
|
| 84 | + $cap_check->ID() |
|
| 85 | + ) |
|
| 86 | + ) { |
|
| 87 | + if ($suppress_exceptions) { |
|
| 88 | + return false; |
|
| 89 | + } |
|
| 90 | + throw new InsufficientPermissionsException($cap_check->context()); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + return true; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 99 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 100 | - * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 101 | - * @return bool |
|
| 102 | - * @throws InvalidDataTypeException |
|
| 103 | - * @throws InsufficientPermissionsException |
|
| 104 | - * @throws InvalidClassException |
|
| 105 | - */ |
|
| 106 | - public function process($capability, string $context, $ID = 0): bool |
|
| 107 | - { |
|
| 108 | - return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
| 109 | - } |
|
| 97 | + /** |
|
| 98 | + * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 99 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 100 | + * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 101 | + * @return bool |
|
| 102 | + * @throws InvalidDataTypeException |
|
| 103 | + * @throws InsufficientPermissionsException |
|
| 104 | + * @throws InvalidClassException |
|
| 105 | + */ |
|
| 106 | + public function process($capability, string $context, $ID = 0): bool |
|
| 107 | + { |
|
| 108 | + return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
| 109 | + } |
|
| 110 | 110 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | return $passed; |
| 64 | 64 | } |
| 65 | 65 | // at this point, $cap_check should be an individual instance of CapCheck |
| 66 | - if (! $cap_check instanceof CapCheckInterface) { |
|
| 66 | + if ( ! $cap_check instanceof CapCheckInterface) { |
|
| 67 | 67 | if ($suppress_exceptions) { |
| 68 | 68 | return false; |
| 69 | 69 | } |
@@ -15,26 +15,26 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface CapabilitiesCheckerInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 20 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 21 | - * |
|
| 22 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 23 | - * @param bool $suppress_exceptions |
|
| 24 | - * @return bool |
|
| 25 | - * @throws InvalidClassException |
|
| 26 | - * @throws InsufficientPermissionsException |
|
| 27 | - */ |
|
| 28 | - public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool; |
|
| 18 | + /** |
|
| 19 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
| 20 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
| 21 | + * |
|
| 22 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
| 23 | + * @param bool $suppress_exceptions |
|
| 24 | + * @return bool |
|
| 25 | + * @throws InvalidClassException |
|
| 26 | + * @throws InsufficientPermissionsException |
|
| 27 | + */ |
|
| 28 | + public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool; |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 33 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 34 | - * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 35 | - * @return bool |
|
| 36 | - * @throws InsufficientPermissionsException |
|
| 37 | - * @throws InvalidClassException |
|
| 38 | - */ |
|
| 39 | - public function process($capability, string $context, $ID = 0): bool; |
|
| 31 | + /** |
|
| 32 | + * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
| 33 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
| 34 | + * @param int|string $ID - (optional) ID for item where current_user_can is being called from |
|
| 35 | + * @return bool |
|
| 36 | + * @throws InsufficientPermissionsException |
|
| 37 | + * @throws InvalidClassException |
|
| 38 | + */ |
|
| 39 | + public function process($capability, string $context, $ID = 0): bool; |
|
| 40 | 40 | } |
@@ -26,88 +26,88 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class AdminRoute extends Route |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @var EE_Admin_Config $admin_config |
|
| 31 | - */ |
|
| 32 | - protected $admin_config; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var array $default_dependencies |
|
| 36 | - */ |
|
| 37 | - protected static $default_dependencies = [ |
|
| 38 | - 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache, |
|
| 39 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 40 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 41 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Route constructor. |
|
| 47 | - * |
|
| 48 | - * @param EE_Admin_Config $admin_config |
|
| 49 | - * @param EE_Dependency_Map $dependency_map |
|
| 50 | - * @param LoaderInterface $loader |
|
| 51 | - * @param RequestInterface $request |
|
| 52 | - * @param JsonDataNode|null $data_node |
|
| 53 | - * @param RouteMatchSpecificationInterface|null $specification |
|
| 54 | - */ |
|
| 55 | - public function __construct( |
|
| 56 | - EE_Admin_Config $admin_config, |
|
| 57 | - EE_Dependency_Map $dependency_map, |
|
| 58 | - LoaderInterface $loader, |
|
| 59 | - RequestInterface $request, |
|
| 60 | - JsonDataNode $data_node = null, |
|
| 61 | - RouteMatchSpecificationInterface $specification = null |
|
| 62 | - ) { |
|
| 63 | - $this->admin_config = $admin_config; |
|
| 64 | - parent::__construct($dependency_map, $loader, $request, $data_node, $specification); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - public function getCapCheck() |
|
| 69 | - { |
|
| 70 | - return new CapCheck('edit_posts', 'access Event Espresso admin route'); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return array |
|
| 76 | - */ |
|
| 77 | - public static function getDefaultDependencies(): array |
|
| 78 | - { |
|
| 79 | - return self::$default_dependencies; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * returns true if the current request matches this route |
|
| 85 | - * |
|
| 86 | - * @return bool |
|
| 87 | - */ |
|
| 88 | - public function matchesCurrentRequest(): bool |
|
| 89 | - { |
|
| 90 | - return $this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation(); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - protected function registerDependencies() |
|
| 98 | - { |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * implements logic required to run during request |
|
| 104 | - * |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - protected function requestHandler(): bool |
|
| 108 | - { |
|
| 109 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 110 | - $this->loader->getShared('EE_Admin'); |
|
| 111 | - return true; |
|
| 112 | - } |
|
| 29 | + /** |
|
| 30 | + * @var EE_Admin_Config $admin_config |
|
| 31 | + */ |
|
| 32 | + protected $admin_config; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var array $default_dependencies |
|
| 36 | + */ |
|
| 37 | + protected static $default_dependencies = [ |
|
| 38 | + 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache, |
|
| 39 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 40 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 41 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 42 | + ]; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Route constructor. |
|
| 47 | + * |
|
| 48 | + * @param EE_Admin_Config $admin_config |
|
| 49 | + * @param EE_Dependency_Map $dependency_map |
|
| 50 | + * @param LoaderInterface $loader |
|
| 51 | + * @param RequestInterface $request |
|
| 52 | + * @param JsonDataNode|null $data_node |
|
| 53 | + * @param RouteMatchSpecificationInterface|null $specification |
|
| 54 | + */ |
|
| 55 | + public function __construct( |
|
| 56 | + EE_Admin_Config $admin_config, |
|
| 57 | + EE_Dependency_Map $dependency_map, |
|
| 58 | + LoaderInterface $loader, |
|
| 59 | + RequestInterface $request, |
|
| 60 | + JsonDataNode $data_node = null, |
|
| 61 | + RouteMatchSpecificationInterface $specification = null |
|
| 62 | + ) { |
|
| 63 | + $this->admin_config = $admin_config; |
|
| 64 | + parent::__construct($dependency_map, $loader, $request, $data_node, $specification); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + public function getCapCheck() |
|
| 69 | + { |
|
| 70 | + return new CapCheck('edit_posts', 'access Event Espresso admin route'); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | + public static function getDefaultDependencies(): array |
|
| 78 | + { |
|
| 79 | + return self::$default_dependencies; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * returns true if the current request matches this route |
|
| 85 | + * |
|
| 86 | + * @return bool |
|
| 87 | + */ |
|
| 88 | + public function matchesCurrentRequest(): bool |
|
| 89 | + { |
|
| 90 | + return $this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation(); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + protected function registerDependencies() |
|
| 98 | + { |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * implements logic required to run during request |
|
| 104 | + * |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + protected function requestHandler(): bool |
|
| 108 | + { |
|
| 109 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 110 | + $this->loader->getShared('EE_Admin'); |
|
| 111 | + return true; |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -14,30 +14,30 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class EspressoEventsAdmin extends AdminRoute |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * returns true if the current request matches this route |
|
| 19 | - * |
|
| 20 | - * @return bool |
|
| 21 | - * @since $VID:$ |
|
| 22 | - */ |
|
| 23 | - public function matchesCurrentRequest(): bool |
|
| 24 | - { |
|
| 25 | - global $pagenow; |
|
| 26 | - return parent::matchesCurrentRequest() |
|
| 27 | - && $pagenow |
|
| 28 | - && $pagenow === 'admin.php' |
|
| 29 | - && $this->request->getRequestParam('page') === 'espresso_events'; |
|
| 30 | - } |
|
| 17 | + /** |
|
| 18 | + * returns true if the current request matches this route |
|
| 19 | + * |
|
| 20 | + * @return bool |
|
| 21 | + * @since $VID:$ |
|
| 22 | + */ |
|
| 23 | + public function matchesCurrentRequest(): bool |
|
| 24 | + { |
|
| 25 | + global $pagenow; |
|
| 26 | + return parent::matchesCurrentRequest() |
|
| 27 | + && $pagenow |
|
| 28 | + && $pagenow === 'admin.php' |
|
| 29 | + && $this->request->getRequestParam('page') === 'espresso_events'; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @since $VID:$ |
|
| 35 | - */ |
|
| 36 | - protected function registerDependencies() |
|
| 37 | - { |
|
| 38 | - $this->dependency_map->registerDependencies( |
|
| 39 | - 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection', |
|
| 40 | - AdminRoute::getDefaultDependencies() |
|
| 41 | - ); |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * @since $VID:$ |
|
| 35 | + */ |
|
| 36 | + protected function registerDependencies() |
|
| 37 | + { |
|
| 38 | + $this->dependency_map->registerDependencies( |
|
| 39 | + 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection', |
|
| 40 | + AdminRoute::getDefaultDependencies() |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -24,31 +24,31 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | abstract class PublicRoute extends Route |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
| 29 | - */ |
|
| 30 | - protected $maintenance_mode; |
|
| 27 | + /** |
|
| 28 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
| 29 | + */ |
|
| 30 | + protected $maintenance_mode; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * FrontendRequests constructor. |
|
| 35 | - * |
|
| 36 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
| 37 | - * @param EE_Dependency_Map $dependency_map |
|
| 38 | - * @param LoaderInterface $loader |
|
| 39 | - * @param RequestInterface $request |
|
| 40 | - * @param JsonDataNode|null $data_node |
|
| 41 | - * @param RouteMatchSpecificationInterface|null $specification |
|
| 42 | - */ |
|
| 43 | - public function __construct( |
|
| 44 | - EE_Maintenance_Mode $maintenance_mode, |
|
| 45 | - EE_Dependency_Map $dependency_map, |
|
| 46 | - LoaderInterface $loader, |
|
| 47 | - RequestInterface $request, |
|
| 48 | - JsonDataNode $data_node = null, |
|
| 49 | - RouteMatchSpecificationInterface $specification = null |
|
| 50 | - ) { |
|
| 51 | - $this->maintenance_mode = $maintenance_mode; |
|
| 52 | - parent::__construct($dependency_map, $loader, $request, $data_node, $specification); |
|
| 53 | - } |
|
| 33 | + /** |
|
| 34 | + * FrontendRequests constructor. |
|
| 35 | + * |
|
| 36 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
| 37 | + * @param EE_Dependency_Map $dependency_map |
|
| 38 | + * @param LoaderInterface $loader |
|
| 39 | + * @param RequestInterface $request |
|
| 40 | + * @param JsonDataNode|null $data_node |
|
| 41 | + * @param RouteMatchSpecificationInterface|null $specification |
|
| 42 | + */ |
|
| 43 | + public function __construct( |
|
| 44 | + EE_Maintenance_Mode $maintenance_mode, |
|
| 45 | + EE_Dependency_Map $dependency_map, |
|
| 46 | + LoaderInterface $loader, |
|
| 47 | + RequestInterface $request, |
|
| 48 | + JsonDataNode $data_node = null, |
|
| 49 | + RouteMatchSpecificationInterface $specification = null |
|
| 50 | + ) { |
|
| 51 | + $this->maintenance_mode = $maintenance_mode; |
|
| 52 | + parent::__construct($dependency_map, $loader, $request, $data_node, $specification); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -20,1131 +20,1131 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class EE_Dependency_Map |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * This means that the requested class dependency is not present in the dependency map |
|
| 25 | - */ |
|
| 26 | - const not_registered = 0; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 30 | - */ |
|
| 31 | - const load_new_object = 1; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 36 | - */ |
|
| 37 | - const load_from_cache = 2; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * When registering a dependency, |
|
| 41 | - * this indicates to keep any existing dependencies that already exist, |
|
| 42 | - * and simply discard any new dependencies declared in the incoming data |
|
| 43 | - */ |
|
| 44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * When registering a dependency, |
|
| 48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 49 | - */ |
|
| 50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @type EE_Dependency_Map $_instance |
|
| 54 | - */ |
|
| 55 | - protected static $_instance; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var ClassInterfaceCache $class_cache |
|
| 59 | - */ |
|
| 60 | - private $class_cache; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @type RequestInterface $request |
|
| 64 | - */ |
|
| 65 | - protected $request; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @type LegacyRequestInterface $legacy_request |
|
| 69 | - */ |
|
| 70 | - protected $legacy_request; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @type ResponseInterface $response |
|
| 74 | - */ |
|
| 75 | - protected $response; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @type LoaderInterface $loader |
|
| 79 | - */ |
|
| 80 | - protected $loader; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @type array $_dependency_map |
|
| 84 | - */ |
|
| 85 | - protected $_dependency_map = []; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @type array $_class_loaders |
|
| 89 | - */ |
|
| 90 | - protected $_class_loaders = []; |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * EE_Dependency_Map constructor. |
|
| 95 | - * |
|
| 96 | - * @param ClassInterfaceCache $class_cache |
|
| 97 | - */ |
|
| 98 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
| 99 | - { |
|
| 100 | - $this->class_cache = $class_cache; |
|
| 101 | - do_action('EE_Dependency_Map____construct', $this); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return void |
|
| 107 | - * @throws InvalidAliasException |
|
| 108 | - */ |
|
| 109 | - public function initialize() |
|
| 110 | - { |
|
| 111 | - $this->_register_core_dependencies(); |
|
| 112 | - $this->_register_core_class_loaders(); |
|
| 113 | - $this->_register_core_aliases(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @singleton method used to instantiate class object |
|
| 119 | - * @param ClassInterfaceCache|null $class_cache |
|
| 120 | - * @return EE_Dependency_Map |
|
| 121 | - */ |
|
| 122 | - public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
| 123 | - { |
|
| 124 | - // check if class object is instantiated, and instantiated properly |
|
| 125 | - if ( |
|
| 126 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
| 127 | - && $class_cache instanceof ClassInterfaceCache |
|
| 128 | - ) { |
|
| 129 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
| 130 | - } |
|
| 131 | - return EE_Dependency_Map::$_instance; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @param RequestInterface $request |
|
| 137 | - */ |
|
| 138 | - public function setRequest(RequestInterface $request) |
|
| 139 | - { |
|
| 140 | - $this->request = $request; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @param LegacyRequestInterface $legacy_request |
|
| 146 | - */ |
|
| 147 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 148 | - { |
|
| 149 | - $this->legacy_request = $legacy_request; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @param ResponseInterface $response |
|
| 155 | - */ |
|
| 156 | - public function setResponse(ResponseInterface $response) |
|
| 157 | - { |
|
| 158 | - $this->response = $response; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param LoaderInterface $loader |
|
| 164 | - */ |
|
| 165 | - public function setLoader(LoaderInterface $loader) |
|
| 166 | - { |
|
| 167 | - $this->loader = $loader; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @param string $class |
|
| 173 | - * @param array $dependencies |
|
| 174 | - * @param int $overwrite |
|
| 175 | - * @return bool |
|
| 176 | - */ |
|
| 177 | - public static function register_dependencies( |
|
| 178 | - string $class, |
|
| 179 | - array $dependencies, |
|
| 180 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 181 | - ): bool { |
|
| 182 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 188 | - * to the class specified by the first parameter. |
|
| 189 | - * IMPORTANT !!! |
|
| 190 | - * The order of elements in the incoming $dependencies array MUST match |
|
| 191 | - * the order of the constructor parameters for the class in question. |
|
| 192 | - * This is especially important when overriding any existing dependencies that are registered. |
|
| 193 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 194 | - * |
|
| 195 | - * @param string $class |
|
| 196 | - * @param array $dependencies |
|
| 197 | - * @param int $overwrite |
|
| 198 | - * @return bool |
|
| 199 | - */ |
|
| 200 | - public function registerDependencies( |
|
| 201 | - string $class, |
|
| 202 | - array $dependencies, |
|
| 203 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 204 | - ): bool { |
|
| 205 | - $class = trim($class, '\\'); |
|
| 206 | - $registered = false; |
|
| 207 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
| 208 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
| 209 | - } |
|
| 210 | - // we need to make sure that any aliases used when registering a dependency |
|
| 211 | - // get resolved to the correct class name |
|
| 212 | - foreach ($dependencies as $dependency => $load_source) { |
|
| 213 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
| 214 | - if ( |
|
| 215 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 216 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 217 | - ) { |
|
| 218 | - unset($dependencies[ $dependency ]); |
|
| 219 | - $dependencies[ $alias ] = $load_source; |
|
| 220 | - $registered = true; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - // now add our two lists of dependencies together. |
|
| 224 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 225 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 226 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 227 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 228 | - // especially with numerically indexed arrays |
|
| 229 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 230 | - // now we need to ensure that the resulting dependencies |
|
| 231 | - // array only has the entries that are required for the class |
|
| 232 | - // so first count how many dependencies were originally registered for the class |
|
| 233 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 234 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 235 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 236 | - // then truncate the final array to match that count |
|
| 237 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 238 | - // otherwise just take the incoming array because nothing previously existed |
|
| 239 | - : $dependencies; |
|
| 240 | - return $registered; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @param string $class_name |
|
| 246 | - * @param callable|string $loader |
|
| 247 | - * @param bool $overwrite |
|
| 248 | - * @return bool |
|
| 249 | - * @throws DomainException |
|
| 250 | - */ |
|
| 251 | - public static function register_class_loader( |
|
| 252 | - string $class_name, |
|
| 253 | - $loader = 'load_core', |
|
| 254 | - bool $overwrite = false |
|
| 255 | - ): bool { |
|
| 256 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * @param string $class_name |
|
| 262 | - * @param Closure|string $loader |
|
| 263 | - * @param bool $overwrite |
|
| 264 | - * @return bool |
|
| 265 | - * @throws DomainException |
|
| 266 | - */ |
|
| 267 | - public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
| 268 | - { |
|
| 269 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 270 | - throw new DomainException( |
|
| 271 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 272 | - ); |
|
| 273 | - } |
|
| 274 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 275 | - if ( |
|
| 276 | - ! is_callable($loader) |
|
| 277 | - && ( |
|
| 278 | - strpos($loader, 'load_') !== 0 |
|
| 279 | - || ! method_exists('EE_Registry', $loader) |
|
| 280 | - ) |
|
| 281 | - ) { |
|
| 282 | - throw new DomainException( |
|
| 283 | - sprintf( |
|
| 284 | - esc_html__( |
|
| 285 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 286 | - 'event_espresso' |
|
| 287 | - ), |
|
| 288 | - $loader |
|
| 289 | - ) |
|
| 290 | - ); |
|
| 291 | - } |
|
| 292 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 293 | - if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 294 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 295 | - return true; |
|
| 296 | - } |
|
| 297 | - return false; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * @return array |
|
| 303 | - */ |
|
| 304 | - public function dependency_map(): array |
|
| 305 | - { |
|
| 306 | - return $this->_dependency_map; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 312 | - * |
|
| 313 | - * @param string $class_name |
|
| 314 | - * @return boolean |
|
| 315 | - */ |
|
| 316 | - public function has(string $class_name = ''): bool |
|
| 317 | - { |
|
| 318 | - // all legacy models have the same dependencies |
|
| 319 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 320 | - $class_name = 'LEGACY_MODELS'; |
|
| 321 | - } |
|
| 322 | - return isset($this->_dependency_map[ $class_name ]); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 328 | - * |
|
| 329 | - * @param string $class_name |
|
| 330 | - * @param string $dependency |
|
| 331 | - * @return bool |
|
| 332 | - */ |
|
| 333 | - public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
| 334 | - { |
|
| 335 | - // all legacy models have the same dependencies |
|
| 336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 337 | - $class_name = 'LEGACY_MODELS'; |
|
| 338 | - } |
|
| 339 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 340 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 346 | - * |
|
| 347 | - * @param string $class_name |
|
| 348 | - * @param string $dependency |
|
| 349 | - * @return int |
|
| 350 | - */ |
|
| 351 | - public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
| 352 | - { |
|
| 353 | - // all legacy models have the same dependencies |
|
| 354 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 355 | - $class_name = 'LEGACY_MODELS'; |
|
| 356 | - } |
|
| 357 | - $dependency = $this->getFqnForAlias($dependency); |
|
| 358 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 359 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 360 | - : EE_Dependency_Map::not_registered; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * @param string $class_name |
|
| 366 | - * @return string | Closure |
|
| 367 | - */ |
|
| 368 | - public function class_loader(string $class_name) |
|
| 369 | - { |
|
| 370 | - // all legacy models use load_model() |
|
| 371 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 372 | - return 'load_model'; |
|
| 373 | - } |
|
| 374 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 375 | - // perform strpos() first to avoid loading regex every time we load a class |
|
| 376 | - if ( |
|
| 377 | - strpos($class_name, 'EE_CPT_') === 0 |
|
| 378 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 379 | - ) { |
|
| 380 | - return 'load_core'; |
|
| 381 | - } |
|
| 382 | - $class_name = $this->getFqnForAlias($class_name); |
|
| 383 | - return $this->_class_loaders[ $class_name ] ?? ''; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * @return array |
|
| 389 | - */ |
|
| 390 | - public function class_loaders(): array |
|
| 391 | - { |
|
| 392 | - return $this->_class_loaders; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * adds an alias for a classname |
|
| 398 | - * |
|
| 399 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 400 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 401 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 402 | - * @throws InvalidAliasException |
|
| 403 | - */ |
|
| 404 | - public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
| 405 | - { |
|
| 406 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
| 412 | - * WHY? |
|
| 413 | - * Because if a class is type hinting for a concretion, |
|
| 414 | - * then why would we need to find another class to supply it? |
|
| 415 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 416 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 417 | - * Don't go looking for some substitute. |
|
| 418 | - * Whereas if a class is type hinting for an interface... |
|
| 419 | - * then we need to find an actual class to use. |
|
| 420 | - * So the interface IS the alias for some other FQN, |
|
| 421 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 422 | - * represents some other class. |
|
| 423 | - * |
|
| 424 | - * @param string $fqn |
|
| 425 | - * @param string $for_class |
|
| 426 | - * @return bool |
|
| 427 | - */ |
|
| 428 | - public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
| 429 | - { |
|
| 430 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 436 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 437 | - * for example: |
|
| 438 | - * if the following two entries were added to the _aliases array: |
|
| 439 | - * array( |
|
| 440 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 441 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 442 | - * ) |
|
| 443 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 444 | - * to load an instance of 'some\namespace\classname' |
|
| 445 | - * |
|
| 446 | - * @param string $alias |
|
| 447 | - * @param string $for_class |
|
| 448 | - * @return string |
|
| 449 | - */ |
|
| 450 | - public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
| 451 | - { |
|
| 452 | - return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 458 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 459 | - * This is done by using the following class constants: |
|
| 460 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 461 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 462 | - */ |
|
| 463 | - protected function _register_core_dependencies() |
|
| 464 | - { |
|
| 465 | - $this->_dependency_map = [ |
|
| 466 | - 'EE_Admin' => [ |
|
| 467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 468 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 469 | - ], |
|
| 470 | - 'EE_Request_Handler' => [ |
|
| 471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 472 | - 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
| 473 | - ], |
|
| 474 | - 'EE_System' => [ |
|
| 475 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 476 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 477 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 478 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 479 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
| 480 | - ], |
|
| 481 | - 'EE_Session' => [ |
|
| 482 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 483 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 484 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 485 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
| 486 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 487 | - ], |
|
| 488 | - 'EE_Cart' => [ |
|
| 489 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 490 | - ], |
|
| 491 | - 'EE_Messenger_Collection_Loader' => [ |
|
| 492 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 493 | - ], |
|
| 494 | - 'EE_Message_Type_Collection_Loader' => [ |
|
| 495 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 496 | - ], |
|
| 497 | - 'EE_Message_Resource_Manager' => [ |
|
| 498 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 499 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 501 | - ], |
|
| 502 | - 'EE_Message_Factory' => [ |
|
| 503 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 504 | - ], |
|
| 505 | - 'EE_messages' => [ |
|
| 506 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 507 | - ], |
|
| 508 | - 'EE_Messages_Generator' => [ |
|
| 509 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 510 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 511 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 512 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 513 | - ], |
|
| 514 | - 'EE_Messages_Processor' => [ |
|
| 515 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 516 | - ], |
|
| 517 | - 'EE_Messages_Queue' => [ |
|
| 518 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 519 | - ], |
|
| 520 | - 'EE_Messages_Template_Defaults' => [ |
|
| 521 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 522 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - ], |
|
| 524 | - 'EE_Message_To_Generate_From_Request' => [ |
|
| 525 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 526 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 527 | - ], |
|
| 528 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 529 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 530 | - ], |
|
| 531 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 532 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 533 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 534 | - ], |
|
| 535 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 536 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 537 | - ], |
|
| 538 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 539 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 540 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 541 | - ], |
|
| 542 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 543 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 544 | - ], |
|
| 545 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 546 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 547 | - ], |
|
| 548 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 549 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 550 | - ], |
|
| 551 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 552 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 553 | - ], |
|
| 554 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 555 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | - ], |
|
| 557 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 558 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 559 | - ], |
|
| 560 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 561 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 562 | - ], |
|
| 563 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 564 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 565 | - ], |
|
| 566 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 567 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 568 | - ], |
|
| 569 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 570 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 571 | - ], |
|
| 572 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 573 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 574 | - ], |
|
| 575 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 576 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 577 | - ], |
|
| 578 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 579 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 580 | - ], |
|
| 581 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
| 582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | - ], |
|
| 584 | - 'EE_Data_Migration_Class_Base' => [ |
|
| 585 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 586 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 587 | - ], |
|
| 588 | - 'EE_DMS_Core_4_1_0' => [ |
|
| 589 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 590 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 591 | - ], |
|
| 592 | - 'EE_DMS_Core_4_2_0' => [ |
|
| 593 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 594 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 595 | - ], |
|
| 596 | - 'EE_DMS_Core_4_3_0' => [ |
|
| 597 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 598 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 599 | - ], |
|
| 600 | - 'EE_DMS_Core_4_4_0' => [ |
|
| 601 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 602 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 603 | - ], |
|
| 604 | - 'EE_DMS_Core_4_5_0' => [ |
|
| 605 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 606 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 607 | - ], |
|
| 608 | - 'EE_DMS_Core_4_6_0' => [ |
|
| 609 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 610 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 611 | - ], |
|
| 612 | - 'EE_DMS_Core_4_7_0' => [ |
|
| 613 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 614 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - ], |
|
| 616 | - 'EE_DMS_Core_4_8_0' => [ |
|
| 617 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 618 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 619 | - ], |
|
| 620 | - 'EE_DMS_Core_4_9_0' => [ |
|
| 621 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 622 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 623 | - ], |
|
| 624 | - 'EE_DMS_Core_4_10_0' => [ |
|
| 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 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 628 | - ], |
|
| 629 | - 'EE_DMS_Core_4_11_0' => [ |
|
| 630 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
| 631 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 632 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 633 | - ], |
|
| 634 | - 'EE_DMS_Core_4_12_0' => [ |
|
| 635 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
| 636 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 637 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 638 | - ], |
|
| 639 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
| 640 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 641 | - ], |
|
| 642 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
| 643 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 644 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
| 645 | - ], |
|
| 646 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
| 647 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 648 | - ], |
|
| 649 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
| 650 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 651 | - ], |
|
| 652 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
| 653 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 654 | - ], |
|
| 655 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
| 656 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 657 | - ], |
|
| 658 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
| 659 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 660 | - ], |
|
| 661 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
| 662 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 663 | - ], |
|
| 664 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
| 665 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 666 | - ], |
|
| 667 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 668 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 669 | - ], |
|
| 670 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 671 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 672 | - ], |
|
| 673 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 674 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 675 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 676 | - ], |
|
| 677 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 678 | - null, |
|
| 679 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 680 | - ], |
|
| 681 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 682 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 683 | - ], |
|
| 684 | - 'LEGACY_MODELS' => [ |
|
| 685 | - null, |
|
| 686 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 687 | - ], |
|
| 688 | - 'EE_Module_Request_Router' => [ |
|
| 689 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 690 | - ], |
|
| 691 | - 'EE_Registration_Processor' => [ |
|
| 692 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 693 | - ], |
|
| 694 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 695 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 696 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 697 | - ], |
|
| 698 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 699 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 700 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 701 | - ], |
|
| 702 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
| 703 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 704 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 705 | - 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
| 706 | - ], |
|
| 707 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 708 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 709 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 710 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 711 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 712 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 713 | - ], |
|
| 714 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 715 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 716 | - ], |
|
| 717 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 718 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 719 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 720 | - ], |
|
| 721 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 722 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 723 | - ], |
|
| 724 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 725 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 726 | - ], |
|
| 727 | - 'EE_CPT_Strategy' => [ |
|
| 728 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 729 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 730 | - ], |
|
| 731 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 732 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 733 | - ], |
|
| 734 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 735 | - null, |
|
| 736 | - null, |
|
| 737 | - null, |
|
| 738 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 739 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 740 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 741 | - ], |
|
| 742 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 743 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 744 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 745 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 746 | - ], |
|
| 747 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 748 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 749 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 750 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 751 | - ], |
|
| 752 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 753 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 754 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 755 | - ], |
|
| 756 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 757 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 758 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 759 | - ], |
|
| 760 | - 'EE_URL_Validation_Strategy' => [ |
|
| 761 | - null, |
|
| 762 | - null, |
|
| 763 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
| 764 | - ], |
|
| 765 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 766 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 767 | - ], |
|
| 768 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 769 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 770 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 771 | - ], |
|
| 772 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 773 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 774 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 775 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 776 | - null, |
|
| 777 | - ], |
|
| 778 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 779 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 780 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 781 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 782 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 783 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 784 | - ], |
|
| 785 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 786 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 787 | - ], |
|
| 788 | - 'EventEspresso\core\services\routing\Router' => [ |
|
| 789 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 790 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 791 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
| 792 | - ], |
|
| 793 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
| 794 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 795 | - ], |
|
| 796 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
| 797 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 798 | - ], |
|
| 799 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
| 800 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
| 801 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 802 | - ], |
|
| 803 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
| 804 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 805 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 806 | - ], |
|
| 807 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
| 808 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
| 809 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
| 810 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
| 811 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
| 812 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
| 813 | - ], |
|
| 814 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
| 815 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 816 | - ], |
|
| 817 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
| 818 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 819 | - ], |
|
| 820 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
| 821 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 822 | - ], |
|
| 823 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
| 824 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 825 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 826 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 827 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 828 | - ], |
|
| 829 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
| 830 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 831 | - ], |
|
| 832 | - 'EventEspresso\core\services\request\CurrentPage' => [ |
|
| 833 | - 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
| 834 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 835 | - ], |
|
| 836 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
| 837 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 838 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 839 | - ], |
|
| 840 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
| 841 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
| 842 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 843 | - ], |
|
| 844 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
| 845 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
| 846 | - ], |
|
| 847 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
| 848 | - 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
| 849 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
| 850 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
| 851 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
| 852 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
| 853 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
| 854 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
| 855 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
| 856 | - ], |
|
| 857 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
| 858 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 859 | - ], |
|
| 860 | - 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
| 861 | - 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
| 862 | - ], |
|
| 863 | - 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
| 864 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 865 | - ], |
|
| 866 | - ]; |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - |
|
| 870 | - /** |
|
| 871 | - * Registers how core classes are loaded. |
|
| 872 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 873 | - * 'EE_Request_Handler' => 'load_core' |
|
| 874 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 875 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 876 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 877 | - * 'Some_Class' => function () { |
|
| 878 | - * return new Some_Class(); |
|
| 879 | - * }, |
|
| 880 | - * This is required for instantiating dependencies |
|
| 881 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 882 | - * 'Required_Interface' => function () { |
|
| 883 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 884 | - * }, |
|
| 885 | - */ |
|
| 886 | - protected function _register_core_class_loaders() |
|
| 887 | - { |
|
| 888 | - $this->_class_loaders = [ |
|
| 889 | - // load_core |
|
| 890 | - 'EE_Dependency_Map' => function () { |
|
| 891 | - return $this; |
|
| 892 | - }, |
|
| 893 | - 'EE_Capabilities' => 'load_core', |
|
| 894 | - 'EE_Encryption' => 'load_core', |
|
| 895 | - 'EE_Front_Controller' => 'load_core', |
|
| 896 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 897 | - 'EE_Registry' => 'load_core', |
|
| 898 | - 'EE_Request' => function () { |
|
| 899 | - return $this->legacy_request; |
|
| 900 | - }, |
|
| 901 | - 'EventEspresso\core\services\request\Request' => function () { |
|
| 902 | - return $this->request; |
|
| 903 | - }, |
|
| 904 | - 'EventEspresso\core\services\request\Response' => function () { |
|
| 905 | - return $this->response; |
|
| 906 | - }, |
|
| 907 | - 'EE_Base' => 'load_core', |
|
| 908 | - 'EE_Request_Handler' => 'load_core', |
|
| 909 | - 'EE_Session' => 'load_core', |
|
| 910 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 911 | - 'EE_System' => 'load_core', |
|
| 912 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 913 | - 'EE_Register_CPTs' => 'load_core', |
|
| 914 | - 'EE_Admin' => 'load_core', |
|
| 915 | - 'EE_CPT_Strategy' => 'load_core', |
|
| 916 | - // load_class |
|
| 917 | - 'EE_Registration_Processor' => 'load_class', |
|
| 918 | - // load_lib |
|
| 919 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 920 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 921 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 922 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 923 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 924 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 925 | - 'EE_Message_Repository' => 'load_lib', |
|
| 926 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 927 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 928 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 929 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 930 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 931 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 932 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 933 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 934 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 935 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 936 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 937 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 938 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 939 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
| 940 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
| 941 | - 'EE_Messages_Generator' => static function () { |
|
| 942 | - return EE_Registry::instance()->load_lib( |
|
| 943 | - 'Messages_Generator', |
|
| 944 | - [], |
|
| 945 | - false, |
|
| 946 | - false |
|
| 947 | - ); |
|
| 948 | - }, |
|
| 949 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 950 | - return EE_Registry::instance()->load_lib( |
|
| 951 | - 'Messages_Template_Defaults', |
|
| 952 | - $arguments, |
|
| 953 | - false, |
|
| 954 | - false |
|
| 955 | - ); |
|
| 956 | - }, |
|
| 957 | - // load_helper |
|
| 958 | - 'EEH_Parse_Shortcodes' => static function () { |
|
| 959 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 960 | - return new EEH_Parse_Shortcodes(); |
|
| 961 | - } |
|
| 962 | - return null; |
|
| 963 | - }, |
|
| 964 | - 'EE_Template_Config' => static function () { |
|
| 965 | - return EE_Config::instance()->template_settings; |
|
| 966 | - }, |
|
| 967 | - 'EE_Currency_Config' => static function () { |
|
| 968 | - return EE_Currency_Config::getCurrencyConfig(); |
|
| 969 | - }, |
|
| 970 | - 'EE_Registration_Config' => static function () { |
|
| 971 | - return EE_Config::instance()->registration; |
|
| 972 | - }, |
|
| 973 | - 'EE_Core_Config' => static function () { |
|
| 974 | - return EE_Config::instance()->core; |
|
| 975 | - }, |
|
| 976 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 977 | - return LoaderFactory::getLoader(); |
|
| 978 | - }, |
|
| 979 | - 'EE_Network_Config' => static function () { |
|
| 980 | - return EE_Network_Config::instance(); |
|
| 981 | - }, |
|
| 982 | - 'EE_Config' => static function () { |
|
| 983 | - return EE_Config::instance(); |
|
| 984 | - }, |
|
| 985 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
| 986 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
| 987 | - }, |
|
| 988 | - 'EE_Admin_Config' => static function () { |
|
| 989 | - return EE_Config::instance()->admin; |
|
| 990 | - }, |
|
| 991 | - 'EE_Organization_Config' => static function () { |
|
| 992 | - return EE_Config::instance()->organization; |
|
| 993 | - }, |
|
| 994 | - 'EE_Network_Core_Config' => static function () { |
|
| 995 | - return EE_Network_Config::instance()->core; |
|
| 996 | - }, |
|
| 997 | - 'EE_Environment_Config' => static function () { |
|
| 998 | - return EE_Config::instance()->environment; |
|
| 999 | - }, |
|
| 1000 | - 'EED_Core_Rest_Api' => static function () { |
|
| 1001 | - return EED_Core_Rest_Api::instance(); |
|
| 1002 | - }, |
|
| 1003 | - 'WP_REST_Server' => static function () { |
|
| 1004 | - return rest_get_server(); |
|
| 1005 | - }, |
|
| 1006 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
| 1007 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
| 1008 | - }, |
|
| 1009 | - 'EE_Ticket_Selector_Config' => function () { |
|
| 1010 | - return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
| 1011 | - }, |
|
| 1012 | - ]; |
|
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - |
|
| 1016 | - /** |
|
| 1017 | - * can be used for supplying alternate names for classes, |
|
| 1018 | - * or for connecting interface names to instantiable classes |
|
| 1019 | - * |
|
| 1020 | - * @throws InvalidAliasException |
|
| 1021 | - */ |
|
| 1022 | - protected function _register_core_aliases() |
|
| 1023 | - { |
|
| 1024 | - $aliases = [ |
|
| 1025 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 1026 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 1027 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 1028 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 1029 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 1030 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 1031 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1032 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 1033 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1034 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 1035 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1036 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 1037 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 1038 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 1039 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 1040 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 1041 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 1042 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 1043 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 1044 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 1045 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1046 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 1047 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1048 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 1049 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 1050 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 1051 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 1052 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 1053 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 1054 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 1055 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 1056 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 1057 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 1058 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 1059 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1060 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1061 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1062 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1063 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
| 1064 | - ]; |
|
| 1065 | - foreach ($aliases as $alias => $fqn) { |
|
| 1066 | - if (is_array($fqn)) { |
|
| 1067 | - foreach ($fqn as $class => $for_class) { |
|
| 1068 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1069 | - } |
|
| 1070 | - continue; |
|
| 1071 | - } |
|
| 1072 | - $this->class_cache->addAlias($fqn, $alias); |
|
| 1073 | - } |
|
| 1074 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1075 | - $this->class_cache->addAlias( |
|
| 1076 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1077 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1078 | - ); |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - |
|
| 1083 | - public function debug($for_class = '') |
|
| 1084 | - { |
|
| 1085 | - if (method_exists($this->class_cache, 'debug')) { |
|
| 1086 | - $this->class_cache->debug($for_class); |
|
| 1087 | - } |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - |
|
| 1091 | - /** |
|
| 1092 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1093 | - * request Primarily used by unit tests. |
|
| 1094 | - */ |
|
| 1095 | - public function reset() |
|
| 1096 | - { |
|
| 1097 | - $this->_register_core_class_loaders(); |
|
| 1098 | - $this->_register_core_dependencies(); |
|
| 1099 | - } |
|
| 1100 | - |
|
| 1101 | - |
|
| 1102 | - /** |
|
| 1103 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1104 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1105 | - * WHY? |
|
| 1106 | - * Because if a class is type hinting for a concretion, |
|
| 1107 | - * then why would we need to find another class to supply it? |
|
| 1108 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1109 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1110 | - * Don't go looking for some substitute. |
|
| 1111 | - * Whereas if a class is type hinting for an interface... |
|
| 1112 | - * then we need to find an actual class to use. |
|
| 1113 | - * So the interface IS the alias for some other FQN, |
|
| 1114 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1115 | - * represents some other class. |
|
| 1116 | - * |
|
| 1117 | - * @param string $fqn |
|
| 1118 | - * @param string $for_class |
|
| 1119 | - * @return bool |
|
| 1120 | - * @deprecated 4.9.62.p |
|
| 1121 | - */ |
|
| 1122 | - public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
| 1123 | - { |
|
| 1124 | - return $this->isAlias($fqn, $for_class); |
|
| 1125 | - } |
|
| 1126 | - |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1130 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1131 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1132 | - * for example: |
|
| 1133 | - * if the following two entries were added to the _aliases array: |
|
| 1134 | - * array( |
|
| 1135 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 1136 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1137 | - * ) |
|
| 1138 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1139 | - * to load an instance of 'some\namespace\classname' |
|
| 1140 | - * |
|
| 1141 | - * @param string $alias |
|
| 1142 | - * @param string $for_class |
|
| 1143 | - * @return string |
|
| 1144 | - * @deprecated 4.9.62.p |
|
| 1145 | - */ |
|
| 1146 | - public function get_alias(string $alias = '', string $for_class = ''): string |
|
| 1147 | - { |
|
| 1148 | - return $this->getFqnForAlias($alias, $for_class); |
|
| 1149 | - } |
|
| 23 | + /** |
|
| 24 | + * This means that the requested class dependency is not present in the dependency map |
|
| 25 | + */ |
|
| 26 | + const not_registered = 0; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 30 | + */ |
|
| 31 | + const load_new_object = 1; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 36 | + */ |
|
| 37 | + const load_from_cache = 2; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * When registering a dependency, |
|
| 41 | + * this indicates to keep any existing dependencies that already exist, |
|
| 42 | + * and simply discard any new dependencies declared in the incoming data |
|
| 43 | + */ |
|
| 44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * When registering a dependency, |
|
| 48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 49 | + */ |
|
| 50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @type EE_Dependency_Map $_instance |
|
| 54 | + */ |
|
| 55 | + protected static $_instance; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var ClassInterfaceCache $class_cache |
|
| 59 | + */ |
|
| 60 | + private $class_cache; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @type RequestInterface $request |
|
| 64 | + */ |
|
| 65 | + protected $request; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @type LegacyRequestInterface $legacy_request |
|
| 69 | + */ |
|
| 70 | + protected $legacy_request; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @type ResponseInterface $response |
|
| 74 | + */ |
|
| 75 | + protected $response; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @type LoaderInterface $loader |
|
| 79 | + */ |
|
| 80 | + protected $loader; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @type array $_dependency_map |
|
| 84 | + */ |
|
| 85 | + protected $_dependency_map = []; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @type array $_class_loaders |
|
| 89 | + */ |
|
| 90 | + protected $_class_loaders = []; |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * EE_Dependency_Map constructor. |
|
| 95 | + * |
|
| 96 | + * @param ClassInterfaceCache $class_cache |
|
| 97 | + */ |
|
| 98 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
| 99 | + { |
|
| 100 | + $this->class_cache = $class_cache; |
|
| 101 | + do_action('EE_Dependency_Map____construct', $this); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return void |
|
| 107 | + * @throws InvalidAliasException |
|
| 108 | + */ |
|
| 109 | + public function initialize() |
|
| 110 | + { |
|
| 111 | + $this->_register_core_dependencies(); |
|
| 112 | + $this->_register_core_class_loaders(); |
|
| 113 | + $this->_register_core_aliases(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @singleton method used to instantiate class object |
|
| 119 | + * @param ClassInterfaceCache|null $class_cache |
|
| 120 | + * @return EE_Dependency_Map |
|
| 121 | + */ |
|
| 122 | + public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
| 123 | + { |
|
| 124 | + // check if class object is instantiated, and instantiated properly |
|
| 125 | + if ( |
|
| 126 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
| 127 | + && $class_cache instanceof ClassInterfaceCache |
|
| 128 | + ) { |
|
| 129 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
| 130 | + } |
|
| 131 | + return EE_Dependency_Map::$_instance; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @param RequestInterface $request |
|
| 137 | + */ |
|
| 138 | + public function setRequest(RequestInterface $request) |
|
| 139 | + { |
|
| 140 | + $this->request = $request; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @param LegacyRequestInterface $legacy_request |
|
| 146 | + */ |
|
| 147 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 148 | + { |
|
| 149 | + $this->legacy_request = $legacy_request; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @param ResponseInterface $response |
|
| 155 | + */ |
|
| 156 | + public function setResponse(ResponseInterface $response) |
|
| 157 | + { |
|
| 158 | + $this->response = $response; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param LoaderInterface $loader |
|
| 164 | + */ |
|
| 165 | + public function setLoader(LoaderInterface $loader) |
|
| 166 | + { |
|
| 167 | + $this->loader = $loader; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @param string $class |
|
| 173 | + * @param array $dependencies |
|
| 174 | + * @param int $overwrite |
|
| 175 | + * @return bool |
|
| 176 | + */ |
|
| 177 | + public static function register_dependencies( |
|
| 178 | + string $class, |
|
| 179 | + array $dependencies, |
|
| 180 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 181 | + ): bool { |
|
| 182 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 188 | + * to the class specified by the first parameter. |
|
| 189 | + * IMPORTANT !!! |
|
| 190 | + * The order of elements in the incoming $dependencies array MUST match |
|
| 191 | + * the order of the constructor parameters for the class in question. |
|
| 192 | + * This is especially important when overriding any existing dependencies that are registered. |
|
| 193 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 194 | + * |
|
| 195 | + * @param string $class |
|
| 196 | + * @param array $dependencies |
|
| 197 | + * @param int $overwrite |
|
| 198 | + * @return bool |
|
| 199 | + */ |
|
| 200 | + public function registerDependencies( |
|
| 201 | + string $class, |
|
| 202 | + array $dependencies, |
|
| 203 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 204 | + ): bool { |
|
| 205 | + $class = trim($class, '\\'); |
|
| 206 | + $registered = false; |
|
| 207 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
| 208 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
| 209 | + } |
|
| 210 | + // we need to make sure that any aliases used when registering a dependency |
|
| 211 | + // get resolved to the correct class name |
|
| 212 | + foreach ($dependencies as $dependency => $load_source) { |
|
| 213 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
| 214 | + if ( |
|
| 215 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 216 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 217 | + ) { |
|
| 218 | + unset($dependencies[ $dependency ]); |
|
| 219 | + $dependencies[ $alias ] = $load_source; |
|
| 220 | + $registered = true; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + // now add our two lists of dependencies together. |
|
| 224 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 225 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 226 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 227 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 228 | + // especially with numerically indexed arrays |
|
| 229 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 230 | + // now we need to ensure that the resulting dependencies |
|
| 231 | + // array only has the entries that are required for the class |
|
| 232 | + // so first count how many dependencies were originally registered for the class |
|
| 233 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 234 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 235 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 236 | + // then truncate the final array to match that count |
|
| 237 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 238 | + // otherwise just take the incoming array because nothing previously existed |
|
| 239 | + : $dependencies; |
|
| 240 | + return $registered; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @param string $class_name |
|
| 246 | + * @param callable|string $loader |
|
| 247 | + * @param bool $overwrite |
|
| 248 | + * @return bool |
|
| 249 | + * @throws DomainException |
|
| 250 | + */ |
|
| 251 | + public static function register_class_loader( |
|
| 252 | + string $class_name, |
|
| 253 | + $loader = 'load_core', |
|
| 254 | + bool $overwrite = false |
|
| 255 | + ): bool { |
|
| 256 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * @param string $class_name |
|
| 262 | + * @param Closure|string $loader |
|
| 263 | + * @param bool $overwrite |
|
| 264 | + * @return bool |
|
| 265 | + * @throws DomainException |
|
| 266 | + */ |
|
| 267 | + public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
| 268 | + { |
|
| 269 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 270 | + throw new DomainException( |
|
| 271 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 272 | + ); |
|
| 273 | + } |
|
| 274 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 275 | + if ( |
|
| 276 | + ! is_callable($loader) |
|
| 277 | + && ( |
|
| 278 | + strpos($loader, 'load_') !== 0 |
|
| 279 | + || ! method_exists('EE_Registry', $loader) |
|
| 280 | + ) |
|
| 281 | + ) { |
|
| 282 | + throw new DomainException( |
|
| 283 | + sprintf( |
|
| 284 | + esc_html__( |
|
| 285 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 286 | + 'event_espresso' |
|
| 287 | + ), |
|
| 288 | + $loader |
|
| 289 | + ) |
|
| 290 | + ); |
|
| 291 | + } |
|
| 292 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 293 | + if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 294 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 295 | + return true; |
|
| 296 | + } |
|
| 297 | + return false; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * @return array |
|
| 303 | + */ |
|
| 304 | + public function dependency_map(): array |
|
| 305 | + { |
|
| 306 | + return $this->_dependency_map; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 312 | + * |
|
| 313 | + * @param string $class_name |
|
| 314 | + * @return boolean |
|
| 315 | + */ |
|
| 316 | + public function has(string $class_name = ''): bool |
|
| 317 | + { |
|
| 318 | + // all legacy models have the same dependencies |
|
| 319 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 320 | + $class_name = 'LEGACY_MODELS'; |
|
| 321 | + } |
|
| 322 | + return isset($this->_dependency_map[ $class_name ]); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 328 | + * |
|
| 329 | + * @param string $class_name |
|
| 330 | + * @param string $dependency |
|
| 331 | + * @return bool |
|
| 332 | + */ |
|
| 333 | + public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
| 334 | + { |
|
| 335 | + // all legacy models have the same dependencies |
|
| 336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 337 | + $class_name = 'LEGACY_MODELS'; |
|
| 338 | + } |
|
| 339 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 340 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 346 | + * |
|
| 347 | + * @param string $class_name |
|
| 348 | + * @param string $dependency |
|
| 349 | + * @return int |
|
| 350 | + */ |
|
| 351 | + public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
| 352 | + { |
|
| 353 | + // all legacy models have the same dependencies |
|
| 354 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 355 | + $class_name = 'LEGACY_MODELS'; |
|
| 356 | + } |
|
| 357 | + $dependency = $this->getFqnForAlias($dependency); |
|
| 358 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 359 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 360 | + : EE_Dependency_Map::not_registered; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * @param string $class_name |
|
| 366 | + * @return string | Closure |
|
| 367 | + */ |
|
| 368 | + public function class_loader(string $class_name) |
|
| 369 | + { |
|
| 370 | + // all legacy models use load_model() |
|
| 371 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 372 | + return 'load_model'; |
|
| 373 | + } |
|
| 374 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 375 | + // perform strpos() first to avoid loading regex every time we load a class |
|
| 376 | + if ( |
|
| 377 | + strpos($class_name, 'EE_CPT_') === 0 |
|
| 378 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 379 | + ) { |
|
| 380 | + return 'load_core'; |
|
| 381 | + } |
|
| 382 | + $class_name = $this->getFqnForAlias($class_name); |
|
| 383 | + return $this->_class_loaders[ $class_name ] ?? ''; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * @return array |
|
| 389 | + */ |
|
| 390 | + public function class_loaders(): array |
|
| 391 | + { |
|
| 392 | + return $this->_class_loaders; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * adds an alias for a classname |
|
| 398 | + * |
|
| 399 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 400 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 401 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 402 | + * @throws InvalidAliasException |
|
| 403 | + */ |
|
| 404 | + public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
| 405 | + { |
|
| 406 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
| 412 | + * WHY? |
|
| 413 | + * Because if a class is type hinting for a concretion, |
|
| 414 | + * then why would we need to find another class to supply it? |
|
| 415 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 416 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 417 | + * Don't go looking for some substitute. |
|
| 418 | + * Whereas if a class is type hinting for an interface... |
|
| 419 | + * then we need to find an actual class to use. |
|
| 420 | + * So the interface IS the alias for some other FQN, |
|
| 421 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 422 | + * represents some other class. |
|
| 423 | + * |
|
| 424 | + * @param string $fqn |
|
| 425 | + * @param string $for_class |
|
| 426 | + * @return bool |
|
| 427 | + */ |
|
| 428 | + public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
| 429 | + { |
|
| 430 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 436 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 437 | + * for example: |
|
| 438 | + * if the following two entries were added to the _aliases array: |
|
| 439 | + * array( |
|
| 440 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 441 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 442 | + * ) |
|
| 443 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 444 | + * to load an instance of 'some\namespace\classname' |
|
| 445 | + * |
|
| 446 | + * @param string $alias |
|
| 447 | + * @param string $for_class |
|
| 448 | + * @return string |
|
| 449 | + */ |
|
| 450 | + public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
| 451 | + { |
|
| 452 | + return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 458 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 459 | + * This is done by using the following class constants: |
|
| 460 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 461 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 462 | + */ |
|
| 463 | + protected function _register_core_dependencies() |
|
| 464 | + { |
|
| 465 | + $this->_dependency_map = [ |
|
| 466 | + 'EE_Admin' => [ |
|
| 467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 468 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 469 | + ], |
|
| 470 | + 'EE_Request_Handler' => [ |
|
| 471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 472 | + 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
| 473 | + ], |
|
| 474 | + 'EE_System' => [ |
|
| 475 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 476 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 477 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 478 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 479 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
| 480 | + ], |
|
| 481 | + 'EE_Session' => [ |
|
| 482 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 483 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 484 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 485 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
| 486 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 487 | + ], |
|
| 488 | + 'EE_Cart' => [ |
|
| 489 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 490 | + ], |
|
| 491 | + 'EE_Messenger_Collection_Loader' => [ |
|
| 492 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 493 | + ], |
|
| 494 | + 'EE_Message_Type_Collection_Loader' => [ |
|
| 495 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 496 | + ], |
|
| 497 | + 'EE_Message_Resource_Manager' => [ |
|
| 498 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 499 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 501 | + ], |
|
| 502 | + 'EE_Message_Factory' => [ |
|
| 503 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 504 | + ], |
|
| 505 | + 'EE_messages' => [ |
|
| 506 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 507 | + ], |
|
| 508 | + 'EE_Messages_Generator' => [ |
|
| 509 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 510 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 511 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 512 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 513 | + ], |
|
| 514 | + 'EE_Messages_Processor' => [ |
|
| 515 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 516 | + ], |
|
| 517 | + 'EE_Messages_Queue' => [ |
|
| 518 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 519 | + ], |
|
| 520 | + 'EE_Messages_Template_Defaults' => [ |
|
| 521 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 522 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + ], |
|
| 524 | + 'EE_Message_To_Generate_From_Request' => [ |
|
| 525 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 526 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 527 | + ], |
|
| 528 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 529 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 530 | + ], |
|
| 531 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 532 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 533 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 534 | + ], |
|
| 535 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 536 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 537 | + ], |
|
| 538 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 539 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 540 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 541 | + ], |
|
| 542 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 543 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 544 | + ], |
|
| 545 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 546 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 547 | + ], |
|
| 548 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 549 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 550 | + ], |
|
| 551 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 552 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 553 | + ], |
|
| 554 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 555 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | + ], |
|
| 557 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 558 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 559 | + ], |
|
| 560 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 561 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 562 | + ], |
|
| 563 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 564 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 565 | + ], |
|
| 566 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 567 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 568 | + ], |
|
| 569 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 570 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 571 | + ], |
|
| 572 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 573 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 574 | + ], |
|
| 575 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 576 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 577 | + ], |
|
| 578 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 579 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 580 | + ], |
|
| 581 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
| 582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | + ], |
|
| 584 | + 'EE_Data_Migration_Class_Base' => [ |
|
| 585 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 586 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 587 | + ], |
|
| 588 | + 'EE_DMS_Core_4_1_0' => [ |
|
| 589 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 590 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 591 | + ], |
|
| 592 | + 'EE_DMS_Core_4_2_0' => [ |
|
| 593 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 594 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 595 | + ], |
|
| 596 | + 'EE_DMS_Core_4_3_0' => [ |
|
| 597 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 598 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 599 | + ], |
|
| 600 | + 'EE_DMS_Core_4_4_0' => [ |
|
| 601 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 602 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 603 | + ], |
|
| 604 | + 'EE_DMS_Core_4_5_0' => [ |
|
| 605 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 606 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 607 | + ], |
|
| 608 | + 'EE_DMS_Core_4_6_0' => [ |
|
| 609 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 610 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 611 | + ], |
|
| 612 | + 'EE_DMS_Core_4_7_0' => [ |
|
| 613 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 614 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + ], |
|
| 616 | + 'EE_DMS_Core_4_8_0' => [ |
|
| 617 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 618 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 619 | + ], |
|
| 620 | + 'EE_DMS_Core_4_9_0' => [ |
|
| 621 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 622 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 623 | + ], |
|
| 624 | + 'EE_DMS_Core_4_10_0' => [ |
|
| 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 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 628 | + ], |
|
| 629 | + 'EE_DMS_Core_4_11_0' => [ |
|
| 630 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
| 631 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 632 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 633 | + ], |
|
| 634 | + 'EE_DMS_Core_4_12_0' => [ |
|
| 635 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
| 636 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 637 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 638 | + ], |
|
| 639 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
| 640 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 641 | + ], |
|
| 642 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
| 643 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 644 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
| 645 | + ], |
|
| 646 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
| 647 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 648 | + ], |
|
| 649 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
| 650 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 651 | + ], |
|
| 652 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
| 653 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 654 | + ], |
|
| 655 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
| 656 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 657 | + ], |
|
| 658 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
| 659 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 660 | + ], |
|
| 661 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
| 662 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 663 | + ], |
|
| 664 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
| 665 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 666 | + ], |
|
| 667 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 668 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 669 | + ], |
|
| 670 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 671 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 672 | + ], |
|
| 673 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 674 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 675 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 676 | + ], |
|
| 677 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 678 | + null, |
|
| 679 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 680 | + ], |
|
| 681 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 682 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 683 | + ], |
|
| 684 | + 'LEGACY_MODELS' => [ |
|
| 685 | + null, |
|
| 686 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 687 | + ], |
|
| 688 | + 'EE_Module_Request_Router' => [ |
|
| 689 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 690 | + ], |
|
| 691 | + 'EE_Registration_Processor' => [ |
|
| 692 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 693 | + ], |
|
| 694 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 695 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 696 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 697 | + ], |
|
| 698 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 699 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 700 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 701 | + ], |
|
| 702 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
| 703 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 704 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 705 | + 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
| 706 | + ], |
|
| 707 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 708 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 709 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 710 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 711 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 712 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 713 | + ], |
|
| 714 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 715 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 716 | + ], |
|
| 717 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 718 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 719 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 720 | + ], |
|
| 721 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 722 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 723 | + ], |
|
| 724 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 725 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 726 | + ], |
|
| 727 | + 'EE_CPT_Strategy' => [ |
|
| 728 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 729 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 730 | + ], |
|
| 731 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 732 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 733 | + ], |
|
| 734 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 735 | + null, |
|
| 736 | + null, |
|
| 737 | + null, |
|
| 738 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 739 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 740 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 741 | + ], |
|
| 742 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 743 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 744 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 745 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 746 | + ], |
|
| 747 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 748 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 749 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 750 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 751 | + ], |
|
| 752 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 753 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 754 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 755 | + ], |
|
| 756 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 757 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 758 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 759 | + ], |
|
| 760 | + 'EE_URL_Validation_Strategy' => [ |
|
| 761 | + null, |
|
| 762 | + null, |
|
| 763 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
| 764 | + ], |
|
| 765 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 766 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 767 | + ], |
|
| 768 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 769 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 770 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 771 | + ], |
|
| 772 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 773 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 774 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 775 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 776 | + null, |
|
| 777 | + ], |
|
| 778 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 779 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 780 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 781 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 782 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 783 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 784 | + ], |
|
| 785 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 786 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 787 | + ], |
|
| 788 | + 'EventEspresso\core\services\routing\Router' => [ |
|
| 789 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 790 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 791 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
| 792 | + ], |
|
| 793 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
| 794 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 795 | + ], |
|
| 796 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
| 797 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 798 | + ], |
|
| 799 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
| 800 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
| 801 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 802 | + ], |
|
| 803 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
| 804 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 805 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 806 | + ], |
|
| 807 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
| 808 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
| 809 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
| 810 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
| 811 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
| 812 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
| 813 | + ], |
|
| 814 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
| 815 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 816 | + ], |
|
| 817 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
| 818 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 819 | + ], |
|
| 820 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
| 821 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 822 | + ], |
|
| 823 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
| 824 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 825 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 826 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 827 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 828 | + ], |
|
| 829 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
| 830 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 831 | + ], |
|
| 832 | + 'EventEspresso\core\services\request\CurrentPage' => [ |
|
| 833 | + 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
| 834 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 835 | + ], |
|
| 836 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
| 837 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 838 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 839 | + ], |
|
| 840 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
| 841 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
| 842 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
| 843 | + ], |
|
| 844 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
| 845 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
| 846 | + ], |
|
| 847 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
| 848 | + 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
| 849 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
| 850 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
| 851 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
| 852 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
| 853 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
| 854 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
| 855 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
| 856 | + ], |
|
| 857 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
| 858 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 859 | + ], |
|
| 860 | + 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
| 861 | + 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
| 862 | + ], |
|
| 863 | + 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
| 864 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 865 | + ], |
|
| 866 | + ]; |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + |
|
| 870 | + /** |
|
| 871 | + * Registers how core classes are loaded. |
|
| 872 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 873 | + * 'EE_Request_Handler' => 'load_core' |
|
| 874 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 875 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 876 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 877 | + * 'Some_Class' => function () { |
|
| 878 | + * return new Some_Class(); |
|
| 879 | + * }, |
|
| 880 | + * This is required for instantiating dependencies |
|
| 881 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 882 | + * 'Required_Interface' => function () { |
|
| 883 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 884 | + * }, |
|
| 885 | + */ |
|
| 886 | + protected function _register_core_class_loaders() |
|
| 887 | + { |
|
| 888 | + $this->_class_loaders = [ |
|
| 889 | + // load_core |
|
| 890 | + 'EE_Dependency_Map' => function () { |
|
| 891 | + return $this; |
|
| 892 | + }, |
|
| 893 | + 'EE_Capabilities' => 'load_core', |
|
| 894 | + 'EE_Encryption' => 'load_core', |
|
| 895 | + 'EE_Front_Controller' => 'load_core', |
|
| 896 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 897 | + 'EE_Registry' => 'load_core', |
|
| 898 | + 'EE_Request' => function () { |
|
| 899 | + return $this->legacy_request; |
|
| 900 | + }, |
|
| 901 | + 'EventEspresso\core\services\request\Request' => function () { |
|
| 902 | + return $this->request; |
|
| 903 | + }, |
|
| 904 | + 'EventEspresso\core\services\request\Response' => function () { |
|
| 905 | + return $this->response; |
|
| 906 | + }, |
|
| 907 | + 'EE_Base' => 'load_core', |
|
| 908 | + 'EE_Request_Handler' => 'load_core', |
|
| 909 | + 'EE_Session' => 'load_core', |
|
| 910 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 911 | + 'EE_System' => 'load_core', |
|
| 912 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 913 | + 'EE_Register_CPTs' => 'load_core', |
|
| 914 | + 'EE_Admin' => 'load_core', |
|
| 915 | + 'EE_CPT_Strategy' => 'load_core', |
|
| 916 | + // load_class |
|
| 917 | + 'EE_Registration_Processor' => 'load_class', |
|
| 918 | + // load_lib |
|
| 919 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 920 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 921 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 922 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 923 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 924 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 925 | + 'EE_Message_Repository' => 'load_lib', |
|
| 926 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 927 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 928 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 929 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 930 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 931 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 932 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 933 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 934 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 935 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 936 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 937 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 938 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 939 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
| 940 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
| 941 | + 'EE_Messages_Generator' => static function () { |
|
| 942 | + return EE_Registry::instance()->load_lib( |
|
| 943 | + 'Messages_Generator', |
|
| 944 | + [], |
|
| 945 | + false, |
|
| 946 | + false |
|
| 947 | + ); |
|
| 948 | + }, |
|
| 949 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 950 | + return EE_Registry::instance()->load_lib( |
|
| 951 | + 'Messages_Template_Defaults', |
|
| 952 | + $arguments, |
|
| 953 | + false, |
|
| 954 | + false |
|
| 955 | + ); |
|
| 956 | + }, |
|
| 957 | + // load_helper |
|
| 958 | + 'EEH_Parse_Shortcodes' => static function () { |
|
| 959 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 960 | + return new EEH_Parse_Shortcodes(); |
|
| 961 | + } |
|
| 962 | + return null; |
|
| 963 | + }, |
|
| 964 | + 'EE_Template_Config' => static function () { |
|
| 965 | + return EE_Config::instance()->template_settings; |
|
| 966 | + }, |
|
| 967 | + 'EE_Currency_Config' => static function () { |
|
| 968 | + return EE_Currency_Config::getCurrencyConfig(); |
|
| 969 | + }, |
|
| 970 | + 'EE_Registration_Config' => static function () { |
|
| 971 | + return EE_Config::instance()->registration; |
|
| 972 | + }, |
|
| 973 | + 'EE_Core_Config' => static function () { |
|
| 974 | + return EE_Config::instance()->core; |
|
| 975 | + }, |
|
| 976 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 977 | + return LoaderFactory::getLoader(); |
|
| 978 | + }, |
|
| 979 | + 'EE_Network_Config' => static function () { |
|
| 980 | + return EE_Network_Config::instance(); |
|
| 981 | + }, |
|
| 982 | + 'EE_Config' => static function () { |
|
| 983 | + return EE_Config::instance(); |
|
| 984 | + }, |
|
| 985 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
| 986 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
| 987 | + }, |
|
| 988 | + 'EE_Admin_Config' => static function () { |
|
| 989 | + return EE_Config::instance()->admin; |
|
| 990 | + }, |
|
| 991 | + 'EE_Organization_Config' => static function () { |
|
| 992 | + return EE_Config::instance()->organization; |
|
| 993 | + }, |
|
| 994 | + 'EE_Network_Core_Config' => static function () { |
|
| 995 | + return EE_Network_Config::instance()->core; |
|
| 996 | + }, |
|
| 997 | + 'EE_Environment_Config' => static function () { |
|
| 998 | + return EE_Config::instance()->environment; |
|
| 999 | + }, |
|
| 1000 | + 'EED_Core_Rest_Api' => static function () { |
|
| 1001 | + return EED_Core_Rest_Api::instance(); |
|
| 1002 | + }, |
|
| 1003 | + 'WP_REST_Server' => static function () { |
|
| 1004 | + return rest_get_server(); |
|
| 1005 | + }, |
|
| 1006 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
| 1007 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
| 1008 | + }, |
|
| 1009 | + 'EE_Ticket_Selector_Config' => function () { |
|
| 1010 | + return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
| 1011 | + }, |
|
| 1012 | + ]; |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + |
|
| 1016 | + /** |
|
| 1017 | + * can be used for supplying alternate names for classes, |
|
| 1018 | + * or for connecting interface names to instantiable classes |
|
| 1019 | + * |
|
| 1020 | + * @throws InvalidAliasException |
|
| 1021 | + */ |
|
| 1022 | + protected function _register_core_aliases() |
|
| 1023 | + { |
|
| 1024 | + $aliases = [ |
|
| 1025 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 1026 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 1027 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 1028 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 1029 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 1030 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 1031 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1032 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 1033 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1034 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 1035 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1036 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 1037 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 1038 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 1039 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 1040 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 1041 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 1042 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 1043 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 1044 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 1045 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1046 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 1047 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1048 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 1049 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 1050 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 1051 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 1052 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 1053 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 1054 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 1055 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 1056 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 1057 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 1058 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 1059 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1060 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1061 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1062 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1063 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
| 1064 | + ]; |
|
| 1065 | + foreach ($aliases as $alias => $fqn) { |
|
| 1066 | + if (is_array($fqn)) { |
|
| 1067 | + foreach ($fqn as $class => $for_class) { |
|
| 1068 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1069 | + } |
|
| 1070 | + continue; |
|
| 1071 | + } |
|
| 1072 | + $this->class_cache->addAlias($fqn, $alias); |
|
| 1073 | + } |
|
| 1074 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1075 | + $this->class_cache->addAlias( |
|
| 1076 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1077 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1078 | + ); |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + |
|
| 1083 | + public function debug($for_class = '') |
|
| 1084 | + { |
|
| 1085 | + if (method_exists($this->class_cache, 'debug')) { |
|
| 1086 | + $this->class_cache->debug($for_class); |
|
| 1087 | + } |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + |
|
| 1091 | + /** |
|
| 1092 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1093 | + * request Primarily used by unit tests. |
|
| 1094 | + */ |
|
| 1095 | + public function reset() |
|
| 1096 | + { |
|
| 1097 | + $this->_register_core_class_loaders(); |
|
| 1098 | + $this->_register_core_dependencies(); |
|
| 1099 | + } |
|
| 1100 | + |
|
| 1101 | + |
|
| 1102 | + /** |
|
| 1103 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1104 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1105 | + * WHY? |
|
| 1106 | + * Because if a class is type hinting for a concretion, |
|
| 1107 | + * then why would we need to find another class to supply it? |
|
| 1108 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1109 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1110 | + * Don't go looking for some substitute. |
|
| 1111 | + * Whereas if a class is type hinting for an interface... |
|
| 1112 | + * then we need to find an actual class to use. |
|
| 1113 | + * So the interface IS the alias for some other FQN, |
|
| 1114 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1115 | + * represents some other class. |
|
| 1116 | + * |
|
| 1117 | + * @param string $fqn |
|
| 1118 | + * @param string $for_class |
|
| 1119 | + * @return bool |
|
| 1120 | + * @deprecated 4.9.62.p |
|
| 1121 | + */ |
|
| 1122 | + public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
| 1123 | + { |
|
| 1124 | + return $this->isAlias($fqn, $for_class); |
|
| 1125 | + } |
|
| 1126 | + |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1130 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1131 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1132 | + * for example: |
|
| 1133 | + * if the following two entries were added to the _aliases array: |
|
| 1134 | + * array( |
|
| 1135 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 1136 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1137 | + * ) |
|
| 1138 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1139 | + * to load an instance of 'some\namespace\classname' |
|
| 1140 | + * |
|
| 1141 | + * @param string $alias |
|
| 1142 | + * @param string $for_class |
|
| 1143 | + * @return string |
|
| 1144 | + * @deprecated 4.9.62.p |
|
| 1145 | + */ |
|
| 1146 | + public function get_alias(string $alias = '', string $for_class = ''): string |
|
| 1147 | + { |
|
| 1148 | + return $this->getFqnForAlias($alias, $for_class); |
|
| 1149 | + } |
|
| 1150 | 1150 | } |
@@ -15,47 +15,47 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ActivationRequests extends PrimaryRoute |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * returns true if the current request matches this route |
|
| 20 | - * |
|
| 21 | - * @return bool |
|
| 22 | - * @since $VID:$ |
|
| 23 | - */ |
|
| 24 | - public function matchesCurrentRequest(): bool |
|
| 25 | - { |
|
| 26 | - return $this->request->isActivation(); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * returns true if the current request matches this route |
|
| 20 | + * |
|
| 21 | + * @return bool |
|
| 22 | + * @since $VID:$ |
|
| 23 | + */ |
|
| 24 | + public function matchesCurrentRequest(): bool |
|
| 25 | + { |
|
| 26 | + return $this->request->isActivation(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @since $VID:$ |
|
| 32 | - */ |
|
| 33 | - protected function registerDependencies() |
|
| 34 | - { |
|
| 35 | - $this->dependency_map->registerDependencies( |
|
| 36 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute', |
|
| 37 | - AdminRoute::getDefaultDependencies() |
|
| 38 | - ); |
|
| 39 | - $this->dependency_map->registerDependencies( |
|
| 40 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests', |
|
| 41 | - Route::getDefaultDependencies() |
|
| 42 | - ); |
|
| 43 | - $this->dependency_map->registerDependencies( |
|
| 44 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage', |
|
| 45 | - AdminRoute::getDefaultDependencies() |
|
| 46 | - ); |
|
| 47 | - } |
|
| 30 | + /** |
|
| 31 | + * @since $VID:$ |
|
| 32 | + */ |
|
| 33 | + protected function registerDependencies() |
|
| 34 | + { |
|
| 35 | + $this->dependency_map->registerDependencies( |
|
| 36 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute', |
|
| 37 | + AdminRoute::getDefaultDependencies() |
|
| 38 | + ); |
|
| 39 | + $this->dependency_map->registerDependencies( |
|
| 40 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests', |
|
| 41 | + Route::getDefaultDependencies() |
|
| 42 | + ); |
|
| 43 | + $this->dependency_map->registerDependencies( |
|
| 44 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage', |
|
| 45 | + AdminRoute::getDefaultDependencies() |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * implements logic required to run during request |
|
| 52 | - * |
|
| 53 | - * @return bool |
|
| 54 | - * @since $VID:$ |
|
| 55 | - */ |
|
| 56 | - protected function requestHandler(): bool |
|
| 57 | - { |
|
| 58 | - $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION); |
|
| 59 | - return true; |
|
| 60 | - } |
|
| 50 | + /** |
|
| 51 | + * implements logic required to run during request |
|
| 52 | + * |
|
| 53 | + * @return bool |
|
| 54 | + * @since $VID:$ |
|
| 55 | + */ |
|
| 56 | + protected function requestHandler(): bool |
|
| 57 | + { |
|
| 58 | + $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION); |
|
| 59 | + return true; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -28,148 +28,148 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class RegularRequests extends PrimaryRoute |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * called just before matchesCurrentRequest() |
|
| 33 | - * and allows Route to perform any setup required such as calling setSpecification() |
|
| 34 | - * |
|
| 35 | - * @since $VID:$ |
|
| 36 | - */ |
|
| 37 | - public function initialize() |
|
| 38 | - { |
|
| 39 | - $basic_nodes = [ |
|
| 40 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api', |
|
| 41 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Capabilities', |
|
| 42 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale', |
|
| 43 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls', |
|
| 44 | - ]; |
|
| 45 | - foreach ($basic_nodes as $basic_node) { |
|
| 46 | - $this->dependency_map->registerDependencies( |
|
| 47 | - $basic_node, |
|
| 48 | - ['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache] |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - $this->dependency_map->registerDependencies( |
|
| 52 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SitePermissions', |
|
| 53 | - [ |
|
| 54 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache, |
|
| 55 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 56 | - ] |
|
| 57 | - ); |
|
| 58 | - $this->dependency_map->registerDependencies( |
|
| 59 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings', |
|
| 60 | - [ |
|
| 61 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 62 | - 'EventEspresso\core\services\converters\date_time_formats\PhpToUnicode' => EE_Dependency_Map::load_from_cache, |
|
| 63 | - ] |
|
| 64 | - ); |
|
| 65 | - $this->dependency_map->registerDependencies( |
|
| 66 | - 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData', |
|
| 67 | - [ |
|
| 68 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api' => EE_Dependency_Map::load_from_cache, |
|
| 69 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache, |
|
| 70 | - 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 71 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 72 | - ] |
|
| 73 | - ); |
|
| 74 | - $this->dependency_map->registerDependencies( |
|
| 75 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config', |
|
| 76 | - [ |
|
| 77 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 78 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache, |
|
| 79 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings' => EE_Dependency_Map::load_from_cache, |
|
| 80 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale' => EE_Dependency_Map::load_from_cache, |
|
| 81 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency' => EE_Dependency_Map::load_from_cache, |
|
| 82 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SitePermissions' => EE_Dependency_Map::load_from_cache, |
|
| 83 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls' => EE_Dependency_Map::load_from_cache, |
|
| 84 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 85 | - ] |
|
| 86 | - ); |
|
| 87 | - $this->dependency_map->registerDependencies( |
|
| 88 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser', |
|
| 89 | - [ |
|
| 90 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 91 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 92 | - ] |
|
| 93 | - ); |
|
| 94 | - $this->dependency_map->registerDependencies( |
|
| 95 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain', |
|
| 96 | - [ |
|
| 97 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 98 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 99 | - ] |
|
| 100 | - ); |
|
| 101 | - $this->dependency_map->registerDependencies( |
|
| 102 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency', |
|
| 103 | - [ |
|
| 104 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 105 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - $this->setDataNode( |
|
| 109 | - $this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData') |
|
| 110 | - ); |
|
| 111 | - } |
|
| 31 | + /** |
|
| 32 | + * called just before matchesCurrentRequest() |
|
| 33 | + * and allows Route to perform any setup required such as calling setSpecification() |
|
| 34 | + * |
|
| 35 | + * @since $VID:$ |
|
| 36 | + */ |
|
| 37 | + public function initialize() |
|
| 38 | + { |
|
| 39 | + $basic_nodes = [ |
|
| 40 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api', |
|
| 41 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Capabilities', |
|
| 42 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale', |
|
| 43 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls', |
|
| 44 | + ]; |
|
| 45 | + foreach ($basic_nodes as $basic_node) { |
|
| 46 | + $this->dependency_map->registerDependencies( |
|
| 47 | + $basic_node, |
|
| 48 | + ['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache] |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + $this->dependency_map->registerDependencies( |
|
| 52 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SitePermissions', |
|
| 53 | + [ |
|
| 54 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache, |
|
| 55 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 56 | + ] |
|
| 57 | + ); |
|
| 58 | + $this->dependency_map->registerDependencies( |
|
| 59 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings', |
|
| 60 | + [ |
|
| 61 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 62 | + 'EventEspresso\core\services\converters\date_time_formats\PhpToUnicode' => EE_Dependency_Map::load_from_cache, |
|
| 63 | + ] |
|
| 64 | + ); |
|
| 65 | + $this->dependency_map->registerDependencies( |
|
| 66 | + 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData', |
|
| 67 | + [ |
|
| 68 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api' => EE_Dependency_Map::load_from_cache, |
|
| 69 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache, |
|
| 70 | + 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 71 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 72 | + ] |
|
| 73 | + ); |
|
| 74 | + $this->dependency_map->registerDependencies( |
|
| 75 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config', |
|
| 76 | + [ |
|
| 77 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 78 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache, |
|
| 79 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings' => EE_Dependency_Map::load_from_cache, |
|
| 80 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale' => EE_Dependency_Map::load_from_cache, |
|
| 81 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency' => EE_Dependency_Map::load_from_cache, |
|
| 82 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SitePermissions' => EE_Dependency_Map::load_from_cache, |
|
| 83 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls' => EE_Dependency_Map::load_from_cache, |
|
| 84 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 85 | + ] |
|
| 86 | + ); |
|
| 87 | + $this->dependency_map->registerDependencies( |
|
| 88 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser', |
|
| 89 | + [ |
|
| 90 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 91 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 92 | + ] |
|
| 93 | + ); |
|
| 94 | + $this->dependency_map->registerDependencies( |
|
| 95 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain', |
|
| 96 | + [ |
|
| 97 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 98 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 99 | + ] |
|
| 100 | + ); |
|
| 101 | + $this->dependency_map->registerDependencies( |
|
| 102 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency', |
|
| 103 | + [ |
|
| 104 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 105 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + $this->setDataNode( |
|
| 109 | + $this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData') |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * returns true if the current request matches this route |
|
| 116 | - * |
|
| 117 | - * @return bool |
|
| 118 | - * @since $VID:$ |
|
| 119 | - */ |
|
| 120 | - public function matchesCurrentRequest(): bool |
|
| 121 | - { |
|
| 122 | - return ! $this->request->isActivation() || $this->request->isUnitTesting(); |
|
| 123 | - } |
|
| 114 | + /** |
|
| 115 | + * returns true if the current request matches this route |
|
| 116 | + * |
|
| 117 | + * @return bool |
|
| 118 | + * @since $VID:$ |
|
| 119 | + */ |
|
| 120 | + public function matchesCurrentRequest(): bool |
|
| 121 | + { |
|
| 122 | + return ! $this->request->isActivation() || $this->request->isUnitTesting(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * @since $VID:$ |
|
| 128 | - */ |
|
| 129 | - protected function registerDependencies() |
|
| 130 | - { |
|
| 131 | - $public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + Route::getDefaultDependencies(); |
|
| 126 | + /** |
|
| 127 | + * @since $VID:$ |
|
| 128 | + */ |
|
| 129 | + protected function registerDependencies() |
|
| 130 | + { |
|
| 131 | + $public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + Route::getDefaultDependencies(); |
|
| 132 | 132 | |
| 133 | - $default_with_barista = [BaristaFactory::class => EE_Dependency_Map::load_from_cache] + |
|
| 134 | - Route::getDefaultDependencies(); |
|
| 135 | - $default_with_manifest = [AssetManifestFactory::class => EE_Dependency_Map::load_from_cache] + |
|
| 136 | - Route::getDefaultDependencies(); |
|
| 133 | + $default_with_barista = [BaristaFactory::class => EE_Dependency_Map::load_from_cache] + |
|
| 134 | + Route::getDefaultDependencies(); |
|
| 135 | + $default_with_manifest = [AssetManifestFactory::class => EE_Dependency_Map::load_from_cache] + |
|
| 136 | + Route::getDefaultDependencies(); |
|
| 137 | 137 | |
| 138 | - $default_routes = [ |
|
| 139 | - // default dependencies |
|
| 140 | - PueRequests::class => Route::getDefaultDependencies(), |
|
| 141 | - ShortcodeRequests::class => Route::getDefaultDependencies(), |
|
| 142 | - RestApiRequests::class => Route::getDefaultDependencies(), |
|
| 143 | - SessionRequests::class => Route::getDefaultDependencies(), |
|
| 144 | - WordPressHeartbeat::class => Route::getDefaultDependencies(), |
|
| 145 | - AssetRequests::class => $default_with_barista, |
|
| 146 | - GQLRequests::class => $default_with_manifest, |
|
| 147 | - // admin dependencies |
|
| 148 | - AdminRoute::class => AdminRoute::getDefaultDependencies(), |
|
| 149 | - EspressoEventsAdmin::class => AdminRoute::getDefaultDependencies(), |
|
| 150 | - EspressoEventEditor::class => AdminRoute::getDefaultDependencies(), |
|
| 151 | - EspressoLegacyAdmin::class => AdminRoute::getDefaultDependencies(), |
|
| 152 | - GutenbergEditor::class => AdminRoute::getDefaultDependencies(), |
|
| 153 | - WordPressPluginsPage::class => AdminRoute::getDefaultDependencies(), |
|
| 154 | - // public dependencies |
|
| 155 | - PersonalDataRequests::class => $public, |
|
| 156 | - FrontendRequests::class => $public, |
|
| 157 | - ]; |
|
| 158 | - foreach ($default_routes as $route => $dependencies) { |
|
| 159 | - $this->dependency_map->registerDependencies($route, $dependencies); |
|
| 160 | - } |
|
| 161 | - } |
|
| 138 | + $default_routes = [ |
|
| 139 | + // default dependencies |
|
| 140 | + PueRequests::class => Route::getDefaultDependencies(), |
|
| 141 | + ShortcodeRequests::class => Route::getDefaultDependencies(), |
|
| 142 | + RestApiRequests::class => Route::getDefaultDependencies(), |
|
| 143 | + SessionRequests::class => Route::getDefaultDependencies(), |
|
| 144 | + WordPressHeartbeat::class => Route::getDefaultDependencies(), |
|
| 145 | + AssetRequests::class => $default_with_barista, |
|
| 146 | + GQLRequests::class => $default_with_manifest, |
|
| 147 | + // admin dependencies |
|
| 148 | + AdminRoute::class => AdminRoute::getDefaultDependencies(), |
|
| 149 | + EspressoEventsAdmin::class => AdminRoute::getDefaultDependencies(), |
|
| 150 | + EspressoEventEditor::class => AdminRoute::getDefaultDependencies(), |
|
| 151 | + EspressoLegacyAdmin::class => AdminRoute::getDefaultDependencies(), |
|
| 152 | + GutenbergEditor::class => AdminRoute::getDefaultDependencies(), |
|
| 153 | + WordPressPluginsPage::class => AdminRoute::getDefaultDependencies(), |
|
| 154 | + // public dependencies |
|
| 155 | + PersonalDataRequests::class => $public, |
|
| 156 | + FrontendRequests::class => $public, |
|
| 157 | + ]; |
|
| 158 | + foreach ($default_routes as $route => $dependencies) { |
|
| 159 | + $this->dependency_map->registerDependencies($route, $dependencies); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * implements logic required to run during request |
|
| 166 | - * |
|
| 167 | - * @return bool |
|
| 168 | - * @since $VID:$ |
|
| 169 | - */ |
|
| 170 | - protected function requestHandler(): bool |
|
| 171 | - { |
|
| 172 | - $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR); |
|
| 173 | - return true; |
|
| 174 | - } |
|
| 164 | + /** |
|
| 165 | + * implements logic required to run during request |
|
| 166 | + * |
|
| 167 | + * @return bool |
|
| 168 | + * @since $VID:$ |
|
| 169 | + */ |
|
| 170 | + protected function requestHandler(): bool |
|
| 171 | + { |
|
| 172 | + $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR); |
|
| 173 | + return true; |
|
| 174 | + } |
|
| 175 | 175 | } |