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