@@ -25,182 +25,182 @@ |
||
| 25 | 25 | abstract class Route implements RouteInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var AssetManagerInterface $asset_manager |
|
| 30 | - */ |
|
| 31 | - protected $asset_manager; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var EE_Dependency_Map $dependency_map |
|
| 35 | - */ |
|
| 36 | - protected $dependency_map; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var JsonDataNode $data_node |
|
| 40 | - */ |
|
| 41 | - protected $data_node; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var LoaderInterface $loader |
|
| 45 | - */ |
|
| 46 | - protected $loader; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var RequestInterface $request |
|
| 50 | - */ |
|
| 51 | - protected $request; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var RouteMatchSpecificationInterface $specification |
|
| 55 | - */ |
|
| 56 | - protected $specification; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var boolean $handled |
|
| 60 | - */ |
|
| 61 | - private $handled = false; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Route constructor. |
|
| 66 | - * |
|
| 67 | - * @param EE_Dependency_Map $dependency_map |
|
| 68 | - * @param LoaderInterface $loader |
|
| 69 | - * @param RequestInterface $request |
|
| 70 | - * @param JsonDataNode $data_node |
|
| 71 | - * @param RouteMatchSpecificationInterface $specification |
|
| 72 | - */ |
|
| 73 | - public function __construct( |
|
| 74 | - EE_Dependency_Map $dependency_map, |
|
| 75 | - LoaderInterface $loader, |
|
| 76 | - RequestInterface $request, |
|
| 77 | - JsonDataNode $data_node = null, |
|
| 78 | - RouteMatchSpecificationInterface $specification = null |
|
| 79 | - ) { |
|
| 80 | - $this->dependency_map = $dependency_map; |
|
| 81 | - $this->data_node = $data_node; |
|
| 82 | - $this->loader = $loader; |
|
| 83 | - $this->request = $request; |
|
| 84 | - $this->specification = $specification; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @since $VID:$ |
|
| 90 | - */ |
|
| 91 | - abstract protected function registerDependencies(); |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * implements logic required to run during request |
|
| 96 | - * |
|
| 97 | - * @return bool |
|
| 98 | - * @since $VID:$ |
|
| 99 | - */ |
|
| 100 | - abstract protected function requestHandler(); |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @param JsonDataNode $data_node |
|
| 105 | - */ |
|
| 106 | - protected function setDataNode($data_node) |
|
| 107 | - { |
|
| 108 | - $this->data_node = $data_node; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param RouteMatchSpecificationInterface $specification |
|
| 114 | - */ |
|
| 115 | - protected function setSpecification($specification) |
|
| 116 | - { |
|
| 117 | - $this->specification = $specification; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @return JsonDataNode |
|
| 123 | - */ |
|
| 124 | - public function dataNode() |
|
| 125 | - { |
|
| 126 | - return $this->data_node; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * runs route requestHandler() if |
|
| 132 | - * - route has not previously been handled |
|
| 133 | - * - route specification matches for current request |
|
| 134 | - * sets route handled property based on results returned by requestHandler() |
|
| 135 | - * |
|
| 136 | - * @return bool |
|
| 137 | - * @since $VID:$ |
|
| 138 | - */ |
|
| 139 | - public function handleRequest() |
|
| 140 | - { |
|
| 141 | - if ($this->isNotHandled()) { |
|
| 142 | - $this->initialize(); |
|
| 143 | - if ($this->matchesCurrentRequest()) { |
|
| 144 | - do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this); |
|
| 145 | - $this->registerDependencies(); |
|
| 146 | - $handled = $this->requestHandler(); |
|
| 147 | - if (! is_bool($handled)) { |
|
| 148 | - throw new DomainException( |
|
| 149 | - esc_html__( |
|
| 150 | - 'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.', |
|
| 151 | - 'event_espresso' |
|
| 152 | - ) |
|
| 153 | - ); |
|
| 154 | - } |
|
| 155 | - $this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - return $this->handled; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * called just before matchesCurrentRequest() |
|
| 164 | - * and allows Route to perform any setup required such as calling setSpecification() |
|
| 165 | - * |
|
| 166 | - * @since $VID:$ |
|
| 167 | - */ |
|
| 168 | - public function initialize() |
|
| 169 | - { |
|
| 170 | - // do nothing by default |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return bool |
|
| 176 | - */ |
|
| 177 | - final public function isHandled() |
|
| 178 | - { |
|
| 179 | - return $this->handled; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - final public function isNotHandled() |
|
| 187 | - { |
|
| 188 | - return ! $this->handled; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * returns true if the current request matches this route |
|
| 194 | - * child classes can override and use Request directly to match route with request |
|
| 195 | - * or supply a RouteMatchSpecification class and just use the below |
|
| 196 | - * |
|
| 197 | - * @return bool |
|
| 198 | - * @since $VID:$ |
|
| 199 | - */ |
|
| 200 | - public function matchesCurrentRequest() |
|
| 201 | - { |
|
| 202 | - return $this->specification instanceof RouteMatchSpecificationInterface |
|
| 203 | - ? $this->specification->isMatchingRoute() |
|
| 204 | - : false; |
|
| 205 | - } |
|
| 28 | + /** |
|
| 29 | + * @var AssetManagerInterface $asset_manager |
|
| 30 | + */ |
|
| 31 | + protected $asset_manager; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var EE_Dependency_Map $dependency_map |
|
| 35 | + */ |
|
| 36 | + protected $dependency_map; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var JsonDataNode $data_node |
|
| 40 | + */ |
|
| 41 | + protected $data_node; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var LoaderInterface $loader |
|
| 45 | + */ |
|
| 46 | + protected $loader; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var RequestInterface $request |
|
| 50 | + */ |
|
| 51 | + protected $request; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var RouteMatchSpecificationInterface $specification |
|
| 55 | + */ |
|
| 56 | + protected $specification; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var boolean $handled |
|
| 60 | + */ |
|
| 61 | + private $handled = false; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Route constructor. |
|
| 66 | + * |
|
| 67 | + * @param EE_Dependency_Map $dependency_map |
|
| 68 | + * @param LoaderInterface $loader |
|
| 69 | + * @param RequestInterface $request |
|
| 70 | + * @param JsonDataNode $data_node |
|
| 71 | + * @param RouteMatchSpecificationInterface $specification |
|
| 72 | + */ |
|
| 73 | + public function __construct( |
|
| 74 | + EE_Dependency_Map $dependency_map, |
|
| 75 | + LoaderInterface $loader, |
|
| 76 | + RequestInterface $request, |
|
| 77 | + JsonDataNode $data_node = null, |
|
| 78 | + RouteMatchSpecificationInterface $specification = null |
|
| 79 | + ) { |
|
| 80 | + $this->dependency_map = $dependency_map; |
|
| 81 | + $this->data_node = $data_node; |
|
| 82 | + $this->loader = $loader; |
|
| 83 | + $this->request = $request; |
|
| 84 | + $this->specification = $specification; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @since $VID:$ |
|
| 90 | + */ |
|
| 91 | + abstract protected function registerDependencies(); |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * implements logic required to run during request |
|
| 96 | + * |
|
| 97 | + * @return bool |
|
| 98 | + * @since $VID:$ |
|
| 99 | + */ |
|
| 100 | + abstract protected function requestHandler(); |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @param JsonDataNode $data_node |
|
| 105 | + */ |
|
| 106 | + protected function setDataNode($data_node) |
|
| 107 | + { |
|
| 108 | + $this->data_node = $data_node; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param RouteMatchSpecificationInterface $specification |
|
| 114 | + */ |
|
| 115 | + protected function setSpecification($specification) |
|
| 116 | + { |
|
| 117 | + $this->specification = $specification; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @return JsonDataNode |
|
| 123 | + */ |
|
| 124 | + public function dataNode() |
|
| 125 | + { |
|
| 126 | + return $this->data_node; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * runs route requestHandler() if |
|
| 132 | + * - route has not previously been handled |
|
| 133 | + * - route specification matches for current request |
|
| 134 | + * sets route handled property based on results returned by requestHandler() |
|
| 135 | + * |
|
| 136 | + * @return bool |
|
| 137 | + * @since $VID:$ |
|
| 138 | + */ |
|
| 139 | + public function handleRequest() |
|
| 140 | + { |
|
| 141 | + if ($this->isNotHandled()) { |
|
| 142 | + $this->initialize(); |
|
| 143 | + if ($this->matchesCurrentRequest()) { |
|
| 144 | + do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this); |
|
| 145 | + $this->registerDependencies(); |
|
| 146 | + $handled = $this->requestHandler(); |
|
| 147 | + if (! is_bool($handled)) { |
|
| 148 | + throw new DomainException( |
|
| 149 | + esc_html__( |
|
| 150 | + 'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.', |
|
| 151 | + 'event_espresso' |
|
| 152 | + ) |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | + $this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + return $this->handled; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * called just before matchesCurrentRequest() |
|
| 164 | + * and allows Route to perform any setup required such as calling setSpecification() |
|
| 165 | + * |
|
| 166 | + * @since $VID:$ |
|
| 167 | + */ |
|
| 168 | + public function initialize() |
|
| 169 | + { |
|
| 170 | + // do nothing by default |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @return bool |
|
| 176 | + */ |
|
| 177 | + final public function isHandled() |
|
| 178 | + { |
|
| 179 | + return $this->handled; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + final public function isNotHandled() |
|
| 187 | + { |
|
| 188 | + return ! $this->handled; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * returns true if the current request matches this route |
|
| 194 | + * child classes can override and use Request directly to match route with request |
|
| 195 | + * or supply a RouteMatchSpecification class and just use the below |
|
| 196 | + * |
|
| 197 | + * @return bool |
|
| 198 | + * @since $VID:$ |
|
| 199 | + */ |
|
| 200 | + public function matchesCurrentRequest() |
|
| 201 | + { |
|
| 202 | + return $this->specification instanceof RouteMatchSpecificationInterface |
|
| 203 | + ? $this->specification->isMatchingRoute() |
|
| 204 | + : false; |
|
| 205 | + } |
|
| 206 | 206 | } |
@@ -144,7 +144,7 @@ |
||
| 144 | 144 | do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this); |
| 145 | 145 | $this->registerDependencies(); |
| 146 | 146 | $handled = $this->requestHandler(); |
| 147 | - if (! is_bool($handled)) { |
|
| 147 | + if ( ! is_bool($handled)) { |
|
| 148 | 148 | throw new DomainException( |
| 149 | 149 | esc_html__( |
| 150 | 150 | 'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.', |
@@ -21,992 +21,992 @@ |
||
| 21 | 21 | class EE_Dependency_Map |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * This means that the requested class dependency is not present in the dependency map |
|
| 26 | - */ |
|
| 27 | - const not_registered = 0; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 31 | - */ |
|
| 32 | - const load_new_object = 1; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 36 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 37 | - */ |
|
| 38 | - const load_from_cache = 2; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * When registering a dependency, |
|
| 42 | - * this indicates to keep any existing dependencies that already exist, |
|
| 43 | - * and simply discard any new dependencies declared in the incoming data |
|
| 44 | - */ |
|
| 45 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * When registering a dependency, |
|
| 49 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 50 | - */ |
|
| 51 | - const OVERWRITE_DEPENDENCIES = 1; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @type EE_Dependency_Map $_instance |
|
| 55 | - */ |
|
| 56 | - protected static $_instance; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var ClassInterfaceCache $class_cache |
|
| 60 | - */ |
|
| 61 | - private $class_cache; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @type RequestInterface $request |
|
| 65 | - */ |
|
| 66 | - protected $request; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @type LegacyRequestInterface $legacy_request |
|
| 70 | - */ |
|
| 71 | - protected $legacy_request; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @type ResponseInterface $response |
|
| 75 | - */ |
|
| 76 | - protected $response; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @type LoaderInterface $loader |
|
| 80 | - */ |
|
| 81 | - protected $loader; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @type array $_dependency_map |
|
| 85 | - */ |
|
| 86 | - protected $_dependency_map = []; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @type array $_class_loaders |
|
| 90 | - */ |
|
| 91 | - protected $_class_loaders = []; |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * EE_Dependency_Map constructor. |
|
| 96 | - * |
|
| 97 | - * @param ClassInterfaceCache $class_cache |
|
| 98 | - */ |
|
| 99 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
| 100 | - { |
|
| 101 | - $this->class_cache = $class_cache; |
|
| 102 | - do_action('EE_Dependency_Map____construct', $this); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return void |
|
| 108 | - * @throws InvalidAliasException |
|
| 109 | - */ |
|
| 110 | - public function initialize() |
|
| 111 | - { |
|
| 112 | - $this->_register_core_dependencies(); |
|
| 113 | - $this->_register_core_class_loaders(); |
|
| 114 | - $this->_register_core_aliases(); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @singleton method used to instantiate class object |
|
| 120 | - * @param ClassInterfaceCache|null $class_cache |
|
| 121 | - * @return EE_Dependency_Map |
|
| 122 | - */ |
|
| 123 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 124 | - { |
|
| 125 | - // check if class object is instantiated, and instantiated properly |
|
| 126 | - if (! 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 | - $class, |
|
| 179 | - array $dependencies, |
|
| 180 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 181 | - ) { |
|
| 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 | - $class, |
|
| 202 | - array $dependencies, |
|
| 203 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 204 | - ) { |
|
| 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 ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 215 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 216 | - ) { |
|
| 217 | - unset($dependencies[ $dependency ]); |
|
| 218 | - $dependencies[ $alias ] = $load_source; |
|
| 219 | - $registered = true; |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - // now add our two lists of dependencies together. |
|
| 223 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 224 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 225 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 226 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 227 | - // especially with numerically indexed arrays |
|
| 228 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 229 | - // now we need to ensure that the resulting dependencies |
|
| 230 | - // array only has the entries that are required for the class |
|
| 231 | - // so first count how many dependencies were originally registered for the class |
|
| 232 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 233 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 234 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 235 | - // then truncate the final array to match that count |
|
| 236 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 237 | - // otherwise just take the incoming array because nothing previously existed |
|
| 238 | - : $dependencies; |
|
| 239 | - return $registered; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * @param string $class_name |
|
| 245 | - * @param string $loader |
|
| 246 | - * @return bool |
|
| 247 | - * @throws DomainException |
|
| 248 | - */ |
|
| 249 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 250 | - { |
|
| 251 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * @param string $class_name |
|
| 257 | - * @param string $loader |
|
| 258 | - * @return bool |
|
| 259 | - * @throws DomainException |
|
| 260 | - */ |
|
| 261 | - public function registerClassLoader($class_name, $loader = 'load_core') |
|
| 262 | - { |
|
| 263 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 264 | - throw new DomainException( |
|
| 265 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 266 | - ); |
|
| 267 | - } |
|
| 268 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 269 | - if (! is_callable($loader) |
|
| 270 | - && ( |
|
| 271 | - strpos($loader, 'load_') !== 0 |
|
| 272 | - || ! method_exists('EE_Registry', $loader) |
|
| 273 | - ) |
|
| 274 | - ) { |
|
| 275 | - throw new DomainException( |
|
| 276 | - sprintf( |
|
| 277 | - esc_html__( |
|
| 278 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 279 | - 'event_espresso' |
|
| 280 | - ), |
|
| 281 | - $loader |
|
| 282 | - ) |
|
| 283 | - ); |
|
| 284 | - } |
|
| 285 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 286 | - if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 287 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 288 | - return true; |
|
| 289 | - } |
|
| 290 | - return false; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * @return array |
|
| 296 | - */ |
|
| 297 | - public function dependency_map() |
|
| 298 | - { |
|
| 299 | - return $this->_dependency_map; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 305 | - * |
|
| 306 | - * @param string $class_name |
|
| 307 | - * @return boolean |
|
| 308 | - */ |
|
| 309 | - public function has($class_name = '') |
|
| 310 | - { |
|
| 311 | - // all legacy models have the same dependencies |
|
| 312 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 313 | - $class_name = 'LEGACY_MODELS'; |
|
| 314 | - } |
|
| 315 | - return isset($this->_dependency_map[ $class_name ]); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 321 | - * |
|
| 322 | - * @param string $class_name |
|
| 323 | - * @param string $dependency |
|
| 324 | - * @return bool |
|
| 325 | - */ |
|
| 326 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 327 | - { |
|
| 328 | - // all legacy models have the same dependencies |
|
| 329 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 330 | - $class_name = 'LEGACY_MODELS'; |
|
| 331 | - } |
|
| 332 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 333 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 339 | - * |
|
| 340 | - * @param string $class_name |
|
| 341 | - * @param string $dependency |
|
| 342 | - * @return int |
|
| 343 | - */ |
|
| 344 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 345 | - { |
|
| 346 | - // all legacy models have the same dependencies |
|
| 347 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 348 | - $class_name = 'LEGACY_MODELS'; |
|
| 349 | - } |
|
| 350 | - $dependency = $this->getFqnForAlias($dependency); |
|
| 351 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 352 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 353 | - : EE_Dependency_Map::not_registered; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * @param string $class_name |
|
| 359 | - * @return string | Closure |
|
| 360 | - */ |
|
| 361 | - public function class_loader($class_name) |
|
| 362 | - { |
|
| 363 | - // all legacy models use load_model() |
|
| 364 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 365 | - return 'load_model'; |
|
| 366 | - } |
|
| 367 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 368 | - // perform strpos() first to avoid loading regex every time we load a class |
|
| 369 | - if (strpos($class_name, 'EE_CPT_') === 0 |
|
| 370 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 371 | - ) { |
|
| 372 | - return 'load_core'; |
|
| 373 | - } |
|
| 374 | - $class_name = $this->getFqnForAlias($class_name); |
|
| 375 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * @return array |
|
| 381 | - */ |
|
| 382 | - public function class_loaders() |
|
| 383 | - { |
|
| 384 | - return $this->_class_loaders; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * adds an alias for a classname |
|
| 390 | - * |
|
| 391 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 392 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 393 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 394 | - * @throws InvalidAliasException |
|
| 395 | - */ |
|
| 396 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
| 397 | - { |
|
| 398 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
| 404 | - * WHY? |
|
| 405 | - * Because if a class is type hinting for a concretion, |
|
| 406 | - * then why would we need to find another class to supply it? |
|
| 407 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 408 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 409 | - * Don't go looking for some substitute. |
|
| 410 | - * Whereas if a class is type hinting for an interface... |
|
| 411 | - * then we need to find an actual class to use. |
|
| 412 | - * So the interface IS the alias for some other FQN, |
|
| 413 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 414 | - * represents some other class. |
|
| 415 | - * |
|
| 416 | - * @param string $fqn |
|
| 417 | - * @param string $for_class |
|
| 418 | - * @return bool |
|
| 419 | - */ |
|
| 420 | - public function isAlias($fqn = '', $for_class = '') |
|
| 421 | - { |
|
| 422 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 428 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 429 | - * for example: |
|
| 430 | - * if the following two entries were added to the _aliases array: |
|
| 431 | - * array( |
|
| 432 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 433 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 434 | - * ) |
|
| 435 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 436 | - * to load an instance of 'some\namespace\classname' |
|
| 437 | - * |
|
| 438 | - * @param string $alias |
|
| 439 | - * @param string $for_class |
|
| 440 | - * @return string |
|
| 441 | - */ |
|
| 442 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
| 443 | - { |
|
| 444 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 450 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 451 | - * This is done by using the following class constants: |
|
| 452 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 453 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 454 | - */ |
|
| 455 | - protected function _register_core_dependencies() |
|
| 456 | - { |
|
| 457 | - $this->_dependency_map = [ |
|
| 458 | - 'EE_Request_Handler' => [ |
|
| 459 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 460 | - ], |
|
| 461 | - 'EE_System' => [ |
|
| 462 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 463 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 464 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 465 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 466 | - ], |
|
| 467 | - 'EE_Cart' => [ |
|
| 468 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 469 | - ], |
|
| 470 | - 'EE_Messenger_Collection_Loader' => [ |
|
| 471 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 472 | - ], |
|
| 473 | - 'EE_Message_Type_Collection_Loader' => [ |
|
| 474 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 475 | - ], |
|
| 476 | - 'EE_Message_Resource_Manager' => [ |
|
| 477 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 478 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 479 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 480 | - ], |
|
| 481 | - 'EE_Message_Factory' => [ |
|
| 482 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 483 | - ], |
|
| 484 | - 'EE_messages' => [ |
|
| 485 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 486 | - ], |
|
| 487 | - 'EE_Messages_Generator' => [ |
|
| 488 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 489 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 490 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 491 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 492 | - ], |
|
| 493 | - 'EE_Messages_Processor' => [ |
|
| 494 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 495 | - ], |
|
| 496 | - 'EE_Messages_Queue' => [ |
|
| 497 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 498 | - ], |
|
| 499 | - 'EE_Messages_Template_Defaults' => [ |
|
| 500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 501 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 502 | - ], |
|
| 503 | - 'EE_Message_To_Generate_From_Request' => [ |
|
| 504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 505 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 506 | - ], |
|
| 507 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 508 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 509 | - ], |
|
| 510 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 511 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 512 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 513 | - ], |
|
| 514 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 515 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 516 | - ], |
|
| 517 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 518 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 519 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 520 | - ], |
|
| 521 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 522 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - ], |
|
| 524 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 525 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 526 | - ], |
|
| 527 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 528 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 529 | - ], |
|
| 530 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 531 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 532 | - ], |
|
| 533 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 534 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 535 | - ], |
|
| 536 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 537 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 538 | - ], |
|
| 539 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 540 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 541 | - ], |
|
| 542 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 543 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 544 | - ], |
|
| 545 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 546 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 547 | - ], |
|
| 548 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 549 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 550 | - ], |
|
| 551 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 552 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 553 | - ], |
|
| 554 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 555 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | - ], |
|
| 557 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 558 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 559 | - ], |
|
| 560 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
| 561 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 562 | - ], |
|
| 563 | - 'EE_Data_Migration_Class_Base' => [ |
|
| 564 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 565 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 566 | - ], |
|
| 567 | - 'EE_DMS_Core_4_1_0' => [ |
|
| 568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 569 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 570 | - ], |
|
| 571 | - 'EE_DMS_Core_4_2_0' => [ |
|
| 572 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 573 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 574 | - ], |
|
| 575 | - 'EE_DMS_Core_4_3_0' => [ |
|
| 576 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 577 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 578 | - ], |
|
| 579 | - 'EE_DMS_Core_4_4_0' => [ |
|
| 580 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 581 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 582 | - ], |
|
| 583 | - 'EE_DMS_Core_4_5_0' => [ |
|
| 584 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 585 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 586 | - ], |
|
| 587 | - 'EE_DMS_Core_4_6_0' => [ |
|
| 588 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 589 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 590 | - ], |
|
| 591 | - 'EE_DMS_Core_4_7_0' => [ |
|
| 592 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 593 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 594 | - ], |
|
| 595 | - 'EE_DMS_Core_4_8_0' => [ |
|
| 596 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 597 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 598 | - ], |
|
| 599 | - 'EE_DMS_Core_4_9_0' => [ |
|
| 600 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 601 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 602 | - ], |
|
| 603 | - 'EE_DMS_Core_4_10_0' => [ |
|
| 604 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 605 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 607 | - ], |
|
| 608 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
| 609 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 610 | - 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 611 | - [], |
|
| 612 | - ], |
|
| 613 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
| 614 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
| 616 | - ], |
|
| 617 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 618 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 619 | - ], |
|
| 620 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 621 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 622 | - ], |
|
| 623 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 624 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 625 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 626 | - ], |
|
| 627 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 628 | - null, |
|
| 629 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 630 | - ], |
|
| 631 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 632 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 633 | - ], |
|
| 634 | - 'LEGACY_MODELS' => [ |
|
| 635 | - null, |
|
| 636 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 637 | - ], |
|
| 638 | - 'EE_Module_Request_Router' => [ |
|
| 639 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 640 | - ], |
|
| 641 | - 'EE_Registration_Processor' => [ |
|
| 642 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 643 | - ], |
|
| 644 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 645 | - null, |
|
| 646 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 647 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 648 | - ], |
|
| 649 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 650 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 651 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 652 | - ], |
|
| 653 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 654 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 655 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 656 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 657 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 658 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 659 | - ], |
|
| 660 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 661 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 662 | - ], |
|
| 663 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 664 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 665 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 666 | - ], |
|
| 667 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 668 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 669 | - ], |
|
| 670 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 671 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 672 | - ], |
|
| 673 | - 'EE_CPT_Strategy' => [ |
|
| 674 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 675 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 676 | - ], |
|
| 677 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 678 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 679 | - ], |
|
| 680 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 681 | - null, |
|
| 682 | - null, |
|
| 683 | - null, |
|
| 684 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 685 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 686 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 687 | - ], |
|
| 688 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 689 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 690 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 691 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 692 | - ], |
|
| 693 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 694 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 695 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 696 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 697 | - ], |
|
| 698 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 699 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 700 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 701 | - ], |
|
| 702 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 703 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 704 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 705 | - ], |
|
| 706 | - 'EE_URL_Validation_Strategy' => [ |
|
| 707 | - null, |
|
| 708 | - null, |
|
| 709 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
| 710 | - ], |
|
| 711 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 712 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 713 | - ], |
|
| 714 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 715 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 716 | - ], |
|
| 717 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 718 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 719 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 720 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 721 | - null |
|
| 722 | - ], |
|
| 723 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 724 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 725 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 726 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 727 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 728 | - ], |
|
| 729 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests' => [ |
|
| 730 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 731 | - 'EventEspresso\core\services\json\JsonDataNode' => EE_Dependency_Map::load_from_cache, |
|
| 732 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 733 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 734 | - 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' => EE_Dependency_Map::load_from_cache, |
|
| 735 | - 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' => EE_Dependency_Map::load_from_cache, |
|
| 736 | - ], |
|
| 737 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 738 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 739 | - ], |
|
| 740 | - 'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager' => [ |
|
| 741 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 742 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 743 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 744 | - ], |
|
| 745 | - ]; |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - |
|
| 749 | - /** |
|
| 750 | - * Registers how core classes are loaded. |
|
| 751 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 752 | - * 'EE_Request_Handler' => 'load_core' |
|
| 753 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 754 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 755 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 756 | - * 'Some_Class' => function () { |
|
| 757 | - * return new Some_Class(); |
|
| 758 | - * }, |
|
| 759 | - * This is required for instantiating dependencies |
|
| 760 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 761 | - * 'Required_Interface' => function () { |
|
| 762 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 763 | - * }, |
|
| 764 | - */ |
|
| 765 | - protected function _register_core_class_loaders() |
|
| 766 | - { |
|
| 767 | - $this->_class_loaders = [ |
|
| 768 | - // load_core |
|
| 769 | - 'EE_Dependency_Map' => function () { |
|
| 770 | - return $this; |
|
| 771 | - }, |
|
| 772 | - 'EE_Capabilities' => 'load_core', |
|
| 773 | - 'EE_Encryption' => 'load_core', |
|
| 774 | - 'EE_Front_Controller' => 'load_core', |
|
| 775 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 776 | - 'EE_Registry' => 'load_core', |
|
| 777 | - 'EE_Request' => function () { |
|
| 778 | - return $this->legacy_request; |
|
| 779 | - }, |
|
| 780 | - 'EventEspresso\core\services\request\Request' => function () { |
|
| 781 | - return $this->request; |
|
| 782 | - }, |
|
| 783 | - 'EventEspresso\core\services\request\Response' => function () { |
|
| 784 | - return $this->response; |
|
| 785 | - }, |
|
| 786 | - 'EE_Base' => 'load_core', |
|
| 787 | - 'EE_Request_Handler' => 'load_core', |
|
| 788 | - 'EE_Session' => 'load_core', |
|
| 789 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 790 | - 'EE_System' => 'load_core', |
|
| 791 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 792 | - 'EE_Register_CPTs' => 'load_core', |
|
| 793 | - 'EE_Admin' => 'load_core', |
|
| 794 | - 'EE_CPT_Strategy' => 'load_core', |
|
| 795 | - // load_class |
|
| 796 | - 'EE_Registration_Processor' => 'load_class', |
|
| 797 | - // load_lib |
|
| 798 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 799 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 800 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 801 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 802 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 803 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 804 | - 'EE_Message_Repository' => 'load_lib', |
|
| 805 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 806 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 807 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 808 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 809 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 810 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 811 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 812 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 813 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 814 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 815 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 816 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 817 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 818 | - 'EE_Messages_Generator' => static function () { |
|
| 819 | - return EE_Registry::instance()->load_lib( |
|
| 820 | - 'Messages_Generator', |
|
| 821 | - [], |
|
| 822 | - false, |
|
| 823 | - false |
|
| 824 | - ); |
|
| 825 | - }, |
|
| 826 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 827 | - return EE_Registry::instance()->load_lib( |
|
| 828 | - 'Messages_Template_Defaults', |
|
| 829 | - $arguments, |
|
| 830 | - false, |
|
| 831 | - false |
|
| 832 | - ); |
|
| 833 | - }, |
|
| 834 | - // load_helper |
|
| 835 | - 'EEH_Parse_Shortcodes' => static function () { |
|
| 836 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 837 | - return new EEH_Parse_Shortcodes(); |
|
| 838 | - } |
|
| 839 | - return null; |
|
| 840 | - }, |
|
| 841 | - 'EE_Template_Config' => static function () { |
|
| 842 | - return EE_Config::instance()->template_settings; |
|
| 843 | - }, |
|
| 844 | - 'EE_Currency_Config' => static function () { |
|
| 845 | - return EE_Config::instance()->currency; |
|
| 846 | - }, |
|
| 847 | - 'EE_Registration_Config' => static function () { |
|
| 848 | - return EE_Config::instance()->registration; |
|
| 849 | - }, |
|
| 850 | - 'EE_Core_Config' => static function () { |
|
| 851 | - return EE_Config::instance()->core; |
|
| 852 | - }, |
|
| 853 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 854 | - return LoaderFactory::getLoader(); |
|
| 855 | - }, |
|
| 856 | - 'EE_Network_Config' => static function () { |
|
| 857 | - return EE_Network_Config::instance(); |
|
| 858 | - }, |
|
| 859 | - 'EE_Config' => static function () { |
|
| 860 | - return EE_Config::instance(); |
|
| 861 | - }, |
|
| 862 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
| 863 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
| 864 | - }, |
|
| 865 | - 'EE_Admin_Config' => static function () { |
|
| 866 | - return EE_Config::instance()->admin; |
|
| 867 | - }, |
|
| 868 | - 'EE_Organization_Config' => static function () { |
|
| 869 | - return EE_Config::instance()->organization; |
|
| 870 | - }, |
|
| 871 | - 'EE_Network_Core_Config' => static function () { |
|
| 872 | - return EE_Network_Config::instance()->core; |
|
| 873 | - }, |
|
| 874 | - 'EE_Environment_Config' => static function () { |
|
| 875 | - return EE_Config::instance()->environment; |
|
| 876 | - }, |
|
| 877 | - 'EED_Core_Rest_Api' => static function () { |
|
| 878 | - return EED_Core_Rest_Api::instance(); |
|
| 879 | - }, |
|
| 880 | - 'WP_REST_Server' => static function () { |
|
| 881 | - return rest_get_server(); |
|
| 882 | - }, |
|
| 883 | - ]; |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - |
|
| 887 | - /** |
|
| 888 | - * can be used for supplying alternate names for classes, |
|
| 889 | - * or for connecting interface names to instantiable classes |
|
| 890 | - * |
|
| 891 | - * @throws InvalidAliasException |
|
| 892 | - */ |
|
| 893 | - protected function _register_core_aliases() |
|
| 894 | - { |
|
| 895 | - $aliases = [ |
|
| 896 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 897 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 898 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 899 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 900 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 901 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 902 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 903 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 904 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 905 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 906 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 907 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 908 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 909 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 910 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 911 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 912 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 913 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 914 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 915 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 916 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 917 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 918 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 919 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 920 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 921 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 922 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 923 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 924 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 925 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 926 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 927 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 928 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 929 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 930 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 931 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 932 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 933 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 934 | - ]; |
|
| 935 | - foreach ($aliases as $alias => $fqn) { |
|
| 936 | - if (is_array($fqn)) { |
|
| 937 | - foreach ($fqn as $class => $for_class) { |
|
| 938 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 939 | - } |
|
| 940 | - continue; |
|
| 941 | - } |
|
| 942 | - $this->class_cache->addAlias($fqn, $alias); |
|
| 943 | - } |
|
| 944 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 945 | - $this->class_cache->addAlias( |
|
| 946 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 947 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 948 | - ); |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - /** |
|
| 954 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 955 | - * request Primarily used by unit tests. |
|
| 956 | - */ |
|
| 957 | - public function reset() |
|
| 958 | - { |
|
| 959 | - $this->_register_core_class_loaders(); |
|
| 960 | - $this->_register_core_dependencies(); |
|
| 961 | - } |
|
| 962 | - |
|
| 963 | - |
|
| 964 | - /** |
|
| 965 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
| 966 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 967 | - * WHY? |
|
| 968 | - * Because if a class is type hinting for a concretion, |
|
| 969 | - * then why would we need to find another class to supply it? |
|
| 970 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 971 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 972 | - * Don't go looking for some substitute. |
|
| 973 | - * Whereas if a class is type hinting for an interface... |
|
| 974 | - * then we need to find an actual class to use. |
|
| 975 | - * So the interface IS the alias for some other FQN, |
|
| 976 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 977 | - * represents some other class. |
|
| 978 | - * |
|
| 979 | - * @param string $fqn |
|
| 980 | - * @param string $for_class |
|
| 981 | - * @return bool |
|
| 982 | - * @deprecated 4.9.62.p |
|
| 983 | - */ |
|
| 984 | - public function has_alias($fqn = '', $for_class = '') |
|
| 985 | - { |
|
| 986 | - return $this->isAlias($fqn, $for_class); |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - |
|
| 990 | - /** |
|
| 991 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 992 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 993 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 994 | - * for example: |
|
| 995 | - * if the following two entries were added to the _aliases array: |
|
| 996 | - * array( |
|
| 997 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 998 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 999 | - * ) |
|
| 1000 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1001 | - * to load an instance of 'some\namespace\classname' |
|
| 1002 | - * |
|
| 1003 | - * @param string $alias |
|
| 1004 | - * @param string $for_class |
|
| 1005 | - * @return string |
|
| 1006 | - * @deprecated 4.9.62.p |
|
| 1007 | - */ |
|
| 1008 | - public function get_alias($alias = '', $for_class = '') |
|
| 1009 | - { |
|
| 1010 | - return $this->getFqnForAlias($alias, $for_class); |
|
| 1011 | - } |
|
| 24 | + /** |
|
| 25 | + * This means that the requested class dependency is not present in the dependency map |
|
| 26 | + */ |
|
| 27 | + const not_registered = 0; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 31 | + */ |
|
| 32 | + const load_new_object = 1; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 36 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 37 | + */ |
|
| 38 | + const load_from_cache = 2; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * When registering a dependency, |
|
| 42 | + * this indicates to keep any existing dependencies that already exist, |
|
| 43 | + * and simply discard any new dependencies declared in the incoming data |
|
| 44 | + */ |
|
| 45 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * When registering a dependency, |
|
| 49 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 50 | + */ |
|
| 51 | + const OVERWRITE_DEPENDENCIES = 1; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @type EE_Dependency_Map $_instance |
|
| 55 | + */ |
|
| 56 | + protected static $_instance; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var ClassInterfaceCache $class_cache |
|
| 60 | + */ |
|
| 61 | + private $class_cache; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @type RequestInterface $request |
|
| 65 | + */ |
|
| 66 | + protected $request; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @type LegacyRequestInterface $legacy_request |
|
| 70 | + */ |
|
| 71 | + protected $legacy_request; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @type ResponseInterface $response |
|
| 75 | + */ |
|
| 76 | + protected $response; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @type LoaderInterface $loader |
|
| 80 | + */ |
|
| 81 | + protected $loader; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @type array $_dependency_map |
|
| 85 | + */ |
|
| 86 | + protected $_dependency_map = []; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @type array $_class_loaders |
|
| 90 | + */ |
|
| 91 | + protected $_class_loaders = []; |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * EE_Dependency_Map constructor. |
|
| 96 | + * |
|
| 97 | + * @param ClassInterfaceCache $class_cache |
|
| 98 | + */ |
|
| 99 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
| 100 | + { |
|
| 101 | + $this->class_cache = $class_cache; |
|
| 102 | + do_action('EE_Dependency_Map____construct', $this); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return void |
|
| 108 | + * @throws InvalidAliasException |
|
| 109 | + */ |
|
| 110 | + public function initialize() |
|
| 111 | + { |
|
| 112 | + $this->_register_core_dependencies(); |
|
| 113 | + $this->_register_core_class_loaders(); |
|
| 114 | + $this->_register_core_aliases(); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @singleton method used to instantiate class object |
|
| 120 | + * @param ClassInterfaceCache|null $class_cache |
|
| 121 | + * @return EE_Dependency_Map |
|
| 122 | + */ |
|
| 123 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 124 | + { |
|
| 125 | + // check if class object is instantiated, and instantiated properly |
|
| 126 | + if (! 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 | + $class, |
|
| 179 | + array $dependencies, |
|
| 180 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 181 | + ) { |
|
| 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 | + $class, |
|
| 202 | + array $dependencies, |
|
| 203 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 204 | + ) { |
|
| 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 ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 215 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 216 | + ) { |
|
| 217 | + unset($dependencies[ $dependency ]); |
|
| 218 | + $dependencies[ $alias ] = $load_source; |
|
| 219 | + $registered = true; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + // now add our two lists of dependencies together. |
|
| 223 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 224 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 225 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 226 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 227 | + // especially with numerically indexed arrays |
|
| 228 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 229 | + // now we need to ensure that the resulting dependencies |
|
| 230 | + // array only has the entries that are required for the class |
|
| 231 | + // so first count how many dependencies were originally registered for the class |
|
| 232 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 233 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 234 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 235 | + // then truncate the final array to match that count |
|
| 236 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 237 | + // otherwise just take the incoming array because nothing previously existed |
|
| 238 | + : $dependencies; |
|
| 239 | + return $registered; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * @param string $class_name |
|
| 245 | + * @param string $loader |
|
| 246 | + * @return bool |
|
| 247 | + * @throws DomainException |
|
| 248 | + */ |
|
| 249 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 250 | + { |
|
| 251 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @param string $class_name |
|
| 257 | + * @param string $loader |
|
| 258 | + * @return bool |
|
| 259 | + * @throws DomainException |
|
| 260 | + */ |
|
| 261 | + public function registerClassLoader($class_name, $loader = 'load_core') |
|
| 262 | + { |
|
| 263 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 264 | + throw new DomainException( |
|
| 265 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 266 | + ); |
|
| 267 | + } |
|
| 268 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 269 | + if (! is_callable($loader) |
|
| 270 | + && ( |
|
| 271 | + strpos($loader, 'load_') !== 0 |
|
| 272 | + || ! method_exists('EE_Registry', $loader) |
|
| 273 | + ) |
|
| 274 | + ) { |
|
| 275 | + throw new DomainException( |
|
| 276 | + sprintf( |
|
| 277 | + esc_html__( |
|
| 278 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 279 | + 'event_espresso' |
|
| 280 | + ), |
|
| 281 | + $loader |
|
| 282 | + ) |
|
| 283 | + ); |
|
| 284 | + } |
|
| 285 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 286 | + if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 287 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 288 | + return true; |
|
| 289 | + } |
|
| 290 | + return false; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * @return array |
|
| 296 | + */ |
|
| 297 | + public function dependency_map() |
|
| 298 | + { |
|
| 299 | + return $this->_dependency_map; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 305 | + * |
|
| 306 | + * @param string $class_name |
|
| 307 | + * @return boolean |
|
| 308 | + */ |
|
| 309 | + public function has($class_name = '') |
|
| 310 | + { |
|
| 311 | + // all legacy models have the same dependencies |
|
| 312 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 313 | + $class_name = 'LEGACY_MODELS'; |
|
| 314 | + } |
|
| 315 | + return isset($this->_dependency_map[ $class_name ]); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 321 | + * |
|
| 322 | + * @param string $class_name |
|
| 323 | + * @param string $dependency |
|
| 324 | + * @return bool |
|
| 325 | + */ |
|
| 326 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 327 | + { |
|
| 328 | + // all legacy models have the same dependencies |
|
| 329 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 330 | + $class_name = 'LEGACY_MODELS'; |
|
| 331 | + } |
|
| 332 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 333 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 339 | + * |
|
| 340 | + * @param string $class_name |
|
| 341 | + * @param string $dependency |
|
| 342 | + * @return int |
|
| 343 | + */ |
|
| 344 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 345 | + { |
|
| 346 | + // all legacy models have the same dependencies |
|
| 347 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 348 | + $class_name = 'LEGACY_MODELS'; |
|
| 349 | + } |
|
| 350 | + $dependency = $this->getFqnForAlias($dependency); |
|
| 351 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 352 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 353 | + : EE_Dependency_Map::not_registered; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * @param string $class_name |
|
| 359 | + * @return string | Closure |
|
| 360 | + */ |
|
| 361 | + public function class_loader($class_name) |
|
| 362 | + { |
|
| 363 | + // all legacy models use load_model() |
|
| 364 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 365 | + return 'load_model'; |
|
| 366 | + } |
|
| 367 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 368 | + // perform strpos() first to avoid loading regex every time we load a class |
|
| 369 | + if (strpos($class_name, 'EE_CPT_') === 0 |
|
| 370 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 371 | + ) { |
|
| 372 | + return 'load_core'; |
|
| 373 | + } |
|
| 374 | + $class_name = $this->getFqnForAlias($class_name); |
|
| 375 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * @return array |
|
| 381 | + */ |
|
| 382 | + public function class_loaders() |
|
| 383 | + { |
|
| 384 | + return $this->_class_loaders; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * adds an alias for a classname |
|
| 390 | + * |
|
| 391 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 392 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 393 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 394 | + * @throws InvalidAliasException |
|
| 395 | + */ |
|
| 396 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
| 397 | + { |
|
| 398 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
| 404 | + * WHY? |
|
| 405 | + * Because if a class is type hinting for a concretion, |
|
| 406 | + * then why would we need to find another class to supply it? |
|
| 407 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 408 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 409 | + * Don't go looking for some substitute. |
|
| 410 | + * Whereas if a class is type hinting for an interface... |
|
| 411 | + * then we need to find an actual class to use. |
|
| 412 | + * So the interface IS the alias for some other FQN, |
|
| 413 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 414 | + * represents some other class. |
|
| 415 | + * |
|
| 416 | + * @param string $fqn |
|
| 417 | + * @param string $for_class |
|
| 418 | + * @return bool |
|
| 419 | + */ |
|
| 420 | + public function isAlias($fqn = '', $for_class = '') |
|
| 421 | + { |
|
| 422 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 428 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 429 | + * for example: |
|
| 430 | + * if the following two entries were added to the _aliases array: |
|
| 431 | + * array( |
|
| 432 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 433 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 434 | + * ) |
|
| 435 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 436 | + * to load an instance of 'some\namespace\classname' |
|
| 437 | + * |
|
| 438 | + * @param string $alias |
|
| 439 | + * @param string $for_class |
|
| 440 | + * @return string |
|
| 441 | + */ |
|
| 442 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
| 443 | + { |
|
| 444 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 450 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 451 | + * This is done by using the following class constants: |
|
| 452 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 453 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 454 | + */ |
|
| 455 | + protected function _register_core_dependencies() |
|
| 456 | + { |
|
| 457 | + $this->_dependency_map = [ |
|
| 458 | + 'EE_Request_Handler' => [ |
|
| 459 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 460 | + ], |
|
| 461 | + 'EE_System' => [ |
|
| 462 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 463 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 464 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 465 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 466 | + ], |
|
| 467 | + 'EE_Cart' => [ |
|
| 468 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 469 | + ], |
|
| 470 | + 'EE_Messenger_Collection_Loader' => [ |
|
| 471 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 472 | + ], |
|
| 473 | + 'EE_Message_Type_Collection_Loader' => [ |
|
| 474 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 475 | + ], |
|
| 476 | + 'EE_Message_Resource_Manager' => [ |
|
| 477 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 478 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 479 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 480 | + ], |
|
| 481 | + 'EE_Message_Factory' => [ |
|
| 482 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 483 | + ], |
|
| 484 | + 'EE_messages' => [ |
|
| 485 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 486 | + ], |
|
| 487 | + 'EE_Messages_Generator' => [ |
|
| 488 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 489 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 490 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 491 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 492 | + ], |
|
| 493 | + 'EE_Messages_Processor' => [ |
|
| 494 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 495 | + ], |
|
| 496 | + 'EE_Messages_Queue' => [ |
|
| 497 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 498 | + ], |
|
| 499 | + 'EE_Messages_Template_Defaults' => [ |
|
| 500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 501 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 502 | + ], |
|
| 503 | + 'EE_Message_To_Generate_From_Request' => [ |
|
| 504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 505 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 506 | + ], |
|
| 507 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 508 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 509 | + ], |
|
| 510 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 511 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 512 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 513 | + ], |
|
| 514 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 515 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 516 | + ], |
|
| 517 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 518 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 519 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 520 | + ], |
|
| 521 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 522 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + ], |
|
| 524 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 525 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 526 | + ], |
|
| 527 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 528 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 529 | + ], |
|
| 530 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 531 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 532 | + ], |
|
| 533 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 534 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 535 | + ], |
|
| 536 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 537 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 538 | + ], |
|
| 539 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 540 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 541 | + ], |
|
| 542 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 543 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 544 | + ], |
|
| 545 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 546 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 547 | + ], |
|
| 548 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 549 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 550 | + ], |
|
| 551 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 552 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 553 | + ], |
|
| 554 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 555 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | + ], |
|
| 557 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 558 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 559 | + ], |
|
| 560 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
| 561 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 562 | + ], |
|
| 563 | + 'EE_Data_Migration_Class_Base' => [ |
|
| 564 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 565 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 566 | + ], |
|
| 567 | + 'EE_DMS_Core_4_1_0' => [ |
|
| 568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 569 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 570 | + ], |
|
| 571 | + 'EE_DMS_Core_4_2_0' => [ |
|
| 572 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 573 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 574 | + ], |
|
| 575 | + 'EE_DMS_Core_4_3_0' => [ |
|
| 576 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 577 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 578 | + ], |
|
| 579 | + 'EE_DMS_Core_4_4_0' => [ |
|
| 580 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 581 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 582 | + ], |
|
| 583 | + 'EE_DMS_Core_4_5_0' => [ |
|
| 584 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 585 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 586 | + ], |
|
| 587 | + 'EE_DMS_Core_4_6_0' => [ |
|
| 588 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 589 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 590 | + ], |
|
| 591 | + 'EE_DMS_Core_4_7_0' => [ |
|
| 592 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 593 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 594 | + ], |
|
| 595 | + 'EE_DMS_Core_4_8_0' => [ |
|
| 596 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 597 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 598 | + ], |
|
| 599 | + 'EE_DMS_Core_4_9_0' => [ |
|
| 600 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 601 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 602 | + ], |
|
| 603 | + 'EE_DMS_Core_4_10_0' => [ |
|
| 604 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 605 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 607 | + ], |
|
| 608 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
| 609 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 610 | + 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 611 | + [], |
|
| 612 | + ], |
|
| 613 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
| 614 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
| 616 | + ], |
|
| 617 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 618 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 619 | + ], |
|
| 620 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 621 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 622 | + ], |
|
| 623 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 624 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 625 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 626 | + ], |
|
| 627 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 628 | + null, |
|
| 629 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 630 | + ], |
|
| 631 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 632 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 633 | + ], |
|
| 634 | + 'LEGACY_MODELS' => [ |
|
| 635 | + null, |
|
| 636 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 637 | + ], |
|
| 638 | + 'EE_Module_Request_Router' => [ |
|
| 639 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 640 | + ], |
|
| 641 | + 'EE_Registration_Processor' => [ |
|
| 642 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 643 | + ], |
|
| 644 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 645 | + null, |
|
| 646 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 647 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 648 | + ], |
|
| 649 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 650 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 651 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 652 | + ], |
|
| 653 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 654 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 655 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 656 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 657 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 658 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 659 | + ], |
|
| 660 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 661 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 662 | + ], |
|
| 663 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 664 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 665 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 666 | + ], |
|
| 667 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 668 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 669 | + ], |
|
| 670 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 671 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 672 | + ], |
|
| 673 | + 'EE_CPT_Strategy' => [ |
|
| 674 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 675 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 676 | + ], |
|
| 677 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 678 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 679 | + ], |
|
| 680 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 681 | + null, |
|
| 682 | + null, |
|
| 683 | + null, |
|
| 684 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 685 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 686 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 687 | + ], |
|
| 688 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 689 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 690 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 691 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 692 | + ], |
|
| 693 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 694 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 695 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 696 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 697 | + ], |
|
| 698 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 699 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 700 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 701 | + ], |
|
| 702 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 703 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 704 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 705 | + ], |
|
| 706 | + 'EE_URL_Validation_Strategy' => [ |
|
| 707 | + null, |
|
| 708 | + null, |
|
| 709 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
| 710 | + ], |
|
| 711 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 712 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 713 | + ], |
|
| 714 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 715 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 716 | + ], |
|
| 717 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 718 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 719 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 720 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 721 | + null |
|
| 722 | + ], |
|
| 723 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 724 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 725 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 726 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 727 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 728 | + ], |
|
| 729 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests' => [ |
|
| 730 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 731 | + 'EventEspresso\core\services\json\JsonDataNode' => EE_Dependency_Map::load_from_cache, |
|
| 732 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 733 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 734 | + 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' => EE_Dependency_Map::load_from_cache, |
|
| 735 | + 'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' => EE_Dependency_Map::load_from_cache, |
|
| 736 | + ], |
|
| 737 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 738 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 739 | + ], |
|
| 740 | + 'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager' => [ |
|
| 741 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 742 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 743 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 744 | + ], |
|
| 745 | + ]; |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + |
|
| 749 | + /** |
|
| 750 | + * Registers how core classes are loaded. |
|
| 751 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 752 | + * 'EE_Request_Handler' => 'load_core' |
|
| 753 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 754 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 755 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 756 | + * 'Some_Class' => function () { |
|
| 757 | + * return new Some_Class(); |
|
| 758 | + * }, |
|
| 759 | + * This is required for instantiating dependencies |
|
| 760 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 761 | + * 'Required_Interface' => function () { |
|
| 762 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 763 | + * }, |
|
| 764 | + */ |
|
| 765 | + protected function _register_core_class_loaders() |
|
| 766 | + { |
|
| 767 | + $this->_class_loaders = [ |
|
| 768 | + // load_core |
|
| 769 | + 'EE_Dependency_Map' => function () { |
|
| 770 | + return $this; |
|
| 771 | + }, |
|
| 772 | + 'EE_Capabilities' => 'load_core', |
|
| 773 | + 'EE_Encryption' => 'load_core', |
|
| 774 | + 'EE_Front_Controller' => 'load_core', |
|
| 775 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 776 | + 'EE_Registry' => 'load_core', |
|
| 777 | + 'EE_Request' => function () { |
|
| 778 | + return $this->legacy_request; |
|
| 779 | + }, |
|
| 780 | + 'EventEspresso\core\services\request\Request' => function () { |
|
| 781 | + return $this->request; |
|
| 782 | + }, |
|
| 783 | + 'EventEspresso\core\services\request\Response' => function () { |
|
| 784 | + return $this->response; |
|
| 785 | + }, |
|
| 786 | + 'EE_Base' => 'load_core', |
|
| 787 | + 'EE_Request_Handler' => 'load_core', |
|
| 788 | + 'EE_Session' => 'load_core', |
|
| 789 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 790 | + 'EE_System' => 'load_core', |
|
| 791 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 792 | + 'EE_Register_CPTs' => 'load_core', |
|
| 793 | + 'EE_Admin' => 'load_core', |
|
| 794 | + 'EE_CPT_Strategy' => 'load_core', |
|
| 795 | + // load_class |
|
| 796 | + 'EE_Registration_Processor' => 'load_class', |
|
| 797 | + // load_lib |
|
| 798 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 799 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 800 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 801 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 802 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 803 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 804 | + 'EE_Message_Repository' => 'load_lib', |
|
| 805 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 806 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 807 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 808 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 809 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 810 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 811 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 812 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 813 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 814 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 815 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 816 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 817 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 818 | + 'EE_Messages_Generator' => static function () { |
|
| 819 | + return EE_Registry::instance()->load_lib( |
|
| 820 | + 'Messages_Generator', |
|
| 821 | + [], |
|
| 822 | + false, |
|
| 823 | + false |
|
| 824 | + ); |
|
| 825 | + }, |
|
| 826 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 827 | + return EE_Registry::instance()->load_lib( |
|
| 828 | + 'Messages_Template_Defaults', |
|
| 829 | + $arguments, |
|
| 830 | + false, |
|
| 831 | + false |
|
| 832 | + ); |
|
| 833 | + }, |
|
| 834 | + // load_helper |
|
| 835 | + 'EEH_Parse_Shortcodes' => static function () { |
|
| 836 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 837 | + return new EEH_Parse_Shortcodes(); |
|
| 838 | + } |
|
| 839 | + return null; |
|
| 840 | + }, |
|
| 841 | + 'EE_Template_Config' => static function () { |
|
| 842 | + return EE_Config::instance()->template_settings; |
|
| 843 | + }, |
|
| 844 | + 'EE_Currency_Config' => static function () { |
|
| 845 | + return EE_Config::instance()->currency; |
|
| 846 | + }, |
|
| 847 | + 'EE_Registration_Config' => static function () { |
|
| 848 | + return EE_Config::instance()->registration; |
|
| 849 | + }, |
|
| 850 | + 'EE_Core_Config' => static function () { |
|
| 851 | + return EE_Config::instance()->core; |
|
| 852 | + }, |
|
| 853 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 854 | + return LoaderFactory::getLoader(); |
|
| 855 | + }, |
|
| 856 | + 'EE_Network_Config' => static function () { |
|
| 857 | + return EE_Network_Config::instance(); |
|
| 858 | + }, |
|
| 859 | + 'EE_Config' => static function () { |
|
| 860 | + return EE_Config::instance(); |
|
| 861 | + }, |
|
| 862 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
| 863 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
| 864 | + }, |
|
| 865 | + 'EE_Admin_Config' => static function () { |
|
| 866 | + return EE_Config::instance()->admin; |
|
| 867 | + }, |
|
| 868 | + 'EE_Organization_Config' => static function () { |
|
| 869 | + return EE_Config::instance()->organization; |
|
| 870 | + }, |
|
| 871 | + 'EE_Network_Core_Config' => static function () { |
|
| 872 | + return EE_Network_Config::instance()->core; |
|
| 873 | + }, |
|
| 874 | + 'EE_Environment_Config' => static function () { |
|
| 875 | + return EE_Config::instance()->environment; |
|
| 876 | + }, |
|
| 877 | + 'EED_Core_Rest_Api' => static function () { |
|
| 878 | + return EED_Core_Rest_Api::instance(); |
|
| 879 | + }, |
|
| 880 | + 'WP_REST_Server' => static function () { |
|
| 881 | + return rest_get_server(); |
|
| 882 | + }, |
|
| 883 | + ]; |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + |
|
| 887 | + /** |
|
| 888 | + * can be used for supplying alternate names for classes, |
|
| 889 | + * or for connecting interface names to instantiable classes |
|
| 890 | + * |
|
| 891 | + * @throws InvalidAliasException |
|
| 892 | + */ |
|
| 893 | + protected function _register_core_aliases() |
|
| 894 | + { |
|
| 895 | + $aliases = [ |
|
| 896 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 897 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 898 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 899 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 900 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 901 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 902 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 903 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 904 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 905 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 906 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 907 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 908 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 909 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 910 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 911 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 912 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 913 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 914 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 915 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 916 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 917 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 918 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 919 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 920 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 921 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 922 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 923 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 924 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 925 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 926 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 927 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 928 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 929 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 930 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 931 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 932 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 933 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 934 | + ]; |
|
| 935 | + foreach ($aliases as $alias => $fqn) { |
|
| 936 | + if (is_array($fqn)) { |
|
| 937 | + foreach ($fqn as $class => $for_class) { |
|
| 938 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 939 | + } |
|
| 940 | + continue; |
|
| 941 | + } |
|
| 942 | + $this->class_cache->addAlias($fqn, $alias); |
|
| 943 | + } |
|
| 944 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 945 | + $this->class_cache->addAlias( |
|
| 946 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 947 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 948 | + ); |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + /** |
|
| 954 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 955 | + * request Primarily used by unit tests. |
|
| 956 | + */ |
|
| 957 | + public function reset() |
|
| 958 | + { |
|
| 959 | + $this->_register_core_class_loaders(); |
|
| 960 | + $this->_register_core_dependencies(); |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + |
|
| 964 | + /** |
|
| 965 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
| 966 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 967 | + * WHY? |
|
| 968 | + * Because if a class is type hinting for a concretion, |
|
| 969 | + * then why would we need to find another class to supply it? |
|
| 970 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 971 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 972 | + * Don't go looking for some substitute. |
|
| 973 | + * Whereas if a class is type hinting for an interface... |
|
| 974 | + * then we need to find an actual class to use. |
|
| 975 | + * So the interface IS the alias for some other FQN, |
|
| 976 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 977 | + * represents some other class. |
|
| 978 | + * |
|
| 979 | + * @param string $fqn |
|
| 980 | + * @param string $for_class |
|
| 981 | + * @return bool |
|
| 982 | + * @deprecated 4.9.62.p |
|
| 983 | + */ |
|
| 984 | + public function has_alias($fqn = '', $for_class = '') |
|
| 985 | + { |
|
| 986 | + return $this->isAlias($fqn, $for_class); |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + |
|
| 990 | + /** |
|
| 991 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 992 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 993 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 994 | + * for example: |
|
| 995 | + * if the following two entries were added to the _aliases array: |
|
| 996 | + * array( |
|
| 997 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 998 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 999 | + * ) |
|
| 1000 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1001 | + * to load an instance of 'some\namespace\classname' |
|
| 1002 | + * |
|
| 1003 | + * @param string $alias |
|
| 1004 | + * @param string $for_class |
|
| 1005 | + * @return string |
|
| 1006 | + * @deprecated 4.9.62.p |
|
| 1007 | + */ |
|
| 1008 | + public function get_alias($alias = '', $for_class = '') |
|
| 1009 | + { |
|
| 1010 | + return $this->getFqnForAlias($alias, $for_class); |
|
| 1011 | + } |
|
| 1012 | 1012 | } |
@@ -19,61 +19,61 @@ |
||
| 19 | 19 | interface JsonDataNodeInterface extends JsonSerializable |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @param JsonDataNode $data_node |
|
| 24 | - * @throws DomainException |
|
| 25 | - */ |
|
| 26 | - public function addDataNode(JsonDataNode $data_node); |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * the actual data in key value array format |
|
| 31 | - * |
|
| 32 | - * @return array |
|
| 33 | - */ |
|
| 34 | - public function data(); |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * specifies the domain (use case) that this route defines |
|
| 39 | - * ! IMPORTANT ! |
|
| 40 | - * only one domain can be set pre request |
|
| 41 | - * |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function domain(); |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * !!! IMPORTANT !!! |
|
| 49 | - * JsonDataNode::setInitialized(true) needs to be called once initialization is complete |
|
| 50 | - * else you're a bad person and bad things will happen to you !!! |
|
| 51 | - * |
|
| 52 | - * @since $VID:$ |
|
| 53 | - */ |
|
| 54 | - public function initialize(); |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * true if the data node has been initialized, |
|
| 59 | - * which entails retrieving the required data and adding it to the data node data array |
|
| 60 | - * |
|
| 61 | - * @return bool |
|
| 62 | - */ |
|
| 63 | - public function isInitialized(); |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * true if the data node has NOT been initialized |
|
| 68 | - * |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public function isNotInitialized(); |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return string |
|
| 76 | - * @since $VID:$ |
|
| 77 | - */ |
|
| 78 | - public function nodeName(); |
|
| 22 | + /** |
|
| 23 | + * @param JsonDataNode $data_node |
|
| 24 | + * @throws DomainException |
|
| 25 | + */ |
|
| 26 | + public function addDataNode(JsonDataNode $data_node); |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * the actual data in key value array format |
|
| 31 | + * |
|
| 32 | + * @return array |
|
| 33 | + */ |
|
| 34 | + public function data(); |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * specifies the domain (use case) that this route defines |
|
| 39 | + * ! IMPORTANT ! |
|
| 40 | + * only one domain can be set pre request |
|
| 41 | + * |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function domain(); |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * !!! IMPORTANT !!! |
|
| 49 | + * JsonDataNode::setInitialized(true) needs to be called once initialization is complete |
|
| 50 | + * else you're a bad person and bad things will happen to you !!! |
|
| 51 | + * |
|
| 52 | + * @since $VID:$ |
|
| 53 | + */ |
|
| 54 | + public function initialize(); |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * true if the data node has been initialized, |
|
| 59 | + * which entails retrieving the required data and adding it to the data node data array |
|
| 60 | + * |
|
| 61 | + * @return bool |
|
| 62 | + */ |
|
| 63 | + public function isInitialized(); |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * true if the data node has NOT been initialized |
|
| 68 | + * |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public function isNotInitialized(); |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return string |
|
| 76 | + * @since $VID:$ |
|
| 77 | + */ |
|
| 78 | + public function nodeName(); |
|
| 79 | 79 | } |
@@ -20,122 +20,122 @@ |
||
| 20 | 20 | class RouteHandler |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var JsonDataNodeHandler $data_node_handler |
|
| 25 | - */ |
|
| 26 | - private $data_node_handler; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var LoaderInterface $loader |
|
| 30 | - */ |
|
| 31 | - private $loader; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var RequestInterface $request |
|
| 35 | - */ |
|
| 36 | - protected $request; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var RouteCollection $routes |
|
| 40 | - */ |
|
| 41 | - private $routes; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * RouteHandler constructor. |
|
| 46 | - * |
|
| 47 | - * @param JsonDataNodeHandler $data_node_handler |
|
| 48 | - * @param LoaderInterface $loader |
|
| 49 | - * @param RequestInterface $request |
|
| 50 | - * @param RouteCollection $routes |
|
| 51 | - */ |
|
| 52 | - public function __construct( |
|
| 53 | - JsonDataNodeHandler $data_node_handler, |
|
| 54 | - LoaderInterface $loader, |
|
| 55 | - RequestInterface $request, |
|
| 56 | - RouteCollection $routes |
|
| 57 | - ) { |
|
| 58 | - $this->data_node_handler = $data_node_handler; |
|
| 59 | - $this->loader = $loader; |
|
| 60 | - $this->request = $request; |
|
| 61 | - $this->routes = $routes; |
|
| 62 | - add_action('admin_footer', [$this->data_node_handler, 'printDataNode']); |
|
| 63 | - add_action('wp_footer', [$this->data_node_handler, 'printDataNode']); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param string $fqcn Fully Qualified Class Name for Route |
|
| 69 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
| 70 | - * @throws Exception |
|
| 71 | - * @since $VID:$ |
|
| 72 | - */ |
|
| 73 | - public function addRoute($fqcn, $handle = true) |
|
| 74 | - { |
|
| 75 | - try { |
|
| 76 | - if ($this->request->isActivation()) { |
|
| 77 | - return; |
|
| 78 | - } |
|
| 79 | - $route = $this->loader->getShared($fqcn); |
|
| 80 | - $this->validateRoute($route, $fqcn); |
|
| 81 | - $this->routes->add($route); |
|
| 82 | - $this->handle($route, $handle); |
|
| 83 | - } catch (Exception $exception) { |
|
| 84 | - new ExceptionStackTraceDisplay($exception); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param RouteInterface $route |
|
| 91 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
| 92 | - */ |
|
| 93 | - public function handle(RouteInterface $route, $handle = true) |
|
| 94 | - { |
|
| 95 | - if ($handle && $route->isNotHandled()) { |
|
| 96 | - $route->handleRequest(); |
|
| 97 | - $data_node = $route->dataNode(); |
|
| 98 | - if ($data_node instanceof JsonDataNode) { |
|
| 99 | - $this->data_node_handler->addDataNode($data_node); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * calls RouteInterface::handleRequest() on all Routes that |
|
| 107 | - * - match current request |
|
| 108 | - * - have yet to be handled |
|
| 109 | - * |
|
| 110 | - * @return void |
|
| 111 | - */ |
|
| 112 | - public function handleRoutesForCurrentRequest() |
|
| 113 | - { |
|
| 114 | - $this->routes->handleRoutesForCurrentRequest(); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param RouteInterface $route |
|
| 120 | - * @param string $fqcn |
|
| 121 | - * @since $VID:$ |
|
| 122 | - */ |
|
| 123 | - private function validateRoute($route, $fqcn) |
|
| 124 | - { |
|
| 125 | - if (! $route instanceof RouteInterface) { |
|
| 126 | - throw new InvalidClassException( |
|
| 127 | - sprintf( |
|
| 128 | - /* |
|
| 23 | + /** |
|
| 24 | + * @var JsonDataNodeHandler $data_node_handler |
|
| 25 | + */ |
|
| 26 | + private $data_node_handler; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var LoaderInterface $loader |
|
| 30 | + */ |
|
| 31 | + private $loader; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var RequestInterface $request |
|
| 35 | + */ |
|
| 36 | + protected $request; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var RouteCollection $routes |
|
| 40 | + */ |
|
| 41 | + private $routes; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * RouteHandler constructor. |
|
| 46 | + * |
|
| 47 | + * @param JsonDataNodeHandler $data_node_handler |
|
| 48 | + * @param LoaderInterface $loader |
|
| 49 | + * @param RequestInterface $request |
|
| 50 | + * @param RouteCollection $routes |
|
| 51 | + */ |
|
| 52 | + public function __construct( |
|
| 53 | + JsonDataNodeHandler $data_node_handler, |
|
| 54 | + LoaderInterface $loader, |
|
| 55 | + RequestInterface $request, |
|
| 56 | + RouteCollection $routes |
|
| 57 | + ) { |
|
| 58 | + $this->data_node_handler = $data_node_handler; |
|
| 59 | + $this->loader = $loader; |
|
| 60 | + $this->request = $request; |
|
| 61 | + $this->routes = $routes; |
|
| 62 | + add_action('admin_footer', [$this->data_node_handler, 'printDataNode']); |
|
| 63 | + add_action('wp_footer', [$this->data_node_handler, 'printDataNode']); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param string $fqcn Fully Qualified Class Name for Route |
|
| 69 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
| 70 | + * @throws Exception |
|
| 71 | + * @since $VID:$ |
|
| 72 | + */ |
|
| 73 | + public function addRoute($fqcn, $handle = true) |
|
| 74 | + { |
|
| 75 | + try { |
|
| 76 | + if ($this->request->isActivation()) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | + $route = $this->loader->getShared($fqcn); |
|
| 80 | + $this->validateRoute($route, $fqcn); |
|
| 81 | + $this->routes->add($route); |
|
| 82 | + $this->handle($route, $handle); |
|
| 83 | + } catch (Exception $exception) { |
|
| 84 | + new ExceptionStackTraceDisplay($exception); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param RouteInterface $route |
|
| 91 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
| 92 | + */ |
|
| 93 | + public function handle(RouteInterface $route, $handle = true) |
|
| 94 | + { |
|
| 95 | + if ($handle && $route->isNotHandled()) { |
|
| 96 | + $route->handleRequest(); |
|
| 97 | + $data_node = $route->dataNode(); |
|
| 98 | + if ($data_node instanceof JsonDataNode) { |
|
| 99 | + $this->data_node_handler->addDataNode($data_node); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * calls RouteInterface::handleRequest() on all Routes that |
|
| 107 | + * - match current request |
|
| 108 | + * - have yet to be handled |
|
| 109 | + * |
|
| 110 | + * @return void |
|
| 111 | + */ |
|
| 112 | + public function handleRoutesForCurrentRequest() |
|
| 113 | + { |
|
| 114 | + $this->routes->handleRoutesForCurrentRequest(); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param RouteInterface $route |
|
| 120 | + * @param string $fqcn |
|
| 121 | + * @since $VID:$ |
|
| 122 | + */ |
|
| 123 | + private function validateRoute($route, $fqcn) |
|
| 124 | + { |
|
| 125 | + if (! $route instanceof RouteInterface) { |
|
| 126 | + throw new InvalidClassException( |
|
| 127 | + sprintf( |
|
| 128 | + /* |
|
| 129 | 129 | * translators: |
| 130 | 130 | * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface. |
| 131 | 131 | */ |
| 132 | - esc_html__( |
|
| 133 | - 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
| 134 | - 'event_espresso' |
|
| 135 | - ), |
|
| 136 | - $fqcn |
|
| 137 | - ) |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } |
|
| 132 | + esc_html__( |
|
| 133 | + 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
| 134 | + 'event_espresso' |
|
| 135 | + ), |
|
| 136 | + $fqcn |
|
| 137 | + ) |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | } |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | */ |
| 123 | 123 | private function validateRoute($route, $fqcn) |
| 124 | 124 | { |
| 125 | - if (! $route instanceof RouteInterface) { |
|
| 125 | + if ( ! $route instanceof RouteInterface) { |
|
| 126 | 126 | throw new InvalidClassException( |
| 127 | 127 | sprintf( |
| 128 | 128 | /* |
@@ -95,19 +95,19 @@ |
||
| 95 | 95 | */ |
| 96 | 96 | public function addDependencies() |
| 97 | 97 | { |
| 98 | - if (! $this->asset_manager instanceof EspressoCoreAppAssetManager) { |
|
| 98 | + if ( ! $this->asset_manager instanceof EspressoCoreAppAssetManager) { |
|
| 99 | 99 | throw new DomainException( |
| 100 | 100 | esc_html__('Invalid or missing EspressoCoreAppAssetManager!', 'event_espresso') |
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | 103 | $assets = $this->asset_manager->getAssets(); |
| 104 | - if (! $assets instanceof AssetCollection) { |
|
| 104 | + if ( ! $assets instanceof AssetCollection) { |
|
| 105 | 105 | throw new DomainException( |
| 106 | 106 | esc_html__('Invalid or missing AssetCollection!', 'event_espresso') |
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | $appJs = $assets->getJavascriptAsset(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR); |
| 110 | - if (! $appJs instanceof JavascriptAsset) { |
|
| 110 | + if ( ! $appJs instanceof JavascriptAsset) { |
|
| 111 | 111 | throw new DomainException( |
| 112 | 112 | sprintf( |
| 113 | 113 | esc_html__('Invalid or missing JavascriptAsset! Expected', 'event_espresso'), |
@@ -23,104 +23,104 @@ |
||
| 23 | 23 | class WordPressPluginsPage extends Route |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * returns true if the current request matches this route |
|
| 28 | - * |
|
| 29 | - * @return bool |
|
| 30 | - * @since $VID:$ |
|
| 31 | - */ |
|
| 32 | - public function matchesCurrentRequest() |
|
| 33 | - { |
|
| 34 | - global $pagenow; |
|
| 35 | - return $this->request->isAdmin() && $pagenow && $pagenow === 'plugins.php'; |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * returns true if the current request matches this route |
|
| 28 | + * |
|
| 29 | + * @return bool |
|
| 30 | + * @since $VID:$ |
|
| 31 | + */ |
|
| 32 | + public function matchesCurrentRequest() |
|
| 33 | + { |
|
| 34 | + global $pagenow; |
|
| 35 | + return $this->request->isAdmin() && $pagenow && $pagenow === 'plugins.php'; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @since $VID:$ |
|
| 41 | - */ |
|
| 42 | - protected function registerDependencies() |
|
| 43 | - { |
|
| 44 | - $this->dependency_map->registerDependencies( |
|
| 45 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\WordPressPluginsPageData', |
|
| 46 | - [ |
|
| 47 | - 'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache, |
|
| 48 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 49 | - ] |
|
| 50 | - ); |
|
| 51 | - $this->dependency_map->registerDependencies( |
|
| 52 | - 'EventEspresso\core\domain\services\admin\ExitModal', |
|
| 53 | - ['EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache] |
|
| 54 | - ); |
|
| 55 | - $this->dependency_map->registerDependencies( |
|
| 56 | - 'EventEspresso\core\domain\services\admin\PluginUpsells', |
|
| 57 | - ['EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache] |
|
| 58 | - ); |
|
| 39 | + /** |
|
| 40 | + * @since $VID:$ |
|
| 41 | + */ |
|
| 42 | + protected function registerDependencies() |
|
| 43 | + { |
|
| 44 | + $this->dependency_map->registerDependencies( |
|
| 45 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\WordPressPluginsPageData', |
|
| 46 | + [ |
|
| 47 | + 'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache, |
|
| 48 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 49 | + ] |
|
| 50 | + ); |
|
| 51 | + $this->dependency_map->registerDependencies( |
|
| 52 | + 'EventEspresso\core\domain\services\admin\ExitModal', |
|
| 53 | + ['EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache] |
|
| 54 | + ); |
|
| 55 | + $this->dependency_map->registerDependencies( |
|
| 56 | + 'EventEspresso\core\domain\services\admin\PluginUpsells', |
|
| 57 | + ['EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache] |
|
| 58 | + ); |
|
| 59 | 59 | |
| 60 | - /** @var EventEspressoData $primary_data_node */ |
|
| 61 | - $primary_data_node = $this->loader->getShared( |
|
| 62 | - 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' |
|
| 63 | - ); |
|
| 64 | - $primary_data_node->setTargetScript(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR); |
|
| 65 | - /** @var WordPressPluginsPageData $data_node */ |
|
| 66 | - $data_node = $this->loader->getShared( |
|
| 67 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\WordPressPluginsPageData' |
|
| 68 | - ); |
|
| 69 | - $this->setDataNode($data_node); |
|
| 70 | - /** @var PluginUpsells $plugin_upsells */ |
|
| 71 | - $plugin_upsells = $this->loader->getShared('EventEspresso\core\domain\services\admin\PluginUpsells'); |
|
| 72 | - $plugin_upsells->decafUpsells(); |
|
| 73 | - } |
|
| 60 | + /** @var EventEspressoData $primary_data_node */ |
|
| 61 | + $primary_data_node = $this->loader->getShared( |
|
| 62 | + 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData' |
|
| 63 | + ); |
|
| 64 | + $primary_data_node->setTargetScript(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR); |
|
| 65 | + /** @var WordPressPluginsPageData $data_node */ |
|
| 66 | + $data_node = $this->loader->getShared( |
|
| 67 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\WordPressPluginsPageData' |
|
| 68 | + ); |
|
| 69 | + $this->setDataNode($data_node); |
|
| 70 | + /** @var PluginUpsells $plugin_upsells */ |
|
| 71 | + $plugin_upsells = $this->loader->getShared('EventEspresso\core\domain\services\admin\PluginUpsells'); |
|
| 72 | + $plugin_upsells->decafUpsells(); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * implements logic required to run during request |
|
| 78 | - * |
|
| 79 | - * @return bool |
|
| 80 | - * @since $VID:$ |
|
| 81 | - */ |
|
| 82 | - protected function requestHandler() |
|
| 83 | - { |
|
| 84 | - /** @var EspressoCoreAppAssetManager $asset_manager */ |
|
| 85 | - $this->asset_manager = $this->loader->getShared( |
|
| 86 | - 'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager' |
|
| 87 | - ); |
|
| 88 | - add_action('admin_enqueue_scripts', [$this, 'addDependencies'], 3); |
|
| 89 | - add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100); |
|
| 90 | - wp_enqueue_style('wp-components'); |
|
| 91 | - return true; |
|
| 92 | - } |
|
| 76 | + /** |
|
| 77 | + * implements logic required to run during request |
|
| 78 | + * |
|
| 79 | + * @return bool |
|
| 80 | + * @since $VID:$ |
|
| 81 | + */ |
|
| 82 | + protected function requestHandler() |
|
| 83 | + { |
|
| 84 | + /** @var EspressoCoreAppAssetManager $asset_manager */ |
|
| 85 | + $this->asset_manager = $this->loader->getShared( |
|
| 86 | + 'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager' |
|
| 87 | + ); |
|
| 88 | + add_action('admin_enqueue_scripts', [$this, 'addDependencies'], 3); |
|
| 89 | + add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100); |
|
| 90 | + wp_enqueue_style('wp-components'); |
|
| 91 | + return true; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * EspressoCoreAppAssetManager sets 'wp-i18n' as the only dependency for its scripts, |
|
| 97 | - * but the ExitSurvey uses additional WP core assets, so this method retrieves the |
|
| 98 | - * 'eventespresso-core-app' script and updates its dependencies accordingly |
|
| 99 | - * |
|
| 100 | - * @since $VID:$ |
|
| 101 | - */ |
|
| 102 | - public function addDependencies() |
|
| 103 | - { |
|
| 104 | - if (! $this->asset_manager instanceof EspressoCoreAppAssetManager) { |
|
| 105 | - throw new DomainException( |
|
| 106 | - esc_html__('Invalid or missing EspressoCoreAppAssetManager!', 'event_espresso') |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - $assets = $this->asset_manager->getAssets(); |
|
| 110 | - if (! $assets instanceof AssetCollection) { |
|
| 111 | - throw new DomainException( |
|
| 112 | - esc_html__('Invalid or missing AssetCollection!', 'event_espresso') |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - $appJs = $assets->getJavascriptAsset(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR); |
|
| 116 | - if (! $appJs instanceof JavascriptAsset) { |
|
| 117 | - throw new DomainException( |
|
| 118 | - sprintf( |
|
| 119 | - esc_html__('Invalid or missing JavascriptAsset! Expected', 'event_espresso'), |
|
| 120 | - EspressoCoreAppAssetManager::JS_HANDLE_EDITOR |
|
| 121 | - ) |
|
| 122 | - ); |
|
| 123 | - } |
|
| 124 | - $appJs->addDependencies(['wp-components', 'wp-url']); |
|
| 125 | - } |
|
| 95 | + /** |
|
| 96 | + * EspressoCoreAppAssetManager sets 'wp-i18n' as the only dependency for its scripts, |
|
| 97 | + * but the ExitSurvey uses additional WP core assets, so this method retrieves the |
|
| 98 | + * 'eventespresso-core-app' script and updates its dependencies accordingly |
|
| 99 | + * |
|
| 100 | + * @since $VID:$ |
|
| 101 | + */ |
|
| 102 | + public function addDependencies() |
|
| 103 | + { |
|
| 104 | + if (! $this->asset_manager instanceof EspressoCoreAppAssetManager) { |
|
| 105 | + throw new DomainException( |
|
| 106 | + esc_html__('Invalid or missing EspressoCoreAppAssetManager!', 'event_espresso') |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + $assets = $this->asset_manager->getAssets(); |
|
| 110 | + if (! $assets instanceof AssetCollection) { |
|
| 111 | + throw new DomainException( |
|
| 112 | + esc_html__('Invalid or missing AssetCollection!', 'event_espresso') |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + $appJs = $assets->getJavascriptAsset(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR); |
|
| 116 | + if (! $appJs instanceof JavascriptAsset) { |
|
| 117 | + throw new DomainException( |
|
| 118 | + sprintf( |
|
| 119 | + esc_html__('Invalid or missing JavascriptAsset! Expected', 'event_espresso'), |
|
| 120 | + EspressoCoreAppAssetManager::JS_HANDLE_EDITOR |
|
| 121 | + ) |
|
| 122 | + ); |
|
| 123 | + } |
|
| 124 | + $appJs->addDependencies(['wp-components', 'wp-url']); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -17,40 +17,40 @@ |
||
| 17 | 17 | class EspressoCoreDomain extends JsonDataNode |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - const NODE_NAME = 'coreDomain'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var Domain $domain |
|
| 24 | - */ |
|
| 25 | - private $domain; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * JsonDataNode constructor. |
|
| 30 | - * |
|
| 31 | - * @param Domain $domain |
|
| 32 | - * @param JsonDataNodeValidator $validator |
|
| 33 | - */ |
|
| 34 | - public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
| 35 | - { |
|
| 36 | - $this->domain = $domain; |
|
| 37 | - parent::__construct($validator); |
|
| 38 | - $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @inheritDoc |
|
| 44 | - */ |
|
| 45 | - public function initialize() |
|
| 46 | - { |
|
| 47 | - $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
| 48 | - $this->addData('brandName', Domain::brandName()); |
|
| 49 | - $this->addData('coreVersion', $this->domain->version()); |
|
| 50 | - $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
| 51 | - $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
| 52 | - $this->addData('pluginPath', $this->domain->pluginPath()); |
|
| 53 | - $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
| 54 | - $this->setInitialized(true); |
|
| 55 | - } |
|
| 20 | + const NODE_NAME = 'coreDomain'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var Domain $domain |
|
| 24 | + */ |
|
| 25 | + private $domain; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * JsonDataNode constructor. |
|
| 30 | + * |
|
| 31 | + * @param Domain $domain |
|
| 32 | + * @param JsonDataNodeValidator $validator |
|
| 33 | + */ |
|
| 34 | + public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
| 35 | + { |
|
| 36 | + $this->domain = $domain; |
|
| 37 | + parent::__construct($validator); |
|
| 38 | + $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @inheritDoc |
|
| 44 | + */ |
|
| 45 | + public function initialize() |
|
| 46 | + { |
|
| 47 | + $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
| 48 | + $this->addData('brandName', Domain::brandName()); |
|
| 49 | + $this->addData('coreVersion', $this->domain->version()); |
|
| 50 | + $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
| 51 | + $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
| 52 | + $this->addData('pluginPath', $this->domain->pluginPath()); |
|
| 53 | + $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
| 54 | + $this->setInitialized(true); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -15,30 +15,30 @@ |
||
| 15 | 15 | class GeneralSettings extends JsonDataNode |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - const NODE_NAME = 'generalSettings'; |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * JsonDataNodeHandler constructor. |
|
| 23 | - * |
|
| 24 | - * @param JsonDataNodeValidator $validator |
|
| 25 | - */ |
|
| 26 | - public function __construct(JsonDataNodeValidator $validator) |
|
| 27 | - { |
|
| 28 | - parent::__construct($validator); |
|
| 29 | - $this->setNodeName(GeneralSettings::NODE_NAME); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @inheritDoc |
|
| 35 | - */ |
|
| 36 | - public function initialize() |
|
| 37 | - { |
|
| 38 | - $this->addData('dateFormat', get_option('date_format')); |
|
| 39 | - $this->addData('timeFormat', get_option('time_format')); |
|
| 40 | - $this->addData('timezone', get_option('timezone_string')); |
|
| 41 | - $this->addData('__typename', 'GeneralSettings'); |
|
| 42 | - $this->setInitialized(true); |
|
| 43 | - } |
|
| 18 | + const NODE_NAME = 'generalSettings'; |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * JsonDataNodeHandler constructor. |
|
| 23 | + * |
|
| 24 | + * @param JsonDataNodeValidator $validator |
|
| 25 | + */ |
|
| 26 | + public function __construct(JsonDataNodeValidator $validator) |
|
| 27 | + { |
|
| 28 | + parent::__construct($validator); |
|
| 29 | + $this->setNodeName(GeneralSettings::NODE_NAME); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @inheritDoc |
|
| 35 | + */ |
|
| 36 | + public function initialize() |
|
| 37 | + { |
|
| 38 | + $this->addData('dateFormat', get_option('date_format')); |
|
| 39 | + $this->addData('timeFormat', get_option('time_format')); |
|
| 40 | + $this->addData('timezone', get_option('timezone_string')); |
|
| 41 | + $this->addData('__typename', 'GeneralSettings'); |
|
| 42 | + $this->setInitialized(true); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -17,41 +17,41 @@ |
||
| 17 | 17 | class SiteCurrency extends JsonDataNode |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - const NODE_NAME = 'siteCurrency'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var EE_Currency_Config $currency_config |
|
| 24 | - */ |
|
| 25 | - protected $currency_config; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * SiteCurrency constructor. |
|
| 30 | - * |
|
| 31 | - * @param EE_Currency_Config $currency_config |
|
| 32 | - * @param JsonDataNodeValidator $validator |
|
| 33 | - */ |
|
| 34 | - public function __construct(EE_Currency_Config $currency_config, JsonDataNodeValidator $validator) |
|
| 35 | - { |
|
| 36 | - parent::__construct($validator); |
|
| 37 | - $this->currency_config = $currency_config; |
|
| 38 | - $this->setNodeName(SiteCurrency::NODE_NAME); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @inheritDoc |
|
| 44 | - */ |
|
| 45 | - public function initialize() |
|
| 46 | - { |
|
| 47 | - $this->addData('code', $this->currency_config->code); |
|
| 48 | - $this->addData('singularLabel', $this->currency_config->name); |
|
| 49 | - $this->addData('pluralLabel', $this->currency_config->plural); |
|
| 50 | - $this->addData('sign', $this->currency_config->sign); |
|
| 51 | - $this->addData('signB4', $this->currency_config->sign_b4); |
|
| 52 | - $this->addData('decimalPlaces', $this->currency_config->dec_plc); |
|
| 53 | - $this->addData('decimalMark', $this->currency_config->dec_mrk); |
|
| 54 | - $this->addData('thousandsSeparator', $this->currency_config->thsnds); |
|
| 55 | - $this->setInitialized(true); |
|
| 56 | - } |
|
| 20 | + const NODE_NAME = 'siteCurrency'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var EE_Currency_Config $currency_config |
|
| 24 | + */ |
|
| 25 | + protected $currency_config; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * SiteCurrency constructor. |
|
| 30 | + * |
|
| 31 | + * @param EE_Currency_Config $currency_config |
|
| 32 | + * @param JsonDataNodeValidator $validator |
|
| 33 | + */ |
|
| 34 | + public function __construct(EE_Currency_Config $currency_config, JsonDataNodeValidator $validator) |
|
| 35 | + { |
|
| 36 | + parent::__construct($validator); |
|
| 37 | + $this->currency_config = $currency_config; |
|
| 38 | + $this->setNodeName(SiteCurrency::NODE_NAME); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @inheritDoc |
|
| 44 | + */ |
|
| 45 | + public function initialize() |
|
| 46 | + { |
|
| 47 | + $this->addData('code', $this->currency_config->code); |
|
| 48 | + $this->addData('singularLabel', $this->currency_config->name); |
|
| 49 | + $this->addData('pluralLabel', $this->currency_config->plural); |
|
| 50 | + $this->addData('sign', $this->currency_config->sign); |
|
| 51 | + $this->addData('signB4', $this->currency_config->sign_b4); |
|
| 52 | + $this->addData('decimalPlaces', $this->currency_config->dec_plc); |
|
| 53 | + $this->addData('decimalMark', $this->currency_config->dec_mrk); |
|
| 54 | + $this->addData('thousandsSeparator', $this->currency_config->thsnds); |
|
| 55 | + $this->setInitialized(true); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -17,32 +17,32 @@ |
||
| 17 | 17 | class Locale extends JsonDataNode |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - const NODE_NAME = 'locale'; |
|
| 20 | + const NODE_NAME = 'locale'; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * JsonDataNodeHandler constructor. |
|
| 25 | - * |
|
| 26 | - * @param JsonDataNodeValidator $validator |
|
| 27 | - */ |
|
| 28 | - public function __construct(JsonDataNodeValidator $validator) |
|
| 29 | - { |
|
| 30 | - parent::__construct($validator); |
|
| 31 | - $this->setNodeName(Locale::NODE_NAME); |
|
| 32 | - } |
|
| 23 | + /** |
|
| 24 | + * JsonDataNodeHandler constructor. |
|
| 25 | + * |
|
| 26 | + * @param JsonDataNodeValidator $validator |
|
| 27 | + */ |
|
| 28 | + public function __construct(JsonDataNodeValidator $validator) |
|
| 29 | + { |
|
| 30 | + parent::__construct($validator); |
|
| 31 | + $this->setNodeName(Locale::NODE_NAME); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @inheritDoc |
|
| 36 | - */ |
|
| 37 | - public function initialize() |
|
| 38 | - { |
|
| 39 | - $this->addData('user', get_user_locale()); |
|
| 40 | - $this->addData('site', get_locale()); |
|
| 41 | - $this->addData('siteTimezone', [ |
|
| 42 | - 'city' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 43 | - 'name' => get_option('timezone_string'), |
|
| 44 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 45 | - ]); |
|
| 46 | - $this->setInitialized(true); |
|
| 47 | - } |
|
| 34 | + /** |
|
| 35 | + * @inheritDoc |
|
| 36 | + */ |
|
| 37 | + public function initialize() |
|
| 38 | + { |
|
| 39 | + $this->addData('user', get_user_locale()); |
|
| 40 | + $this->addData('site', get_locale()); |
|
| 41 | + $this->addData('siteTimezone', [ |
|
| 42 | + 'city' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 43 | + 'name' => get_option('timezone_string'), |
|
| 44 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 45 | + ]); |
|
| 46 | + $this->setInitialized(true); |
|
| 47 | + } |
|
| 48 | 48 | } |