@@ -79,10 +79,10 @@ |
||
| 79 | 79 | $model_names = []; |
| 80 | 80 | if (is_array($this->_model_name_pointed_to)) { |
| 81 | 81 | foreach ($this->_model_name_pointed_to as $model_name) { |
| 82 | - $model_names[] = "EE_" . $model_name; |
|
| 82 | + $model_names[] = "EE_".$model_name; |
|
| 83 | 83 | } |
| 84 | 84 | } else { |
| 85 | - $model_names = ["EE_" . $this->_model_name_pointed_to]; |
|
| 85 | + $model_names = ["EE_".$this->_model_name_pointed_to]; |
|
| 86 | 86 | } |
| 87 | 87 | return $model_names; |
| 88 | 88 | } |
@@ -8,94 +8,94 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Usually the name of a single model. However, as in the case for custom post types, |
|
| 13 | - * it can actually be an array of models |
|
| 14 | - * |
|
| 15 | - * @var string[] |
|
| 16 | - */ |
|
| 17 | - protected $_model_name_pointed_to; |
|
| 11 | + /** |
|
| 12 | + * Usually the name of a single model. However, as in the case for custom post types, |
|
| 13 | + * it can actually be an array of models |
|
| 14 | + * |
|
| 15 | + * @var string[] |
|
| 16 | + */ |
|
| 17 | + protected $_model_name_pointed_to; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param string $table_column name of column for field |
|
| 22 | - * @param string $nicename should be internationalized with __('blah','event_espresso') |
|
| 23 | - * @param boolean $nullable |
|
| 24 | - * @param int|string $default_value data type should match field type |
|
| 25 | - * @param string|string[] $model_name eg 'Event','Answer','Term', etc. |
|
| 26 | - * Basically its the model class's name without the "EEM_" |
|
| 27 | - */ |
|
| 28 | - public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
| 29 | - { |
|
| 30 | - $this->_model_name_pointed_to = (array) $model_name; |
|
| 31 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 32 | - } |
|
| 20 | + /** |
|
| 21 | + * @param string $table_column name of column for field |
|
| 22 | + * @param string $nicename should be internationalized with __('blah','event_espresso') |
|
| 23 | + * @param boolean $nullable |
|
| 24 | + * @param int|string $default_value data type should match field type |
|
| 25 | + * @param string|string[] $model_name eg 'Event','Answer','Term', etc. |
|
| 26 | + * Basically its the model class's name without the "EEM_" |
|
| 27 | + */ |
|
| 28 | + public function __construct($table_column, $nicename, $nullable, $default_value, $model_name) |
|
| 29 | + { |
|
| 30 | + $this->_model_name_pointed_to = (array) $model_name; |
|
| 31 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns the name of the model(s) pointed to |
|
| 37 | - * |
|
| 38 | - * @return string[] string or array of strings |
|
| 39 | - * @deprecated since version 4.6.7 |
|
| 40 | - */ |
|
| 41 | - public function get_model_name_pointed_to(): array |
|
| 42 | - { |
|
| 43 | - EE_Error::doing_it_wrong( |
|
| 44 | - 'get_model_name_pointed_to', |
|
| 45 | - __( |
|
| 46 | - 'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', |
|
| 47 | - 'event_espresso' |
|
| 48 | - ), |
|
| 49 | - '4.6.7' |
|
| 50 | - ); |
|
| 51 | - return $this->_model_name_pointed_to; |
|
| 52 | - } |
|
| 35 | + /** |
|
| 36 | + * Returns the name of the model(s) pointed to |
|
| 37 | + * |
|
| 38 | + * @return string[] string or array of strings |
|
| 39 | + * @deprecated since version 4.6.7 |
|
| 40 | + */ |
|
| 41 | + public function get_model_name_pointed_to(): array |
|
| 42 | + { |
|
| 43 | + EE_Error::doing_it_wrong( |
|
| 44 | + 'get_model_name_pointed_to', |
|
| 45 | + __( |
|
| 46 | + 'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', |
|
| 47 | + 'event_espresso' |
|
| 48 | + ), |
|
| 49 | + '4.6.7' |
|
| 50 | + ); |
|
| 51 | + return $this->_model_name_pointed_to; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Gets the model names pointed to by this field, always as an array |
|
| 57 | - * (even if there's only one) |
|
| 58 | - * |
|
| 59 | - * @return string[] of model names pointed to by this field |
|
| 60 | - */ |
|
| 61 | - public function get_model_names_pointed_to(): array |
|
| 62 | - { |
|
| 63 | - return is_array($this->_model_name_pointed_to) |
|
| 64 | - ? $this->_model_name_pointed_to |
|
| 65 | - : [$this->_model_name_pointed_to]; |
|
| 66 | - } |
|
| 55 | + /** |
|
| 56 | + * Gets the model names pointed to by this field, always as an array |
|
| 57 | + * (even if there's only one) |
|
| 58 | + * |
|
| 59 | + * @return string[] of model names pointed to by this field |
|
| 60 | + */ |
|
| 61 | + public function get_model_names_pointed_to(): array |
|
| 62 | + { |
|
| 63 | + return is_array($this->_model_name_pointed_to) |
|
| 64 | + ? $this->_model_name_pointed_to |
|
| 65 | + : [$this->_model_name_pointed_to]; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Returns the model's classname (eg EE_Event instead of just Event) |
|
| 71 | - * |
|
| 72 | - * @return string[] |
|
| 73 | - */ |
|
| 74 | - public function get_model_class_names_pointed_to(): array |
|
| 75 | - { |
|
| 76 | - $model_names = []; |
|
| 77 | - if (is_array($this->_model_name_pointed_to)) { |
|
| 78 | - foreach ($this->_model_name_pointed_to as $model_name) { |
|
| 79 | - $model_names[] = "EE_" . $model_name; |
|
| 80 | - } |
|
| 81 | - } else { |
|
| 82 | - $model_names = ["EE_" . $this->_model_name_pointed_to]; |
|
| 83 | - } |
|
| 84 | - return $model_names; |
|
| 85 | - } |
|
| 69 | + /** |
|
| 70 | + * Returns the model's classname (eg EE_Event instead of just Event) |
|
| 71 | + * |
|
| 72 | + * @return string[] |
|
| 73 | + */ |
|
| 74 | + public function get_model_class_names_pointed_to(): array |
|
| 75 | + { |
|
| 76 | + $model_names = []; |
|
| 77 | + if (is_array($this->_model_name_pointed_to)) { |
|
| 78 | + foreach ($this->_model_name_pointed_to as $model_name) { |
|
| 79 | + $model_names[] = "EE_" . $model_name; |
|
| 80 | + } |
|
| 81 | + } else { |
|
| 82 | + $model_names = ["EE_" . $this->_model_name_pointed_to]; |
|
| 83 | + } |
|
| 84 | + return $model_names; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @param int|EE_Base_Class $model_obj |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function is_model_obj_of_type_pointed_to($model_obj): bool |
|
| 93 | - { |
|
| 94 | - foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) { |
|
| 95 | - if ($model_obj instanceof $model_obj_classname) { |
|
| 96 | - return true; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - return false; |
|
| 100 | - } |
|
| 88 | + /** |
|
| 89 | + * @param int|EE_Base_Class $model_obj |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + public function is_model_obj_of_type_pointed_to($model_obj): bool |
|
| 93 | + { |
|
| 94 | + foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) { |
|
| 95 | + if ($model_obj instanceof $model_obj_classname) { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | ) { |
| 206 | 206 | $class = trim($class, '\\'); |
| 207 | 207 | $registered = false; |
| 208 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
| 209 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
| 208 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[$class])) { |
|
| 209 | + EE_Dependency_Map::$_instance->_dependency_map[$class] = []; |
|
| 210 | 210 | } |
| 211 | 211 | // we need to make sure that any aliases used when registering a dependency |
| 212 | 212 | // get resolved to the correct class name |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
| 215 | 215 | if ( |
| 216 | 216 | $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
| 217 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 217 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[$class][$alias]) |
|
| 218 | 218 | ) { |
| 219 | - unset($dependencies[ $dependency ]); |
|
| 220 | - $dependencies[ $alias ] = $load_source; |
|
| 219 | + unset($dependencies[$dependency]); |
|
| 220 | + $dependencies[$alias] = $load_source; |
|
| 221 | 221 | $registered = true; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
| 228 | 228 | // Union is way faster than array_merge() but should be used with caution... |
| 229 | 229 | // especially with numerically indexed arrays |
| 230 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 230 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[$class]; |
|
| 231 | 231 | // now we need to ensure that the resulting dependencies |
| 232 | 232 | // array only has the entries that are required for the class |
| 233 | 233 | // so first count how many dependencies were originally registered for the class |
| 234 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 234 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[$class]); |
|
| 235 | 235 | // if that count is non-zero (meaning dependencies were already registered) |
| 236 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 236 | + EE_Dependency_Map::$_instance->_dependency_map[$class] = $dependency_count |
|
| 237 | 237 | // then truncate the final array to match that count |
| 238 | 238 | ? array_slice($dependencies, 0, $dependency_count) |
| 239 | 239 | // otherwise just take the incoming array because nothing previously existed |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public function registerClassLoader($class_name, $loader = 'load_core') |
| 264 | 264 | { |
| 265 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 265 | + if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 266 | 266 | throw new DomainException( |
| 267 | 267 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
| 268 | 268 | ); |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | } |
| 288 | 288 | $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
| 289 | - if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 290 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 289 | + if ( ! isset(EE_Dependency_Map::$_instance->_class_loaders[$class_name])) { |
|
| 290 | + EE_Dependency_Map::$_instance->_class_loaders[$class_name] = $loader; |
|
| 291 | 291 | return true; |
| 292 | 292 | } |
| 293 | 293 | return false; |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | if (strpos($class_name, 'EEM_') === 0) { |
| 316 | 316 | $class_name = 'LEGACY_MODELS'; |
| 317 | 317 | } |
| 318 | - return isset($this->_dependency_map[ $class_name ]); |
|
| 318 | + return isset($this->_dependency_map[$class_name]); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $class_name = 'LEGACY_MODELS'; |
| 334 | 334 | } |
| 335 | 335 | $dependency = $this->getFqnForAlias($dependency, $class_name); |
| 336 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 336 | + return isset($this->_dependency_map[$class_name][$dependency]); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | $dependency = $this->getFqnForAlias($dependency); |
| 354 | 354 | return $this->has_dependency_for_class($class_name, $dependency) |
| 355 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 355 | + ? $this->_dependency_map[$class_name][$dependency] |
|
| 356 | 356 | : EE_Dependency_Map::not_registered; |
| 357 | 357 | } |
| 358 | 358 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | return 'load_core'; |
| 377 | 377 | } |
| 378 | 378 | $class_name = $this->getFqnForAlias($class_name); |
| 379 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 379 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | { |
| 817 | 817 | $this->_class_loaders = [ |
| 818 | 818 | // load_core |
| 819 | - 'EE_Dependency_Map' => function () { |
|
| 819 | + 'EE_Dependency_Map' => function() { |
|
| 820 | 820 | return $this; |
| 821 | 821 | }, |
| 822 | 822 | 'EE_Capabilities' => 'load_core', |
@@ -824,13 +824,13 @@ discard block |
||
| 824 | 824 | 'EE_Front_Controller' => 'load_core', |
| 825 | 825 | 'EE_Module_Request_Router' => 'load_core', |
| 826 | 826 | 'EE_Registry' => 'load_core', |
| 827 | - 'EE_Request' => function () { |
|
| 827 | + 'EE_Request' => function() { |
|
| 828 | 828 | return $this->legacy_request; |
| 829 | 829 | }, |
| 830 | - 'EventEspresso\core\services\request\Request' => function () { |
|
| 830 | + 'EventEspresso\core\services\request\Request' => function() { |
|
| 831 | 831 | return $this->request; |
| 832 | 832 | }, |
| 833 | - 'EventEspresso\core\services\request\Response' => function () { |
|
| 833 | + 'EventEspresso\core\services\request\Response' => function() { |
|
| 834 | 834 | return $this->response; |
| 835 | 835 | }, |
| 836 | 836 | 'EE_Base' => 'load_core', |
@@ -867,7 +867,7 @@ discard block |
||
| 867 | 867 | 'EE_DMS_Core_4_10_0' => 'load_dms', |
| 868 | 868 | 'EE_DMS_Core_4_11_0' => 'load_dms', |
| 869 | 869 | 'EE_DMS_Core_4_12_0' => 'load_dms', |
| 870 | - 'EE_Messages_Generator' => static function () { |
|
| 870 | + 'EE_Messages_Generator' => static function() { |
|
| 871 | 871 | return EE_Registry::instance()->load_lib( |
| 872 | 872 | 'Messages_Generator', |
| 873 | 873 | [], |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | false |
| 876 | 876 | ); |
| 877 | 877 | }, |
| 878 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 878 | + 'EE_Messages_Template_Defaults' => static function($arguments = []) { |
|
| 879 | 879 | return EE_Registry::instance()->load_lib( |
| 880 | 880 | 'Messages_Template_Defaults', |
| 881 | 881 | $arguments, |
@@ -884,55 +884,55 @@ discard block |
||
| 884 | 884 | ); |
| 885 | 885 | }, |
| 886 | 886 | // load_helper |
| 887 | - 'EEH_Parse_Shortcodes' => static function () { |
|
| 887 | + 'EEH_Parse_Shortcodes' => static function() { |
|
| 888 | 888 | if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
| 889 | 889 | return new EEH_Parse_Shortcodes(); |
| 890 | 890 | } |
| 891 | 891 | return null; |
| 892 | 892 | }, |
| 893 | - 'EE_Template_Config' => static function () { |
|
| 893 | + 'EE_Template_Config' => static function() { |
|
| 894 | 894 | return EE_Config::instance()->template_settings; |
| 895 | 895 | }, |
| 896 | - 'EE_Currency_Config' => static function () { |
|
| 896 | + 'EE_Currency_Config' => static function() { |
|
| 897 | 897 | return EE_Config::instance()->currency; |
| 898 | 898 | }, |
| 899 | - 'EE_Registration_Config' => static function () { |
|
| 899 | + 'EE_Registration_Config' => static function() { |
|
| 900 | 900 | return EE_Config::instance()->registration; |
| 901 | 901 | }, |
| 902 | - 'EE_Core_Config' => static function () { |
|
| 902 | + 'EE_Core_Config' => static function() { |
|
| 903 | 903 | return EE_Config::instance()->core; |
| 904 | 904 | }, |
| 905 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 905 | + 'EventEspresso\core\services\loaders\Loader' => static function() { |
|
| 906 | 906 | return LoaderFactory::getLoader(); |
| 907 | 907 | }, |
| 908 | - 'EE_Network_Config' => static function () { |
|
| 908 | + 'EE_Network_Config' => static function() { |
|
| 909 | 909 | return EE_Network_Config::instance(); |
| 910 | 910 | }, |
| 911 | - 'EE_Config' => static function () { |
|
| 911 | + 'EE_Config' => static function() { |
|
| 912 | 912 | return EE_Config::instance(); |
| 913 | 913 | }, |
| 914 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
| 914 | + 'EventEspresso\core\domain\Domain' => static function() { |
|
| 915 | 915 | return DomainFactory::getEventEspressoCoreDomain(); |
| 916 | 916 | }, |
| 917 | - 'EE_Admin_Config' => static function () { |
|
| 917 | + 'EE_Admin_Config' => static function() { |
|
| 918 | 918 | return EE_Config::instance()->admin; |
| 919 | 919 | }, |
| 920 | - 'EE_Organization_Config' => static function () { |
|
| 920 | + 'EE_Organization_Config' => static function() { |
|
| 921 | 921 | return EE_Config::instance()->organization; |
| 922 | 922 | }, |
| 923 | - 'EE_Network_Core_Config' => static function () { |
|
| 923 | + 'EE_Network_Core_Config' => static function() { |
|
| 924 | 924 | return EE_Network_Config::instance()->core; |
| 925 | 925 | }, |
| 926 | - 'EE_Environment_Config' => static function () { |
|
| 926 | + 'EE_Environment_Config' => static function() { |
|
| 927 | 927 | return EE_Config::instance()->environment; |
| 928 | 928 | }, |
| 929 | - 'EED_Core_Rest_Api' => static function () { |
|
| 929 | + 'EED_Core_Rest_Api' => static function() { |
|
| 930 | 930 | return EED_Core_Rest_Api::instance(); |
| 931 | 931 | }, |
| 932 | - 'WP_REST_Server' => static function () { |
|
| 932 | + 'WP_REST_Server' => static function() { |
|
| 933 | 933 | return rest_get_server(); |
| 934 | 934 | }, |
| 935 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
| 935 | + 'EventEspresso\core\Psr4Autoloader' => static function() { |
|
| 936 | 936 | return EE_Psr4AutoloaderInit::psr4_loader(); |
| 937 | 937 | }, |
| 938 | 938 | ]; |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | } |
| 998 | 998 | $this->class_cache->addAlias($fqn, $alias); |
| 999 | 999 | } |
| 1000 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1000 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1001 | 1001 | $this->class_cache->addAlias( |
| 1002 | 1002 | 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
| 1003 | 1003 | 'EventEspresso\core\services\notices\NoticeConverterInterface' |
@@ -22,1061 +22,1061 @@ |
||
| 22 | 22 | class EE_Dependency_Map |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * This means that the requested class dependency is not present in the dependency map |
|
| 27 | - */ |
|
| 28 | - const not_registered = 0; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 32 | - */ |
|
| 33 | - const load_new_object = 1; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 37 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 38 | - */ |
|
| 39 | - const load_from_cache = 2; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * When registering a dependency, |
|
| 43 | - * this indicates to keep any existing dependencies that already exist, |
|
| 44 | - * and simply discard any new dependencies declared in the incoming data |
|
| 45 | - */ |
|
| 46 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * When registering a dependency, |
|
| 50 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 51 | - */ |
|
| 52 | - const OVERWRITE_DEPENDENCIES = 1; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @type EE_Dependency_Map $_instance |
|
| 56 | - */ |
|
| 57 | - protected static $_instance; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var ClassInterfaceCache $class_cache |
|
| 61 | - */ |
|
| 62 | - private $class_cache; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @type RequestInterface $request |
|
| 66 | - */ |
|
| 67 | - protected $request; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @type LegacyRequestInterface $legacy_request |
|
| 71 | - */ |
|
| 72 | - protected $legacy_request; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @type ResponseInterface $response |
|
| 76 | - */ |
|
| 77 | - protected $response; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @type LoaderInterface $loader |
|
| 81 | - */ |
|
| 82 | - protected $loader; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @type array $_dependency_map |
|
| 86 | - */ |
|
| 87 | - protected $_dependency_map = []; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @type array $_class_loaders |
|
| 91 | - */ |
|
| 92 | - protected $_class_loaders = []; |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * EE_Dependency_Map constructor. |
|
| 97 | - * |
|
| 98 | - * @param ClassInterfaceCache $class_cache |
|
| 99 | - */ |
|
| 100 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
| 101 | - { |
|
| 102 | - $this->class_cache = $class_cache; |
|
| 103 | - do_action('EE_Dependency_Map____construct', $this); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @return void |
|
| 109 | - * @throws InvalidAliasException |
|
| 110 | - */ |
|
| 111 | - public function initialize() |
|
| 112 | - { |
|
| 113 | - $this->_register_core_dependencies(); |
|
| 114 | - $this->_register_core_class_loaders(); |
|
| 115 | - $this->_register_core_aliases(); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @singleton method used to instantiate class object |
|
| 121 | - * @param ClassInterfaceCache|null $class_cache |
|
| 122 | - * @return EE_Dependency_Map |
|
| 123 | - */ |
|
| 124 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 125 | - { |
|
| 126 | - // check if class object is instantiated, and instantiated properly |
|
| 127 | - if ( |
|
| 128 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
| 129 | - && $class_cache instanceof ClassInterfaceCache |
|
| 130 | - ) { |
|
| 131 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
| 132 | - } |
|
| 133 | - return EE_Dependency_Map::$_instance; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param RequestInterface $request |
|
| 139 | - */ |
|
| 140 | - public function setRequest(RequestInterface $request) |
|
| 141 | - { |
|
| 142 | - $this->request = $request; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @param LegacyRequestInterface $legacy_request |
|
| 148 | - */ |
|
| 149 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 150 | - { |
|
| 151 | - $this->legacy_request = $legacy_request; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param ResponseInterface $response |
|
| 157 | - */ |
|
| 158 | - public function setResponse(ResponseInterface $response) |
|
| 159 | - { |
|
| 160 | - $this->response = $response; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param LoaderInterface $loader |
|
| 166 | - */ |
|
| 167 | - public function setLoader(LoaderInterface $loader) |
|
| 168 | - { |
|
| 169 | - $this->loader = $loader; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * @param string $class |
|
| 175 | - * @param array $dependencies |
|
| 176 | - * @param int $overwrite |
|
| 177 | - * @return bool |
|
| 178 | - */ |
|
| 179 | - public static function register_dependencies( |
|
| 180 | - $class, |
|
| 181 | - array $dependencies, |
|
| 182 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 183 | - ) { |
|
| 184 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 190 | - * to the class specified by the first parameter. |
|
| 191 | - * IMPORTANT !!! |
|
| 192 | - * The order of elements in the incoming $dependencies array MUST match |
|
| 193 | - * the order of the constructor parameters for the class in question. |
|
| 194 | - * This is especially important when overriding any existing dependencies that are registered. |
|
| 195 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 196 | - * |
|
| 197 | - * @param string $class |
|
| 198 | - * @param array $dependencies |
|
| 199 | - * @param int $overwrite |
|
| 200 | - * @return bool |
|
| 201 | - */ |
|
| 202 | - public function registerDependencies( |
|
| 203 | - $class, |
|
| 204 | - array $dependencies, |
|
| 205 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 206 | - ) { |
|
| 207 | - $class = trim($class, '\\'); |
|
| 208 | - $registered = false; |
|
| 209 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
| 210 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
| 211 | - } |
|
| 212 | - // we need to make sure that any aliases used when registering a dependency |
|
| 213 | - // get resolved to the correct class name |
|
| 214 | - foreach ($dependencies as $dependency => $load_source) { |
|
| 215 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
| 216 | - if ( |
|
| 217 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 218 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 219 | - ) { |
|
| 220 | - unset($dependencies[ $dependency ]); |
|
| 221 | - $dependencies[ $alias ] = $load_source; |
|
| 222 | - $registered = true; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - // now add our two lists of dependencies together. |
|
| 226 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 227 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 228 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 229 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 230 | - // especially with numerically indexed arrays |
|
| 231 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 232 | - // now we need to ensure that the resulting dependencies |
|
| 233 | - // array only has the entries that are required for the class |
|
| 234 | - // so first count how many dependencies were originally registered for the class |
|
| 235 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 236 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 237 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 238 | - // then truncate the final array to match that count |
|
| 239 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 240 | - // otherwise just take the incoming array because nothing previously existed |
|
| 241 | - : $dependencies; |
|
| 242 | - return $registered; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * @param string $class_name |
|
| 248 | - * @param string $loader |
|
| 249 | - * @return bool |
|
| 250 | - * @throws DomainException |
|
| 251 | - */ |
|
| 252 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 253 | - { |
|
| 254 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * @param string $class_name |
|
| 260 | - * @param string $loader |
|
| 261 | - * @return bool |
|
| 262 | - * @throws DomainException |
|
| 263 | - */ |
|
| 264 | - public function registerClassLoader($class_name, $loader = 'load_core') |
|
| 265 | - { |
|
| 266 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 267 | - throw new DomainException( |
|
| 268 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 269 | - ); |
|
| 270 | - } |
|
| 271 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 272 | - if ( |
|
| 273 | - ! is_callable($loader) |
|
| 274 | - && ( |
|
| 275 | - strpos($loader, 'load_') !== 0 |
|
| 276 | - || ! method_exists('EE_Registry', $loader) |
|
| 277 | - ) |
|
| 278 | - ) { |
|
| 279 | - throw new DomainException( |
|
| 280 | - sprintf( |
|
| 281 | - esc_html__( |
|
| 282 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 283 | - 'event_espresso' |
|
| 284 | - ), |
|
| 285 | - $loader |
|
| 286 | - ) |
|
| 287 | - ); |
|
| 288 | - } |
|
| 289 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 290 | - if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 291 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 292 | - return true; |
|
| 293 | - } |
|
| 294 | - return false; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * @return array |
|
| 300 | - */ |
|
| 301 | - public function dependency_map() |
|
| 302 | - { |
|
| 303 | - return $this->_dependency_map; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 309 | - * |
|
| 310 | - * @param string $class_name |
|
| 311 | - * @return boolean |
|
| 312 | - */ |
|
| 313 | - public function has($class_name = '') |
|
| 314 | - { |
|
| 315 | - // all legacy models have the same dependencies |
|
| 316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 317 | - $class_name = 'LEGACY_MODELS'; |
|
| 318 | - } |
|
| 319 | - return isset($this->_dependency_map[ $class_name ]); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 325 | - * |
|
| 326 | - * @param string $class_name |
|
| 327 | - * @param string $dependency |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 331 | - { |
|
| 332 | - // all legacy models have the same dependencies |
|
| 333 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 334 | - $class_name = 'LEGACY_MODELS'; |
|
| 335 | - } |
|
| 336 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 337 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 343 | - * |
|
| 344 | - * @param string $class_name |
|
| 345 | - * @param string $dependency |
|
| 346 | - * @return int |
|
| 347 | - */ |
|
| 348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 349 | - { |
|
| 350 | - // all legacy models have the same dependencies |
|
| 351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 352 | - $class_name = 'LEGACY_MODELS'; |
|
| 353 | - } |
|
| 354 | - $dependency = $this->getFqnForAlias($dependency); |
|
| 355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 356 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 357 | - : EE_Dependency_Map::not_registered; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * @param string $class_name |
|
| 363 | - * @return string | Closure |
|
| 364 | - */ |
|
| 365 | - public function class_loader($class_name) |
|
| 366 | - { |
|
| 367 | - // all legacy models use load_model() |
|
| 368 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 369 | - return 'load_model'; |
|
| 370 | - } |
|
| 371 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 372 | - // perform strpos() first to avoid loading regex every time we load a class |
|
| 373 | - if ( |
|
| 374 | - strpos($class_name, 'EE_CPT_') === 0 |
|
| 375 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 376 | - ) { |
|
| 377 | - return 'load_core'; |
|
| 378 | - } |
|
| 379 | - $class_name = $this->getFqnForAlias($class_name); |
|
| 380 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * @return array |
|
| 386 | - */ |
|
| 387 | - public function class_loaders() |
|
| 388 | - { |
|
| 389 | - return $this->_class_loaders; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * adds an alias for a classname |
|
| 395 | - * |
|
| 396 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 397 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 398 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 399 | - * @throws InvalidAliasException |
|
| 400 | - */ |
|
| 401 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
| 402 | - { |
|
| 403 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
| 409 | - * WHY? |
|
| 410 | - * Because if a class is type hinting for a concretion, |
|
| 411 | - * then why would we need to find another class to supply it? |
|
| 412 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 413 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 414 | - * Don't go looking for some substitute. |
|
| 415 | - * Whereas if a class is type hinting for an interface... |
|
| 416 | - * then we need to find an actual class to use. |
|
| 417 | - * So the interface IS the alias for some other FQN, |
|
| 418 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 419 | - * represents some other class. |
|
| 420 | - * |
|
| 421 | - * @param string $fqn |
|
| 422 | - * @param string $for_class |
|
| 423 | - * @return bool |
|
| 424 | - */ |
|
| 425 | - public function isAlias($fqn = '', $for_class = '') |
|
| 426 | - { |
|
| 427 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 433 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 434 | - * for example: |
|
| 435 | - * if the following two entries were added to the _aliases array: |
|
| 436 | - * array( |
|
| 437 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 438 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 439 | - * ) |
|
| 440 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 441 | - * to load an instance of 'some\namespace\classname' |
|
| 442 | - * |
|
| 443 | - * @param string $alias |
|
| 444 | - * @param string $for_class |
|
| 445 | - * @return string |
|
| 446 | - */ |
|
| 447 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
| 448 | - { |
|
| 449 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 455 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 456 | - * This is done by using the following class constants: |
|
| 457 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 458 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 459 | - */ |
|
| 460 | - protected function _register_core_dependencies() |
|
| 461 | - { |
|
| 462 | - $this->_dependency_map = [ |
|
| 463 | - 'EE_Request_Handler' => [ |
|
| 464 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 465 | - ], |
|
| 466 | - 'EE_System' => [ |
|
| 467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 468 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 470 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 471 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
| 472 | - ], |
|
| 473 | - 'EE_Admin' => [ |
|
| 474 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 475 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 476 | - ], |
|
| 477 | - 'EE_Cart' => [ |
|
| 478 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 479 | - ], |
|
| 480 | - 'EE_Messenger_Collection_Loader' => [ |
|
| 481 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 482 | - ], |
|
| 483 | - 'EE_Message_Type_Collection_Loader' => [ |
|
| 484 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 485 | - ], |
|
| 486 | - 'EE_Message_Resource_Manager' => [ |
|
| 487 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 488 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 489 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 490 | - ], |
|
| 491 | - 'EE_Message_Factory' => [ |
|
| 492 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 493 | - ], |
|
| 494 | - 'EE_messages' => [ |
|
| 495 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 496 | - ], |
|
| 497 | - 'EE_Messages_Generator' => [ |
|
| 498 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 499 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 500 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 501 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 502 | - ], |
|
| 503 | - 'EE_Messages_Processor' => [ |
|
| 504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 505 | - ], |
|
| 506 | - 'EE_Messages_Queue' => [ |
|
| 507 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 508 | - ], |
|
| 509 | - 'EE_Messages_Template_Defaults' => [ |
|
| 510 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 511 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 512 | - ], |
|
| 513 | - 'EE_Message_To_Generate_From_Request' => [ |
|
| 514 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 515 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 516 | - ], |
|
| 517 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 518 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 519 | - ], |
|
| 520 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 521 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 522 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - ], |
|
| 524 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 525 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 526 | - ], |
|
| 527 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 528 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 529 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 530 | - ], |
|
| 531 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 533 | - ], |
|
| 534 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 535 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 536 | - ], |
|
| 537 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 538 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 539 | - ], |
|
| 540 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 541 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 542 | - ], |
|
| 543 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 544 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 545 | - ], |
|
| 546 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 547 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 548 | - ], |
|
| 549 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 550 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 551 | - ], |
|
| 552 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 553 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 554 | - ], |
|
| 555 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 556 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 557 | - ], |
|
| 558 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 559 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 560 | - ], |
|
| 561 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 562 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 563 | - ], |
|
| 564 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 565 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 566 | - ], |
|
| 567 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 568 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 569 | - ], |
|
| 570 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
| 571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 572 | - ], |
|
| 573 | - 'EE_Data_Migration_Class_Base' => [ |
|
| 574 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 575 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 576 | - ], |
|
| 577 | - 'EE_DMS_Core_4_1_0' => [ |
|
| 578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 579 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 580 | - ], |
|
| 581 | - 'EE_DMS_Core_4_2_0' => [ |
|
| 582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 584 | - ], |
|
| 585 | - 'EE_DMS_Core_4_3_0' => [ |
|
| 586 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 587 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 588 | - ], |
|
| 589 | - 'EE_DMS_Core_4_4_0' => [ |
|
| 590 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 591 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 592 | - ], |
|
| 593 | - 'EE_DMS_Core_4_5_0' => [ |
|
| 594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 596 | - ], |
|
| 597 | - 'EE_DMS_Core_4_6_0' => [ |
|
| 598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | - ], |
|
| 601 | - 'EE_DMS_Core_4_7_0' => [ |
|
| 602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 604 | - ], |
|
| 605 | - 'EE_DMS_Core_4_8_0' => [ |
|
| 606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 608 | - ], |
|
| 609 | - 'EE_DMS_Core_4_9_0' => [ |
|
| 610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | - ], |
|
| 613 | - 'EE_DMS_Core_4_10_0' => [ |
|
| 614 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 616 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 617 | - ], |
|
| 618 | - 'EE_DMS_Core_4_11_0' => [ |
|
| 619 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
| 620 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 621 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 622 | - ], |
|
| 623 | - 'EE_DMS_Core_4_12_0' => [ |
|
| 624 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
| 625 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 626 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 627 | - ], |
|
| 628 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
| 629 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 630 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
| 631 | - ], |
|
| 632 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 633 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 634 | - ], |
|
| 635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 636 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 637 | - ], |
|
| 638 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 639 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 640 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 641 | - ], |
|
| 642 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 643 | - null, |
|
| 644 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 645 | - ], |
|
| 646 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 647 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 648 | - ], |
|
| 649 | - 'LEGACY_MODELS' => [ |
|
| 650 | - null, |
|
| 651 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 652 | - ], |
|
| 653 | - 'EE_Module_Request_Router' => [ |
|
| 654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 655 | - ], |
|
| 656 | - 'EE_Registration_Processor' => [ |
|
| 657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 658 | - ], |
|
| 659 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 660 | - null, |
|
| 661 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 662 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 663 | - ], |
|
| 664 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 665 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 666 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 667 | - ], |
|
| 668 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
| 669 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 670 | - ], |
|
| 671 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 672 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 673 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 674 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 675 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 676 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 677 | - ], |
|
| 678 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 679 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 680 | - ], |
|
| 681 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 682 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 683 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 684 | - ], |
|
| 685 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 686 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 687 | - ], |
|
| 688 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 689 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 690 | - ], |
|
| 691 | - 'EE_CPT_Strategy' => [ |
|
| 692 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 693 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 694 | - ], |
|
| 695 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 696 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 697 | - ], |
|
| 698 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 699 | - null, |
|
| 700 | - null, |
|
| 701 | - null, |
|
| 702 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 703 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 704 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 705 | - ], |
|
| 706 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 707 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 708 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 709 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 710 | - ], |
|
| 711 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 712 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 713 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 714 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 715 | - ], |
|
| 716 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 717 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 718 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 719 | - ], |
|
| 720 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 721 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 722 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 723 | - ], |
|
| 724 | - 'EE_URL_Validation_Strategy' => [ |
|
| 725 | - null, |
|
| 726 | - null, |
|
| 727 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
| 728 | - ], |
|
| 729 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 730 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 731 | - ], |
|
| 732 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 733 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 734 | - ], |
|
| 735 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 736 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 737 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 738 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 739 | - null, |
|
| 740 | - ], |
|
| 741 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 742 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 743 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 744 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 745 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 746 | - ], |
|
| 747 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 748 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 749 | - ], |
|
| 750 | - 'EventEspresso\core\services\routing\Router' => [ |
|
| 751 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 752 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 753 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
| 754 | - ], |
|
| 755 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
| 756 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 757 | - ], |
|
| 758 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
| 759 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 760 | - ], |
|
| 761 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
| 762 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
| 763 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 764 | - ], |
|
| 765 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
| 766 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 767 | - ], |
|
| 768 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
| 769 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
| 770 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
| 771 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
| 772 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
| 773 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
| 774 | - ], |
|
| 775 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
| 776 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 777 | - ], |
|
| 778 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
| 779 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
| 780 | - ], |
|
| 781 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
| 782 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
| 783 | - ], |
|
| 784 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
| 785 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 786 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 787 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 788 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 789 | - ], |
|
| 790 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
| 791 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 792 | - ], |
|
| 793 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
| 794 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
| 795 | - ], |
|
| 796 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
| 797 | - 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
| 798 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
| 799 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
| 800 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
| 801 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
| 802 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
| 803 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
| 804 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
| 805 | - ], |
|
| 806 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
| 807 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 808 | - ], |
|
| 809 | - ]; |
|
| 810 | - } |
|
| 811 | - |
|
| 812 | - |
|
| 813 | - /** |
|
| 814 | - * Registers how core classes are loaded. |
|
| 815 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 816 | - * 'EE_Request_Handler' => 'load_core' |
|
| 817 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 818 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 819 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 820 | - * 'Some_Class' => function () { |
|
| 821 | - * return new Some_Class(); |
|
| 822 | - * }, |
|
| 823 | - * This is required for instantiating dependencies |
|
| 824 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 825 | - * 'Required_Interface' => function () { |
|
| 826 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 827 | - * }, |
|
| 828 | - */ |
|
| 829 | - protected function _register_core_class_loaders() |
|
| 830 | - { |
|
| 831 | - $this->_class_loaders = [ |
|
| 832 | - // load_core |
|
| 833 | - 'EE_Dependency_Map' => function () { |
|
| 834 | - return $this; |
|
| 835 | - }, |
|
| 836 | - 'EE_Capabilities' => 'load_core', |
|
| 837 | - 'EE_Encryption' => 'load_core', |
|
| 838 | - 'EE_Front_Controller' => 'load_core', |
|
| 839 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 840 | - 'EE_Registry' => 'load_core', |
|
| 841 | - 'EE_Request' => function () { |
|
| 842 | - return $this->legacy_request; |
|
| 843 | - }, |
|
| 844 | - 'EventEspresso\core\services\request\Request' => function () { |
|
| 845 | - return $this->request; |
|
| 846 | - }, |
|
| 847 | - 'EventEspresso\core\services\request\Response' => function () { |
|
| 848 | - return $this->response; |
|
| 849 | - }, |
|
| 850 | - 'EE_Base' => 'load_core', |
|
| 851 | - 'EE_Request_Handler' => 'load_core', |
|
| 852 | - 'EE_Session' => 'load_core', |
|
| 853 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 854 | - 'EE_System' => 'load_core', |
|
| 855 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 856 | - 'EE_Register_CPTs' => 'load_core', |
|
| 857 | - 'EE_Admin' => 'load_core', |
|
| 858 | - 'EE_CPT_Strategy' => 'load_core', |
|
| 859 | - // load_class |
|
| 860 | - 'EE_Registration_Processor' => 'load_class', |
|
| 861 | - // load_lib |
|
| 862 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 863 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 864 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 865 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 866 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 867 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 868 | - 'EE_Message_Repository' => 'load_lib', |
|
| 869 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 870 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 871 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 872 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 873 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 874 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 875 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 876 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 877 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 878 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 879 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 880 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 881 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 882 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
| 883 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
| 884 | - 'EE_Messages_Generator' => static function () { |
|
| 885 | - return EE_Registry::instance()->load_lib( |
|
| 886 | - 'Messages_Generator', |
|
| 887 | - [], |
|
| 888 | - false, |
|
| 889 | - false |
|
| 890 | - ); |
|
| 891 | - }, |
|
| 892 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 893 | - return EE_Registry::instance()->load_lib( |
|
| 894 | - 'Messages_Template_Defaults', |
|
| 895 | - $arguments, |
|
| 896 | - false, |
|
| 897 | - false |
|
| 898 | - ); |
|
| 899 | - }, |
|
| 900 | - // load_helper |
|
| 901 | - 'EEH_Parse_Shortcodes' => static function () { |
|
| 902 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 903 | - return new EEH_Parse_Shortcodes(); |
|
| 904 | - } |
|
| 905 | - return null; |
|
| 906 | - }, |
|
| 907 | - 'EE_Template_Config' => static function () { |
|
| 908 | - return EE_Config::instance()->template_settings; |
|
| 909 | - }, |
|
| 910 | - 'EE_Currency_Config' => static function () { |
|
| 911 | - return EE_Config::instance()->currency; |
|
| 912 | - }, |
|
| 913 | - 'EE_Registration_Config' => static function () { |
|
| 914 | - return EE_Config::instance()->registration; |
|
| 915 | - }, |
|
| 916 | - 'EE_Core_Config' => static function () { |
|
| 917 | - return EE_Config::instance()->core; |
|
| 918 | - }, |
|
| 919 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 920 | - return LoaderFactory::getLoader(); |
|
| 921 | - }, |
|
| 922 | - 'EE_Network_Config' => static function () { |
|
| 923 | - return EE_Network_Config::instance(); |
|
| 924 | - }, |
|
| 925 | - 'EE_Config' => static function () { |
|
| 926 | - return EE_Config::instance(); |
|
| 927 | - }, |
|
| 928 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
| 929 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
| 930 | - }, |
|
| 931 | - 'EE_Admin_Config' => static function () { |
|
| 932 | - return EE_Config::instance()->admin; |
|
| 933 | - }, |
|
| 934 | - 'EE_Organization_Config' => static function () { |
|
| 935 | - return EE_Config::instance()->organization; |
|
| 936 | - }, |
|
| 937 | - 'EE_Network_Core_Config' => static function () { |
|
| 938 | - return EE_Network_Config::instance()->core; |
|
| 939 | - }, |
|
| 940 | - 'EE_Environment_Config' => static function () { |
|
| 941 | - return EE_Config::instance()->environment; |
|
| 942 | - }, |
|
| 943 | - 'EED_Core_Rest_Api' => static function () { |
|
| 944 | - return EED_Core_Rest_Api::instance(); |
|
| 945 | - }, |
|
| 946 | - 'WP_REST_Server' => static function () { |
|
| 947 | - return rest_get_server(); |
|
| 948 | - }, |
|
| 949 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
| 950 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
| 951 | - }, |
|
| 952 | - ]; |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - |
|
| 956 | - /** |
|
| 957 | - * can be used for supplying alternate names for classes, |
|
| 958 | - * or for connecting interface names to instantiable classes |
|
| 959 | - * |
|
| 960 | - * @throws InvalidAliasException |
|
| 961 | - */ |
|
| 962 | - protected function _register_core_aliases() |
|
| 963 | - { |
|
| 964 | - $aliases = [ |
|
| 965 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 966 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 967 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 968 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 969 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 970 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 971 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 972 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 973 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 974 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 975 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 976 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 977 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 978 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 979 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 980 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 981 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 982 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 983 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 984 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 985 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 986 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 987 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 988 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 989 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 990 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 991 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 992 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 993 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 994 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 995 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 996 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 997 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 998 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 999 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1000 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1001 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1002 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1003 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
| 1004 | - ]; |
|
| 1005 | - foreach ($aliases as $alias => $fqn) { |
|
| 1006 | - if (is_array($fqn)) { |
|
| 1007 | - foreach ($fqn as $class => $for_class) { |
|
| 1008 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1009 | - } |
|
| 1010 | - continue; |
|
| 1011 | - } |
|
| 1012 | - $this->class_cache->addAlias($fqn, $alias); |
|
| 1013 | - } |
|
| 1014 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1015 | - $this->class_cache->addAlias( |
|
| 1016 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1017 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1018 | - ); |
|
| 1019 | - } |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - |
|
| 1023 | - /** |
|
| 1024 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1025 | - * request Primarily used by unit tests. |
|
| 1026 | - */ |
|
| 1027 | - public function reset() |
|
| 1028 | - { |
|
| 1029 | - $this->_register_core_class_loaders(); |
|
| 1030 | - $this->_register_core_dependencies(); |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1036 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1037 | - * WHY? |
|
| 1038 | - * Because if a class is type hinting for a concretion, |
|
| 1039 | - * then why would we need to find another class to supply it? |
|
| 1040 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1041 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1042 | - * Don't go looking for some substitute. |
|
| 1043 | - * Whereas if a class is type hinting for an interface... |
|
| 1044 | - * then we need to find an actual class to use. |
|
| 1045 | - * So the interface IS the alias for some other FQN, |
|
| 1046 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1047 | - * represents some other class. |
|
| 1048 | - * |
|
| 1049 | - * @param string $fqn |
|
| 1050 | - * @param string $for_class |
|
| 1051 | - * @return bool |
|
| 1052 | - * @deprecated 4.9.62.p |
|
| 1053 | - */ |
|
| 1054 | - public function has_alias($fqn = '', $for_class = '') |
|
| 1055 | - { |
|
| 1056 | - return $this->isAlias($fqn, $for_class); |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1062 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1063 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1064 | - * for example: |
|
| 1065 | - * if the following two entries were added to the _aliases array: |
|
| 1066 | - * array( |
|
| 1067 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 1068 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1069 | - * ) |
|
| 1070 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1071 | - * to load an instance of 'some\namespace\classname' |
|
| 1072 | - * |
|
| 1073 | - * @param string $alias |
|
| 1074 | - * @param string $for_class |
|
| 1075 | - * @return string |
|
| 1076 | - * @deprecated 4.9.62.p |
|
| 1077 | - */ |
|
| 1078 | - public function get_alias($alias = '', $for_class = '') |
|
| 1079 | - { |
|
| 1080 | - return $this->getFqnForAlias($alias, $for_class); |
|
| 1081 | - } |
|
| 25 | + /** |
|
| 26 | + * This means that the requested class dependency is not present in the dependency map |
|
| 27 | + */ |
|
| 28 | + const not_registered = 0; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 32 | + */ |
|
| 33 | + const load_new_object = 1; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 37 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 38 | + */ |
|
| 39 | + const load_from_cache = 2; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * When registering a dependency, |
|
| 43 | + * this indicates to keep any existing dependencies that already exist, |
|
| 44 | + * and simply discard any new dependencies declared in the incoming data |
|
| 45 | + */ |
|
| 46 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * When registering a dependency, |
|
| 50 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 51 | + */ |
|
| 52 | + const OVERWRITE_DEPENDENCIES = 1; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @type EE_Dependency_Map $_instance |
|
| 56 | + */ |
|
| 57 | + protected static $_instance; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var ClassInterfaceCache $class_cache |
|
| 61 | + */ |
|
| 62 | + private $class_cache; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @type RequestInterface $request |
|
| 66 | + */ |
|
| 67 | + protected $request; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @type LegacyRequestInterface $legacy_request |
|
| 71 | + */ |
|
| 72 | + protected $legacy_request; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @type ResponseInterface $response |
|
| 76 | + */ |
|
| 77 | + protected $response; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @type LoaderInterface $loader |
|
| 81 | + */ |
|
| 82 | + protected $loader; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @type array $_dependency_map |
|
| 86 | + */ |
|
| 87 | + protected $_dependency_map = []; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @type array $_class_loaders |
|
| 91 | + */ |
|
| 92 | + protected $_class_loaders = []; |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * EE_Dependency_Map constructor. |
|
| 97 | + * |
|
| 98 | + * @param ClassInterfaceCache $class_cache |
|
| 99 | + */ |
|
| 100 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
| 101 | + { |
|
| 102 | + $this->class_cache = $class_cache; |
|
| 103 | + do_action('EE_Dependency_Map____construct', $this); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @return void |
|
| 109 | + * @throws InvalidAliasException |
|
| 110 | + */ |
|
| 111 | + public function initialize() |
|
| 112 | + { |
|
| 113 | + $this->_register_core_dependencies(); |
|
| 114 | + $this->_register_core_class_loaders(); |
|
| 115 | + $this->_register_core_aliases(); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @singleton method used to instantiate class object |
|
| 121 | + * @param ClassInterfaceCache|null $class_cache |
|
| 122 | + * @return EE_Dependency_Map |
|
| 123 | + */ |
|
| 124 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 125 | + { |
|
| 126 | + // check if class object is instantiated, and instantiated properly |
|
| 127 | + if ( |
|
| 128 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
| 129 | + && $class_cache instanceof ClassInterfaceCache |
|
| 130 | + ) { |
|
| 131 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
| 132 | + } |
|
| 133 | + return EE_Dependency_Map::$_instance; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param RequestInterface $request |
|
| 139 | + */ |
|
| 140 | + public function setRequest(RequestInterface $request) |
|
| 141 | + { |
|
| 142 | + $this->request = $request; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @param LegacyRequestInterface $legacy_request |
|
| 148 | + */ |
|
| 149 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 150 | + { |
|
| 151 | + $this->legacy_request = $legacy_request; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param ResponseInterface $response |
|
| 157 | + */ |
|
| 158 | + public function setResponse(ResponseInterface $response) |
|
| 159 | + { |
|
| 160 | + $this->response = $response; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param LoaderInterface $loader |
|
| 166 | + */ |
|
| 167 | + public function setLoader(LoaderInterface $loader) |
|
| 168 | + { |
|
| 169 | + $this->loader = $loader; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * @param string $class |
|
| 175 | + * @param array $dependencies |
|
| 176 | + * @param int $overwrite |
|
| 177 | + * @return bool |
|
| 178 | + */ |
|
| 179 | + public static function register_dependencies( |
|
| 180 | + $class, |
|
| 181 | + array $dependencies, |
|
| 182 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 183 | + ) { |
|
| 184 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 190 | + * to the class specified by the first parameter. |
|
| 191 | + * IMPORTANT !!! |
|
| 192 | + * The order of elements in the incoming $dependencies array MUST match |
|
| 193 | + * the order of the constructor parameters for the class in question. |
|
| 194 | + * This is especially important when overriding any existing dependencies that are registered. |
|
| 195 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 196 | + * |
|
| 197 | + * @param string $class |
|
| 198 | + * @param array $dependencies |
|
| 199 | + * @param int $overwrite |
|
| 200 | + * @return bool |
|
| 201 | + */ |
|
| 202 | + public function registerDependencies( |
|
| 203 | + $class, |
|
| 204 | + array $dependencies, |
|
| 205 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 206 | + ) { |
|
| 207 | + $class = trim($class, '\\'); |
|
| 208 | + $registered = false; |
|
| 209 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
| 210 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
| 211 | + } |
|
| 212 | + // we need to make sure that any aliases used when registering a dependency |
|
| 213 | + // get resolved to the correct class name |
|
| 214 | + foreach ($dependencies as $dependency => $load_source) { |
|
| 215 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
| 216 | + if ( |
|
| 217 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 218 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 219 | + ) { |
|
| 220 | + unset($dependencies[ $dependency ]); |
|
| 221 | + $dependencies[ $alias ] = $load_source; |
|
| 222 | + $registered = true; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + // now add our two lists of dependencies together. |
|
| 226 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 227 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 228 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 229 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 230 | + // especially with numerically indexed arrays |
|
| 231 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
| 232 | + // now we need to ensure that the resulting dependencies |
|
| 233 | + // array only has the entries that are required for the class |
|
| 234 | + // so first count how many dependencies were originally registered for the class |
|
| 235 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
| 236 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 237 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 238 | + // then truncate the final array to match that count |
|
| 239 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 240 | + // otherwise just take the incoming array because nothing previously existed |
|
| 241 | + : $dependencies; |
|
| 242 | + return $registered; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * @param string $class_name |
|
| 248 | + * @param string $loader |
|
| 249 | + * @return bool |
|
| 250 | + * @throws DomainException |
|
| 251 | + */ |
|
| 252 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 253 | + { |
|
| 254 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * @param string $class_name |
|
| 260 | + * @param string $loader |
|
| 261 | + * @return bool |
|
| 262 | + * @throws DomainException |
|
| 263 | + */ |
|
| 264 | + public function registerClassLoader($class_name, $loader = 'load_core') |
|
| 265 | + { |
|
| 266 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 267 | + throw new DomainException( |
|
| 268 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 269 | + ); |
|
| 270 | + } |
|
| 271 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 272 | + if ( |
|
| 273 | + ! is_callable($loader) |
|
| 274 | + && ( |
|
| 275 | + strpos($loader, 'load_') !== 0 |
|
| 276 | + || ! method_exists('EE_Registry', $loader) |
|
| 277 | + ) |
|
| 278 | + ) { |
|
| 279 | + throw new DomainException( |
|
| 280 | + sprintf( |
|
| 281 | + esc_html__( |
|
| 282 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 283 | + 'event_espresso' |
|
| 284 | + ), |
|
| 285 | + $loader |
|
| 286 | + ) |
|
| 287 | + ); |
|
| 288 | + } |
|
| 289 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
| 290 | + if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
| 291 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 292 | + return true; |
|
| 293 | + } |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * @return array |
|
| 300 | + */ |
|
| 301 | + public function dependency_map() |
|
| 302 | + { |
|
| 303 | + return $this->_dependency_map; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 309 | + * |
|
| 310 | + * @param string $class_name |
|
| 311 | + * @return boolean |
|
| 312 | + */ |
|
| 313 | + public function has($class_name = '') |
|
| 314 | + { |
|
| 315 | + // all legacy models have the same dependencies |
|
| 316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 317 | + $class_name = 'LEGACY_MODELS'; |
|
| 318 | + } |
|
| 319 | + return isset($this->_dependency_map[ $class_name ]); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 325 | + * |
|
| 326 | + * @param string $class_name |
|
| 327 | + * @param string $dependency |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 331 | + { |
|
| 332 | + // all legacy models have the same dependencies |
|
| 333 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 334 | + $class_name = 'LEGACY_MODELS'; |
|
| 335 | + } |
|
| 336 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 337 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 343 | + * |
|
| 344 | + * @param string $class_name |
|
| 345 | + * @param string $dependency |
|
| 346 | + * @return int |
|
| 347 | + */ |
|
| 348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 349 | + { |
|
| 350 | + // all legacy models have the same dependencies |
|
| 351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 352 | + $class_name = 'LEGACY_MODELS'; |
|
| 353 | + } |
|
| 354 | + $dependency = $this->getFqnForAlias($dependency); |
|
| 355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 356 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 357 | + : EE_Dependency_Map::not_registered; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * @param string $class_name |
|
| 363 | + * @return string | Closure |
|
| 364 | + */ |
|
| 365 | + public function class_loader($class_name) |
|
| 366 | + { |
|
| 367 | + // all legacy models use load_model() |
|
| 368 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 369 | + return 'load_model'; |
|
| 370 | + } |
|
| 371 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 372 | + // perform strpos() first to avoid loading regex every time we load a class |
|
| 373 | + if ( |
|
| 374 | + strpos($class_name, 'EE_CPT_') === 0 |
|
| 375 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 376 | + ) { |
|
| 377 | + return 'load_core'; |
|
| 378 | + } |
|
| 379 | + $class_name = $this->getFqnForAlias($class_name); |
|
| 380 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * @return array |
|
| 386 | + */ |
|
| 387 | + public function class_loaders() |
|
| 388 | + { |
|
| 389 | + return $this->_class_loaders; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * adds an alias for a classname |
|
| 395 | + * |
|
| 396 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 397 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 398 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 399 | + * @throws InvalidAliasException |
|
| 400 | + */ |
|
| 401 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
| 402 | + { |
|
| 403 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
| 409 | + * WHY? |
|
| 410 | + * Because if a class is type hinting for a concretion, |
|
| 411 | + * then why would we need to find another class to supply it? |
|
| 412 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 413 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 414 | + * Don't go looking for some substitute. |
|
| 415 | + * Whereas if a class is type hinting for an interface... |
|
| 416 | + * then we need to find an actual class to use. |
|
| 417 | + * So the interface IS the alias for some other FQN, |
|
| 418 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 419 | + * represents some other class. |
|
| 420 | + * |
|
| 421 | + * @param string $fqn |
|
| 422 | + * @param string $for_class |
|
| 423 | + * @return bool |
|
| 424 | + */ |
|
| 425 | + public function isAlias($fqn = '', $for_class = '') |
|
| 426 | + { |
|
| 427 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 433 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 434 | + * for example: |
|
| 435 | + * if the following two entries were added to the _aliases array: |
|
| 436 | + * array( |
|
| 437 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 438 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 439 | + * ) |
|
| 440 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 441 | + * to load an instance of 'some\namespace\classname' |
|
| 442 | + * |
|
| 443 | + * @param string $alias |
|
| 444 | + * @param string $for_class |
|
| 445 | + * @return string |
|
| 446 | + */ |
|
| 447 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
| 448 | + { |
|
| 449 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 455 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 456 | + * This is done by using the following class constants: |
|
| 457 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 458 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 459 | + */ |
|
| 460 | + protected function _register_core_dependencies() |
|
| 461 | + { |
|
| 462 | + $this->_dependency_map = [ |
|
| 463 | + 'EE_Request_Handler' => [ |
|
| 464 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 465 | + ], |
|
| 466 | + 'EE_System' => [ |
|
| 467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 468 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 470 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 471 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
| 472 | + ], |
|
| 473 | + 'EE_Admin' => [ |
|
| 474 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 475 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 476 | + ], |
|
| 477 | + 'EE_Cart' => [ |
|
| 478 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 479 | + ], |
|
| 480 | + 'EE_Messenger_Collection_Loader' => [ |
|
| 481 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 482 | + ], |
|
| 483 | + 'EE_Message_Type_Collection_Loader' => [ |
|
| 484 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 485 | + ], |
|
| 486 | + 'EE_Message_Resource_Manager' => [ |
|
| 487 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 488 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 489 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 490 | + ], |
|
| 491 | + 'EE_Message_Factory' => [ |
|
| 492 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 493 | + ], |
|
| 494 | + 'EE_messages' => [ |
|
| 495 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 496 | + ], |
|
| 497 | + 'EE_Messages_Generator' => [ |
|
| 498 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 499 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 500 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 501 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 502 | + ], |
|
| 503 | + 'EE_Messages_Processor' => [ |
|
| 504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 505 | + ], |
|
| 506 | + 'EE_Messages_Queue' => [ |
|
| 507 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 508 | + ], |
|
| 509 | + 'EE_Messages_Template_Defaults' => [ |
|
| 510 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 511 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 512 | + ], |
|
| 513 | + 'EE_Message_To_Generate_From_Request' => [ |
|
| 514 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 515 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 516 | + ], |
|
| 517 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
| 518 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 519 | + ], |
|
| 520 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
| 521 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 522 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + ], |
|
| 524 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
| 525 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 526 | + ], |
|
| 527 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
| 528 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 529 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 530 | + ], |
|
| 531 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
| 532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 533 | + ], |
|
| 534 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
| 535 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 536 | + ], |
|
| 537 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
| 538 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 539 | + ], |
|
| 540 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
| 541 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 542 | + ], |
|
| 543 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
| 544 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 545 | + ], |
|
| 546 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
| 547 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 548 | + ], |
|
| 549 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
| 550 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 551 | + ], |
|
| 552 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
| 553 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 554 | + ], |
|
| 555 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
| 556 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 557 | + ], |
|
| 558 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
| 559 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 560 | + ], |
|
| 561 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
| 562 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 563 | + ], |
|
| 564 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
| 565 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 566 | + ], |
|
| 567 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
| 568 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 569 | + ], |
|
| 570 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
| 571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 572 | + ], |
|
| 573 | + 'EE_Data_Migration_Class_Base' => [ |
|
| 574 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 575 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 576 | + ], |
|
| 577 | + 'EE_DMS_Core_4_1_0' => [ |
|
| 578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 579 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 580 | + ], |
|
| 581 | + 'EE_DMS_Core_4_2_0' => [ |
|
| 582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 584 | + ], |
|
| 585 | + 'EE_DMS_Core_4_3_0' => [ |
|
| 586 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 587 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 588 | + ], |
|
| 589 | + 'EE_DMS_Core_4_4_0' => [ |
|
| 590 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 591 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 592 | + ], |
|
| 593 | + 'EE_DMS_Core_4_5_0' => [ |
|
| 594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 596 | + ], |
|
| 597 | + 'EE_DMS_Core_4_6_0' => [ |
|
| 598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | + ], |
|
| 601 | + 'EE_DMS_Core_4_7_0' => [ |
|
| 602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 604 | + ], |
|
| 605 | + 'EE_DMS_Core_4_8_0' => [ |
|
| 606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 608 | + ], |
|
| 609 | + 'EE_DMS_Core_4_9_0' => [ |
|
| 610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | + ], |
|
| 613 | + 'EE_DMS_Core_4_10_0' => [ |
|
| 614 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 616 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 617 | + ], |
|
| 618 | + 'EE_DMS_Core_4_11_0' => [ |
|
| 619 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
| 620 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 621 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 622 | + ], |
|
| 623 | + 'EE_DMS_Core_4_12_0' => [ |
|
| 624 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
| 625 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 626 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 627 | + ], |
|
| 628 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
| 629 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 630 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
| 631 | + ], |
|
| 632 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
| 633 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 634 | + ], |
|
| 635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
| 636 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 637 | + ], |
|
| 638 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
| 639 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 640 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 641 | + ], |
|
| 642 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
| 643 | + null, |
|
| 644 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 645 | + ], |
|
| 646 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
| 647 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 648 | + ], |
|
| 649 | + 'LEGACY_MODELS' => [ |
|
| 650 | + null, |
|
| 651 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 652 | + ], |
|
| 653 | + 'EE_Module_Request_Router' => [ |
|
| 654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 655 | + ], |
|
| 656 | + 'EE_Registration_Processor' => [ |
|
| 657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 658 | + ], |
|
| 659 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
| 660 | + null, |
|
| 661 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 662 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 663 | + ], |
|
| 664 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
| 665 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 666 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 667 | + ], |
|
| 668 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
| 669 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
| 670 | + ], |
|
| 671 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
| 672 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 673 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 674 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 675 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 676 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 677 | + ], |
|
| 678 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
| 679 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 680 | + ], |
|
| 681 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
| 682 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 683 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 684 | + ], |
|
| 685 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
| 686 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 687 | + ], |
|
| 688 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
| 689 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 690 | + ], |
|
| 691 | + 'EE_CPT_Strategy' => [ |
|
| 692 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 693 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 694 | + ], |
|
| 695 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
| 696 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 697 | + ], |
|
| 698 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
| 699 | + null, |
|
| 700 | + null, |
|
| 701 | + null, |
|
| 702 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 703 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 704 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 705 | + ], |
|
| 706 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
| 707 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 708 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 709 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 710 | + ], |
|
| 711 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
| 712 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 713 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 714 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 715 | + ], |
|
| 716 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
| 717 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 718 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 719 | + ], |
|
| 720 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
| 721 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 722 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 723 | + ], |
|
| 724 | + 'EE_URL_Validation_Strategy' => [ |
|
| 725 | + null, |
|
| 726 | + null, |
|
| 727 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
| 728 | + ], |
|
| 729 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
| 730 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 731 | + ], |
|
| 732 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 733 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 734 | + ], |
|
| 735 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 736 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 737 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 738 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 739 | + null, |
|
| 740 | + ], |
|
| 741 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
| 742 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
| 743 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 744 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 745 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
| 746 | + ], |
|
| 747 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
| 748 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
| 749 | + ], |
|
| 750 | + 'EventEspresso\core\services\routing\Router' => [ |
|
| 751 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 752 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 753 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
| 754 | + ], |
|
| 755 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
| 756 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 757 | + ], |
|
| 758 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
| 759 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 760 | + ], |
|
| 761 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
| 762 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
| 763 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 764 | + ], |
|
| 765 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
| 766 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 767 | + ], |
|
| 768 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
| 769 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
| 770 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
| 771 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
| 772 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
| 773 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
| 774 | + ], |
|
| 775 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
| 776 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 777 | + ], |
|
| 778 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
| 779 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
| 780 | + ], |
|
| 781 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
| 782 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
| 783 | + ], |
|
| 784 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
| 785 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 786 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 787 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 788 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 789 | + ], |
|
| 790 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
| 791 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
| 792 | + ], |
|
| 793 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
| 794 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
| 795 | + ], |
|
| 796 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
| 797 | + 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
| 798 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
| 799 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
| 800 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
| 801 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
| 802 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
| 803 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
| 804 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
| 805 | + ], |
|
| 806 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
| 807 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 808 | + ], |
|
| 809 | + ]; |
|
| 810 | + } |
|
| 811 | + |
|
| 812 | + |
|
| 813 | + /** |
|
| 814 | + * Registers how core classes are loaded. |
|
| 815 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 816 | + * 'EE_Request_Handler' => 'load_core' |
|
| 817 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 818 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 819 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 820 | + * 'Some_Class' => function () { |
|
| 821 | + * return new Some_Class(); |
|
| 822 | + * }, |
|
| 823 | + * This is required for instantiating dependencies |
|
| 824 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 825 | + * 'Required_Interface' => function () { |
|
| 826 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 827 | + * }, |
|
| 828 | + */ |
|
| 829 | + protected function _register_core_class_loaders() |
|
| 830 | + { |
|
| 831 | + $this->_class_loaders = [ |
|
| 832 | + // load_core |
|
| 833 | + 'EE_Dependency_Map' => function () { |
|
| 834 | + return $this; |
|
| 835 | + }, |
|
| 836 | + 'EE_Capabilities' => 'load_core', |
|
| 837 | + 'EE_Encryption' => 'load_core', |
|
| 838 | + 'EE_Front_Controller' => 'load_core', |
|
| 839 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 840 | + 'EE_Registry' => 'load_core', |
|
| 841 | + 'EE_Request' => function () { |
|
| 842 | + return $this->legacy_request; |
|
| 843 | + }, |
|
| 844 | + 'EventEspresso\core\services\request\Request' => function () { |
|
| 845 | + return $this->request; |
|
| 846 | + }, |
|
| 847 | + 'EventEspresso\core\services\request\Response' => function () { |
|
| 848 | + return $this->response; |
|
| 849 | + }, |
|
| 850 | + 'EE_Base' => 'load_core', |
|
| 851 | + 'EE_Request_Handler' => 'load_core', |
|
| 852 | + 'EE_Session' => 'load_core', |
|
| 853 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 854 | + 'EE_System' => 'load_core', |
|
| 855 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 856 | + 'EE_Register_CPTs' => 'load_core', |
|
| 857 | + 'EE_Admin' => 'load_core', |
|
| 858 | + 'EE_CPT_Strategy' => 'load_core', |
|
| 859 | + // load_class |
|
| 860 | + 'EE_Registration_Processor' => 'load_class', |
|
| 861 | + // load_lib |
|
| 862 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 863 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 864 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 865 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 866 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 867 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 868 | + 'EE_Message_Repository' => 'load_lib', |
|
| 869 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 870 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 871 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 872 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 873 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 874 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 875 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 876 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 877 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 878 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 879 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 880 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 881 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 882 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
| 883 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
| 884 | + 'EE_Messages_Generator' => static function () { |
|
| 885 | + return EE_Registry::instance()->load_lib( |
|
| 886 | + 'Messages_Generator', |
|
| 887 | + [], |
|
| 888 | + false, |
|
| 889 | + false |
|
| 890 | + ); |
|
| 891 | + }, |
|
| 892 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
| 893 | + return EE_Registry::instance()->load_lib( |
|
| 894 | + 'Messages_Template_Defaults', |
|
| 895 | + $arguments, |
|
| 896 | + false, |
|
| 897 | + false |
|
| 898 | + ); |
|
| 899 | + }, |
|
| 900 | + // load_helper |
|
| 901 | + 'EEH_Parse_Shortcodes' => static function () { |
|
| 902 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 903 | + return new EEH_Parse_Shortcodes(); |
|
| 904 | + } |
|
| 905 | + return null; |
|
| 906 | + }, |
|
| 907 | + 'EE_Template_Config' => static function () { |
|
| 908 | + return EE_Config::instance()->template_settings; |
|
| 909 | + }, |
|
| 910 | + 'EE_Currency_Config' => static function () { |
|
| 911 | + return EE_Config::instance()->currency; |
|
| 912 | + }, |
|
| 913 | + 'EE_Registration_Config' => static function () { |
|
| 914 | + return EE_Config::instance()->registration; |
|
| 915 | + }, |
|
| 916 | + 'EE_Core_Config' => static function () { |
|
| 917 | + return EE_Config::instance()->core; |
|
| 918 | + }, |
|
| 919 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 920 | + return LoaderFactory::getLoader(); |
|
| 921 | + }, |
|
| 922 | + 'EE_Network_Config' => static function () { |
|
| 923 | + return EE_Network_Config::instance(); |
|
| 924 | + }, |
|
| 925 | + 'EE_Config' => static function () { |
|
| 926 | + return EE_Config::instance(); |
|
| 927 | + }, |
|
| 928 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
| 929 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
| 930 | + }, |
|
| 931 | + 'EE_Admin_Config' => static function () { |
|
| 932 | + return EE_Config::instance()->admin; |
|
| 933 | + }, |
|
| 934 | + 'EE_Organization_Config' => static function () { |
|
| 935 | + return EE_Config::instance()->organization; |
|
| 936 | + }, |
|
| 937 | + 'EE_Network_Core_Config' => static function () { |
|
| 938 | + return EE_Network_Config::instance()->core; |
|
| 939 | + }, |
|
| 940 | + 'EE_Environment_Config' => static function () { |
|
| 941 | + return EE_Config::instance()->environment; |
|
| 942 | + }, |
|
| 943 | + 'EED_Core_Rest_Api' => static function () { |
|
| 944 | + return EED_Core_Rest_Api::instance(); |
|
| 945 | + }, |
|
| 946 | + 'WP_REST_Server' => static function () { |
|
| 947 | + return rest_get_server(); |
|
| 948 | + }, |
|
| 949 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
| 950 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
| 951 | + }, |
|
| 952 | + ]; |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + |
|
| 956 | + /** |
|
| 957 | + * can be used for supplying alternate names for classes, |
|
| 958 | + * or for connecting interface names to instantiable classes |
|
| 959 | + * |
|
| 960 | + * @throws InvalidAliasException |
|
| 961 | + */ |
|
| 962 | + protected function _register_core_aliases() |
|
| 963 | + { |
|
| 964 | + $aliases = [ |
|
| 965 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 966 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 967 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 968 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 969 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 970 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 971 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 972 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 973 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 974 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 975 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 976 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 977 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 978 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 979 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 980 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 981 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 982 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 983 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 984 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 985 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 986 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 987 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 988 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 989 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 990 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 991 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 992 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 993 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 994 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 995 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 996 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 997 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 998 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 999 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1000 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1001 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1002 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1003 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
| 1004 | + ]; |
|
| 1005 | + foreach ($aliases as $alias => $fqn) { |
|
| 1006 | + if (is_array($fqn)) { |
|
| 1007 | + foreach ($fqn as $class => $for_class) { |
|
| 1008 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1009 | + } |
|
| 1010 | + continue; |
|
| 1011 | + } |
|
| 1012 | + $this->class_cache->addAlias($fqn, $alias); |
|
| 1013 | + } |
|
| 1014 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1015 | + $this->class_cache->addAlias( |
|
| 1016 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1017 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1018 | + ); |
|
| 1019 | + } |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + |
|
| 1023 | + /** |
|
| 1024 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1025 | + * request Primarily used by unit tests. |
|
| 1026 | + */ |
|
| 1027 | + public function reset() |
|
| 1028 | + { |
|
| 1029 | + $this->_register_core_class_loaders(); |
|
| 1030 | + $this->_register_core_dependencies(); |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + |
|
| 1034 | + /** |
|
| 1035 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1036 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1037 | + * WHY? |
|
| 1038 | + * Because if a class is type hinting for a concretion, |
|
| 1039 | + * then why would we need to find another class to supply it? |
|
| 1040 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1041 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1042 | + * Don't go looking for some substitute. |
|
| 1043 | + * Whereas if a class is type hinting for an interface... |
|
| 1044 | + * then we need to find an actual class to use. |
|
| 1045 | + * So the interface IS the alias for some other FQN, |
|
| 1046 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1047 | + * represents some other class. |
|
| 1048 | + * |
|
| 1049 | + * @param string $fqn |
|
| 1050 | + * @param string $for_class |
|
| 1051 | + * @return bool |
|
| 1052 | + * @deprecated 4.9.62.p |
|
| 1053 | + */ |
|
| 1054 | + public function has_alias($fqn = '', $for_class = '') |
|
| 1055 | + { |
|
| 1056 | + return $this->isAlias($fqn, $for_class); |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1062 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1063 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1064 | + * for example: |
|
| 1065 | + * if the following two entries were added to the _aliases array: |
|
| 1066 | + * array( |
|
| 1067 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 1068 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1069 | + * ) |
|
| 1070 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1071 | + * to load an instance of 'some\namespace\classname' |
|
| 1072 | + * |
|
| 1073 | + * @param string $alias |
|
| 1074 | + * @param string $for_class |
|
| 1075 | + * @return string |
|
| 1076 | + * @deprecated 4.9.62.p |
|
| 1077 | + */ |
|
| 1078 | + public function get_alias($alias = '', $for_class = '') |
|
| 1079 | + { |
|
| 1080 | + return $this->getFqnForAlias($alias, $for_class); |
|
| 1081 | + } |
|
| 1082 | 1082 | } |
@@ -37,122 +37,122 @@ |
||
| 37 | 37 | * @since 4.0 |
| 38 | 38 | */ |
| 39 | 39 | if (function_exists('espresso_version')) { |
| 40 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 41 | - /** |
|
| 42 | - * espresso_duplicate_plugin_error |
|
| 43 | - * displays if more than one version of EE is activated at the same time |
|
| 44 | - */ |
|
| 45 | - function espresso_duplicate_plugin_error() |
|
| 46 | - { |
|
| 47 | - ?> |
|
| 40 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 41 | + /** |
|
| 42 | + * espresso_duplicate_plugin_error |
|
| 43 | + * displays if more than one version of EE is activated at the same time |
|
| 44 | + */ |
|
| 45 | + function espresso_duplicate_plugin_error() |
|
| 46 | + { |
|
| 47 | + ?> |
|
| 48 | 48 | <div class="error"> |
| 49 | 49 | <p> |
| 50 | 50 | <?php |
| 51 | - echo esc_html__( |
|
| 52 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 53 | - 'event_espresso' |
|
| 54 | - ); ?> |
|
| 51 | + echo esc_html__( |
|
| 52 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 53 | + 'event_espresso' |
|
| 54 | + ); ?> |
|
| 55 | 55 | </p> |
| 56 | 56 | </div> |
| 57 | 57 | <?php |
| 58 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 58 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | 62 | } else { |
| 63 | - define('EE_MIN_PHP_VER_REQUIRED', '7.1.0'); |
|
| 64 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 65 | - /** |
|
| 66 | - * espresso_minimum_php_version_error |
|
| 67 | - * |
|
| 68 | - * @return void |
|
| 69 | - */ |
|
| 70 | - function espresso_minimum_php_version_error() |
|
| 71 | - { |
|
| 72 | - ?> |
|
| 63 | + define('EE_MIN_PHP_VER_REQUIRED', '7.1.0'); |
|
| 64 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 65 | + /** |
|
| 66 | + * espresso_minimum_php_version_error |
|
| 67 | + * |
|
| 68 | + * @return void |
|
| 69 | + */ |
|
| 70 | + function espresso_minimum_php_version_error() |
|
| 71 | + { |
|
| 72 | + ?> |
|
| 73 | 73 | <div class="error"> |
| 74 | 74 | <p> |
| 75 | 75 | <?php |
| 76 | - printf( |
|
| 77 | - esc_html__( |
|
| 78 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 79 | - 'event_espresso' |
|
| 80 | - ), |
|
| 81 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 82 | - PHP_VERSION, |
|
| 83 | - '<br/>', |
|
| 84 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 85 | - ); |
|
| 86 | - ?> |
|
| 76 | + printf( |
|
| 77 | + esc_html__( |
|
| 78 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 79 | + 'event_espresso' |
|
| 80 | + ), |
|
| 81 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 82 | + PHP_VERSION, |
|
| 83 | + '<br/>', |
|
| 84 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 85 | + ); |
|
| 86 | + ?> |
|
| 87 | 87 | </p> |
| 88 | 88 | </div> |
| 89 | 89 | <?php |
| 90 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 91 | - } |
|
| 90 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 94 | - } else { |
|
| 95 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.12.0.rc.001'); |
|
| 105 | - } |
|
| 93 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 94 | + } else { |
|
| 95 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.12.0.rc.001'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * espresso_plugin_activation |
|
| 109 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 110 | - */ |
|
| 111 | - function espresso_plugin_activation() |
|
| 112 | - { |
|
| 113 | - update_option('ee_espresso_activation', true); |
|
| 107 | + /** |
|
| 108 | + * espresso_plugin_activation |
|
| 109 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 110 | + */ |
|
| 111 | + function espresso_plugin_activation() |
|
| 112 | + { |
|
| 113 | + update_option('ee_espresso_activation', true); |
|
| 114 | 114 | |
| 115 | - // Run WP GraphQL activation callback |
|
| 116 | - if (! class_exists('WPGraphQL')) { |
|
| 117 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 118 | - } |
|
| 119 | - graphql_activation_callback(); |
|
| 120 | - } |
|
| 115 | + // Run WP GraphQL activation callback |
|
| 116 | + if (! class_exists('WPGraphQL')) { |
|
| 117 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 118 | + } |
|
| 119 | + graphql_activation_callback(); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 122 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * espresso_plugin_deactivation |
|
| 126 | - */ |
|
| 127 | - function espresso_plugin_deactivation() |
|
| 128 | - { |
|
| 129 | - // Run WP GraphQL deactivation callback |
|
| 130 | - if (! class_exists('WPGraphQL')) { |
|
| 131 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 132 | - } |
|
| 133 | - graphql_deactivation_callback(); |
|
| 134 | - } |
|
| 135 | - register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 124 | + /** |
|
| 125 | + * espresso_plugin_deactivation |
|
| 126 | + */ |
|
| 127 | + function espresso_plugin_deactivation() |
|
| 128 | + { |
|
| 129 | + // Run WP GraphQL deactivation callback |
|
| 130 | + if (! class_exists('WPGraphQL')) { |
|
| 131 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 132 | + } |
|
| 133 | + graphql_deactivation_callback(); |
|
| 134 | + } |
|
| 135 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 136 | 136 | |
| 137 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 138 | - bootstrap_espresso(); |
|
| 139 | - } |
|
| 137 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 138 | + bootstrap_espresso(); |
|
| 139 | + } |
|
| 140 | 140 | } |
| 141 | 141 | if (! function_exists('espresso_deactivate_plugin')) { |
| 142 | - /** |
|
| 143 | - * deactivate_plugin |
|
| 144 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 145 | - * |
|
| 146 | - * @access public |
|
| 147 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 148 | - * @return void |
|
| 149 | - */ |
|
| 150 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 151 | - { |
|
| 152 | - if (! function_exists('deactivate_plugins')) { |
|
| 153 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 154 | - } |
|
| 155 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 156 | - deactivate_plugins($plugin_basename); |
|
| 157 | - } |
|
| 142 | + /** |
|
| 143 | + * deactivate_plugin |
|
| 144 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 145 | + * |
|
| 146 | + * @access public |
|
| 147 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 148 | + * @return void |
|
| 149 | + */ |
|
| 150 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 151 | + { |
|
| 152 | + if (! function_exists('deactivate_plugins')) { |
|
| 153 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 154 | + } |
|
| 155 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 156 | + deactivate_plugins($plugin_basename); |
|
| 157 | + } |
|
| 158 | 158 | } |
@@ -11,93 +11,93 @@ discard block |
||
| 11 | 11 | class EEM_Change_Log extends EEM_Base |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * the related object was created log type |
|
| 16 | - */ |
|
| 17 | - const type_create = 'create'; |
|
| 18 | - /** |
|
| 19 | - * the related object was updated (changed, or soft-deleted) |
|
| 20 | - */ |
|
| 21 | - const type_update = 'update'; |
|
| 22 | - /** |
|
| 23 | - * the related object was deleted permanently |
|
| 24 | - */ |
|
| 25 | - const type_delete = 'delete'; |
|
| 26 | - /** |
|
| 27 | - * the related item had something worth noting happen on it, but |
|
| 28 | - * only for the purposes of debugging problems |
|
| 29 | - */ |
|
| 30 | - const type_debug = 'debug'; |
|
| 31 | - /** |
|
| 32 | - * the related item had an error occur on it |
|
| 33 | - */ |
|
| 34 | - const type_error = 'error'; |
|
| 35 | - /** |
|
| 36 | - * the related item is regarding some gateway interaction, like an IPN |
|
| 37 | - * or request to process a payment |
|
| 38 | - */ |
|
| 39 | - const type_gateway = 'gateway'; |
|
| 14 | + /** |
|
| 15 | + * the related object was created log type |
|
| 16 | + */ |
|
| 17 | + const type_create = 'create'; |
|
| 18 | + /** |
|
| 19 | + * the related object was updated (changed, or soft-deleted) |
|
| 20 | + */ |
|
| 21 | + const type_update = 'update'; |
|
| 22 | + /** |
|
| 23 | + * the related object was deleted permanently |
|
| 24 | + */ |
|
| 25 | + const type_delete = 'delete'; |
|
| 26 | + /** |
|
| 27 | + * the related item had something worth noting happen on it, but |
|
| 28 | + * only for the purposes of debugging problems |
|
| 29 | + */ |
|
| 30 | + const type_debug = 'debug'; |
|
| 31 | + /** |
|
| 32 | + * the related item had an error occur on it |
|
| 33 | + */ |
|
| 34 | + const type_error = 'error'; |
|
| 35 | + /** |
|
| 36 | + * the related item is regarding some gateway interaction, like an IPN |
|
| 37 | + * or request to process a payment |
|
| 38 | + */ |
|
| 39 | + const type_gateway = 'gateway'; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * private instance of the EEM_Change_Log object |
|
| 43 | - * |
|
| 44 | - * @access private |
|
| 45 | - * @var EEM_Change_Log $_instance |
|
| 46 | - */ |
|
| 47 | - protected static $_instance = null; |
|
| 41 | + /** |
|
| 42 | + * private instance of the EEM_Change_Log object |
|
| 43 | + * |
|
| 44 | + * @access private |
|
| 45 | + * @var EEM_Change_Log $_instance |
|
| 46 | + */ |
|
| 47 | + protected static $_instance = null; |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * constructor |
|
| 52 | - * |
|
| 53 | - * @access protected |
|
| 54 | - * @param null $timezone |
|
| 55 | - * @throws EE_Error |
|
| 56 | - */ |
|
| 57 | - protected function __construct($timezone = null) |
|
| 58 | - { |
|
| 59 | - global $current_user; |
|
| 60 | - $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
| 61 | - $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
| 62 | - $this->_tables = array( |
|
| 63 | - 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
| 64 | - ); |
|
| 65 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
| 66 | - $this->_fields = array( |
|
| 67 | - 'Log' => array( |
|
| 68 | - 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
| 69 | - 'LOG_time' => new EE_Datetime_Field( |
|
| 70 | - 'LOG_time', |
|
| 71 | - esc_html__("Log Time", 'event_espresso'), |
|
| 72 | - false, |
|
| 73 | - EE_Datetime_Field::now |
|
| 74 | - ), |
|
| 75 | - 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
| 76 | - 'OBJ_ID', |
|
| 77 | - esc_html__("Object ID (int or string)", 'event_espresso'), |
|
| 78 | - true, |
|
| 79 | - null, |
|
| 80 | - $models_this_can_attach_to |
|
| 81 | - ), |
|
| 82 | - 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
| 83 | - 'OBJ_type', |
|
| 84 | - esc_html__("Object Type", 'event_espresso'), |
|
| 85 | - true, |
|
| 86 | - null, |
|
| 87 | - $models_this_can_attach_to |
|
| 88 | - ), |
|
| 89 | - 'LOG_type' => new EE_Plain_Text_Field( |
|
| 90 | - 'LOG_type', |
|
| 91 | - esc_html__("Type of log entry", "event_espresso"), |
|
| 92 | - false, |
|
| 93 | - self::type_debug |
|
| 94 | - ), |
|
| 95 | - 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
| 96 | - 'LOG_message', |
|
| 97 | - esc_html__("Log Message (body)", 'event_espresso'), |
|
| 98 | - true |
|
| 99 | - ), |
|
| 100 | - /* |
|
| 50 | + /** |
|
| 51 | + * constructor |
|
| 52 | + * |
|
| 53 | + * @access protected |
|
| 54 | + * @param null $timezone |
|
| 55 | + * @throws EE_Error |
|
| 56 | + */ |
|
| 57 | + protected function __construct($timezone = null) |
|
| 58 | + { |
|
| 59 | + global $current_user; |
|
| 60 | + $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
| 61 | + $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
| 62 | + $this->_tables = array( |
|
| 63 | + 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
| 64 | + ); |
|
| 65 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
| 66 | + $this->_fields = array( |
|
| 67 | + 'Log' => array( |
|
| 68 | + 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
| 69 | + 'LOG_time' => new EE_Datetime_Field( |
|
| 70 | + 'LOG_time', |
|
| 71 | + esc_html__("Log Time", 'event_espresso'), |
|
| 72 | + false, |
|
| 73 | + EE_Datetime_Field::now |
|
| 74 | + ), |
|
| 75 | + 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
| 76 | + 'OBJ_ID', |
|
| 77 | + esc_html__("Object ID (int or string)", 'event_espresso'), |
|
| 78 | + true, |
|
| 79 | + null, |
|
| 80 | + $models_this_can_attach_to |
|
| 81 | + ), |
|
| 82 | + 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
| 83 | + 'OBJ_type', |
|
| 84 | + esc_html__("Object Type", 'event_espresso'), |
|
| 85 | + true, |
|
| 86 | + null, |
|
| 87 | + $models_this_can_attach_to |
|
| 88 | + ), |
|
| 89 | + 'LOG_type' => new EE_Plain_Text_Field( |
|
| 90 | + 'LOG_type', |
|
| 91 | + esc_html__("Type of log entry", "event_espresso"), |
|
| 92 | + false, |
|
| 93 | + self::type_debug |
|
| 94 | + ), |
|
| 95 | + 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
| 96 | + 'LOG_message', |
|
| 97 | + esc_html__("Log Message (body)", 'event_espresso'), |
|
| 98 | + true |
|
| 99 | + ), |
|
| 100 | + /* |
|
| 101 | 101 | * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used, |
| 102 | 102 | * not the LOG_wp_user field. E.g., |
| 103 | 103 | * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return |
@@ -106,158 +106,158 @@ discard block |
||
| 106 | 106 | * If you want the latter, you can't use the model's magic joining. E.g, you would need to do |
| 107 | 107 | * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`. |
| 108 | 108 | */ |
| 109 | - 'LOG_wp_user' => new EE_WP_User_Field( |
|
| 110 | - 'LOG_wp_user', |
|
| 111 | - esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
| 112 | - true |
|
| 113 | - ), |
|
| 114 | - ), |
|
| 115 | - ); |
|
| 116 | - $this->_model_relations = array(); |
|
| 117 | - foreach ($models_this_can_attach_to as $model) { |
|
| 118 | - if ($model != 'Change_Log') { |
|
| 119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - // use completely custom caps for this |
|
| 123 | - unset($this->_cap_restriction_generators); |
|
| 124 | - // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
| 125 | - foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
| 126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
| 127 | - = new EE_Return_None_Where_Conditions(); |
|
| 128 | - } |
|
| 129 | - parent::__construct($timezone); |
|
| 130 | - } |
|
| 109 | + 'LOG_wp_user' => new EE_WP_User_Field( |
|
| 110 | + 'LOG_wp_user', |
|
| 111 | + esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
| 112 | + true |
|
| 113 | + ), |
|
| 114 | + ), |
|
| 115 | + ); |
|
| 116 | + $this->_model_relations = array(); |
|
| 117 | + foreach ($models_this_can_attach_to as $model) { |
|
| 118 | + if ($model != 'Change_Log') { |
|
| 119 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + // use completely custom caps for this |
|
| 123 | + unset($this->_cap_restriction_generators); |
|
| 124 | + // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
| 125 | + foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
| 126 | + $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
| 127 | + = new EE_Return_None_Where_Conditions(); |
|
| 128 | + } |
|
| 129 | + parent::__construct($timezone); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
| 134 | - * @param mixed $message array|string of the message you want to record |
|
| 135 | - * @param EE_Base_Class $related_model_obj |
|
| 136 | - * @return EE_Change_Log |
|
| 137 | - * @throws EE_Error |
|
| 138 | - */ |
|
| 139 | - public function log($log_type, $message, $related_model_obj) |
|
| 140 | - { |
|
| 141 | - if ($related_model_obj instanceof EE_Base_Class) { |
|
| 142 | - $obj_id = $related_model_obj->ID(); |
|
| 143 | - $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
| 144 | - } else { |
|
| 145 | - $obj_id = null; |
|
| 146 | - $obj_type = null; |
|
| 147 | - } |
|
| 148 | - /** @var EE_Change_Log $log */ |
|
| 149 | - $log = EE_Change_Log::new_instance(array( |
|
| 150 | - 'LOG_type' => $log_type, |
|
| 151 | - 'LOG_message' => $message, |
|
| 152 | - 'OBJ_ID' => $obj_id, |
|
| 153 | - 'OBJ_type' => $obj_type, |
|
| 154 | - )); |
|
| 155 | - $log->save(); |
|
| 156 | - return $log; |
|
| 157 | - } |
|
| 132 | + /** |
|
| 133 | + * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
| 134 | + * @param mixed $message array|string of the message you want to record |
|
| 135 | + * @param EE_Base_Class $related_model_obj |
|
| 136 | + * @return EE_Change_Log |
|
| 137 | + * @throws EE_Error |
|
| 138 | + */ |
|
| 139 | + public function log($log_type, $message, $related_model_obj) |
|
| 140 | + { |
|
| 141 | + if ($related_model_obj instanceof EE_Base_Class) { |
|
| 142 | + $obj_id = $related_model_obj->ID(); |
|
| 143 | + $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
| 144 | + } else { |
|
| 145 | + $obj_id = null; |
|
| 146 | + $obj_type = null; |
|
| 147 | + } |
|
| 148 | + /** @var EE_Change_Log $log */ |
|
| 149 | + $log = EE_Change_Log::new_instance(array( |
|
| 150 | + 'LOG_type' => $log_type, |
|
| 151 | + 'LOG_message' => $message, |
|
| 152 | + 'OBJ_ID' => $obj_id, |
|
| 153 | + 'OBJ_type' => $obj_type, |
|
| 154 | + )); |
|
| 155 | + $log->save(); |
|
| 156 | + return $log; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Adds a gateway log for the specified object, given its ID and type |
|
| 162 | - * |
|
| 163 | - * @param string $message |
|
| 164 | - * @param mixed $related_obj_id |
|
| 165 | - * @param string $related_obj_type |
|
| 166 | - * @throws EE_Error |
|
| 167 | - * @return EE_Change_Log |
|
| 168 | - */ |
|
| 169 | - public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
| 170 | - { |
|
| 171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
| 172 | - throw new EE_Error( |
|
| 173 | - sprintf( |
|
| 174 | - esc_html__( |
|
| 175 | - "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
| 176 | - "event_espresso" |
|
| 177 | - ), |
|
| 178 | - $related_obj_type |
|
| 179 | - ) |
|
| 180 | - ); |
|
| 181 | - } |
|
| 182 | - /** @var EE_Change_Log $log */ |
|
| 183 | - $log = EE_Change_Log::new_instance(array( |
|
| 184 | - 'LOG_type' => EEM_Change_Log::type_gateway, |
|
| 185 | - 'LOG_message' => $message, |
|
| 186 | - 'OBJ_ID' => $related_obj_id, |
|
| 187 | - 'OBJ_type' => $related_obj_type, |
|
| 188 | - )); |
|
| 189 | - $log->save(); |
|
| 190 | - return $log; |
|
| 191 | - } |
|
| 160 | + /** |
|
| 161 | + * Adds a gateway log for the specified object, given its ID and type |
|
| 162 | + * |
|
| 163 | + * @param string $message |
|
| 164 | + * @param mixed $related_obj_id |
|
| 165 | + * @param string $related_obj_type |
|
| 166 | + * @throws EE_Error |
|
| 167 | + * @return EE_Change_Log |
|
| 168 | + */ |
|
| 169 | + public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
| 170 | + { |
|
| 171 | + if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
| 172 | + throw new EE_Error( |
|
| 173 | + sprintf( |
|
| 174 | + esc_html__( |
|
| 175 | + "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
| 176 | + "event_espresso" |
|
| 177 | + ), |
|
| 178 | + $related_obj_type |
|
| 179 | + ) |
|
| 180 | + ); |
|
| 181 | + } |
|
| 182 | + /** @var EE_Change_Log $log */ |
|
| 183 | + $log = EE_Change_Log::new_instance(array( |
|
| 184 | + 'LOG_type' => EEM_Change_Log::type_gateway, |
|
| 185 | + 'LOG_message' => $message, |
|
| 186 | + 'OBJ_ID' => $related_obj_id, |
|
| 187 | + 'OBJ_type' => $related_obj_type, |
|
| 188 | + )); |
|
| 189 | + $log->save(); |
|
| 190 | + return $log; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
| 196 | - * |
|
| 197 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 198 | - * @return array of arrays |
|
| 199 | - * @throws EE_Error |
|
| 200 | - */ |
|
| 201 | - public function get_all_efficiently($query_params) |
|
| 202 | - { |
|
| 203 | - return $this->_get_all_wpdb_results($query_params); |
|
| 204 | - } |
|
| 194 | + /** |
|
| 195 | + * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
| 196 | + * |
|
| 197 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 198 | + * @return array of arrays |
|
| 199 | + * @throws EE_Error |
|
| 200 | + */ |
|
| 201 | + public function get_all_efficiently($query_params) |
|
| 202 | + { |
|
| 203 | + return $this->_get_all_wpdb_results($query_params); |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | 206 | |
| 207 | - /** |
|
| 208 | - * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
| 209 | - * models after this, they may be out-of-sync with the database |
|
| 210 | - * |
|
| 211 | - * @param DateTime $datetime |
|
| 212 | - * @return false|int |
|
| 213 | - * @throws EE_Error |
|
| 214 | - */ |
|
| 215 | - public function delete_gateway_logs_older_than(DateTime $datetime) |
|
| 216 | - { |
|
| 217 | - global $wpdb; |
|
| 218 | - return $wpdb->query( |
|
| 219 | - $wpdb->prepare( |
|
| 220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
| 221 | - EEM_Change_Log::type_gateway, |
|
| 222 | - $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 225 | - } |
|
| 207 | + /** |
|
| 208 | + * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
| 209 | + * models after this, they may be out-of-sync with the database |
|
| 210 | + * |
|
| 211 | + * @param DateTime $datetime |
|
| 212 | + * @return false|int |
|
| 213 | + * @throws EE_Error |
|
| 214 | + */ |
|
| 215 | + public function delete_gateway_logs_older_than(DateTime $datetime) |
|
| 216 | + { |
|
| 217 | + global $wpdb; |
|
| 218 | + return $wpdb->query( |
|
| 219 | + $wpdb->prepare( |
|
| 220 | + 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
| 221 | + EEM_Change_Log::type_gateway, |
|
| 222 | + $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
| 230 | - * map vai the given filter. |
|
| 231 | - * |
|
| 232 | - * @return array |
|
| 233 | - */ |
|
| 234 | - public static function get_pretty_label_map_for_registered_types() |
|
| 235 | - { |
|
| 236 | - return apply_filters( |
|
| 237 | - 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
| 238 | - array( |
|
| 239 | - self::type_create => esc_html__("Create", "event_espresso"), |
|
| 240 | - self::type_update => esc_html__("Update", "event_espresso"), |
|
| 241 | - self::type_delete => esc_html__("Delete", "event_espresso"), |
|
| 242 | - self::type_debug => esc_html__("Debug", "event_espresso"), |
|
| 243 | - self::type_error => esc_html__("Error", "event_espresso"), |
|
| 244 | - self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
| 245 | - ) |
|
| 246 | - ); |
|
| 247 | - } |
|
| 228 | + /** |
|
| 229 | + * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
| 230 | + * map vai the given filter. |
|
| 231 | + * |
|
| 232 | + * @return array |
|
| 233 | + */ |
|
| 234 | + public static function get_pretty_label_map_for_registered_types() |
|
| 235 | + { |
|
| 236 | + return apply_filters( |
|
| 237 | + 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
| 238 | + array( |
|
| 239 | + self::type_create => esc_html__("Create", "event_espresso"), |
|
| 240 | + self::type_update => esc_html__("Update", "event_espresso"), |
|
| 241 | + self::type_delete => esc_html__("Delete", "event_espresso"), |
|
| 242 | + self::type_debug => esc_html__("Debug", "event_espresso"), |
|
| 243 | + self::type_error => esc_html__("Error", "event_espresso"), |
|
| 244 | + self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
| 245 | + ) |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | |
| 250 | - /** |
|
| 251 | - * Return the pretty (localized) label for the given log type identifier. |
|
| 252 | - * @param string $type_identifier |
|
| 253 | - * @return string |
|
| 254 | - */ |
|
| 255 | - public static function get_pretty_label_for_type($type_identifier) |
|
| 256 | - { |
|
| 257 | - $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
| 258 | - // we fallback to the incoming type identifier if there is no localized label for it. |
|
| 259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
| 260 | - ? $type_identifier_map[ $type_identifier ] |
|
| 261 | - : $type_identifier; |
|
| 262 | - } |
|
| 250 | + /** |
|
| 251 | + * Return the pretty (localized) label for the given log type identifier. |
|
| 252 | + * @param string $type_identifier |
|
| 253 | + * @return string |
|
| 254 | + */ |
|
| 255 | + public static function get_pretty_label_for_type($type_identifier) |
|
| 256 | + { |
|
| 257 | + $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
| 258 | + // we fallback to the incoming type identifier if there is no localized label for it. |
|
| 259 | + return isset($type_identifier_map[ $type_identifier ]) |
|
| 260 | + ? $type_identifier_map[ $type_identifier ] |
|
| 261 | + : $type_identifier; |
|
| 262 | + } |
|
| 263 | 263 | } |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | ), |
| 114 | 114 | ), |
| 115 | 115 | ); |
| 116 | - $this->_model_relations = array(); |
|
| 116 | + $this->_model_relations = array(); |
|
| 117 | 117 | foreach ($models_this_can_attach_to as $model) { |
| 118 | 118 | if ($model != 'Change_Log') { |
| 119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 119 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | // use completely custom caps for this |
| 123 | 123 | unset($this->_cap_restriction_generators); |
| 124 | 124 | // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
| 125 | 125 | foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
| 126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
| 126 | + $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] |
|
| 127 | 127 | = new EE_Return_None_Where_Conditions(); |
| 128 | 128 | } |
| 129 | 129 | parent::__construct($timezone); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function gateway_log($message, $related_obj_id, $related_obj_type) |
| 170 | 170 | { |
| 171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
| 171 | + if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
| 172 | 172 | throw new EE_Error( |
| 173 | 173 | sprintf( |
| 174 | 174 | esc_html__( |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | global $wpdb; |
| 218 | 218 | return $wpdb->query( |
| 219 | 219 | $wpdb->prepare( |
| 220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
| 220 | + 'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s', |
|
| 221 | 221 | EEM_Change_Log::type_gateway, |
| 222 | 222 | $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
| 223 | 223 | ) |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
| 258 | 258 | // we fallback to the incoming type identifier if there is no localized label for it. |
| 259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
| 260 | - ? $type_identifier_map[ $type_identifier ] |
|
| 259 | + return isset($type_identifier_map[$type_identifier]) |
|
| 260 | + ? $type_identifier_map[$type_identifier] |
|
| 261 | 261 | : $type_identifier; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -4,49 +4,49 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Button |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * indicates that the HTML input type is 'button' |
|
| 9 | - */ |
|
| 10 | - public const TYPE_BUTTON = 'button'; |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * indicates that the HTML input type is 'reset' |
|
| 14 | - */ |
|
| 15 | - public const TYPE_BUTTON_RESET = 'reset'; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * indicates that the HTML input type is 'submit' |
|
| 19 | - */ |
|
| 20 | - public const TYPE_BUTTON_SUBMIT = 'submit'; |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - private $valid_type_options; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - public function __construct() |
|
| 30 | - { |
|
| 31 | - $this->valid_type_options = apply_filters( |
|
| 32 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Button__valid_type_options', |
|
| 33 | - [ |
|
| 34 | - Button::TYPE_BUTTON => esc_html__('Button', 'event_espresso'), |
|
| 35 | - Button::TYPE_BUTTON_RESET => esc_html__('Reset Button', 'event_espresso'), |
|
| 36 | - Button::TYPE_BUTTON_SUBMIT => esc_html__('Submit Button', 'event_espresso'), |
|
| 37 | - ] |
|
| 38 | - ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @param bool $constants_only |
|
| 44 | - * @return array |
|
| 45 | - */ |
|
| 46 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 47 | - { |
|
| 48 | - return $constants_only |
|
| 49 | - ? array_keys($this->valid_type_options) |
|
| 50 | - : $this->valid_type_options; |
|
| 51 | - } |
|
| 7 | + /** |
|
| 8 | + * indicates that the HTML input type is 'button' |
|
| 9 | + */ |
|
| 10 | + public const TYPE_BUTTON = 'button'; |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * indicates that the HTML input type is 'reset' |
|
| 14 | + */ |
|
| 15 | + public const TYPE_BUTTON_RESET = 'reset'; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * indicates that the HTML input type is 'submit' |
|
| 19 | + */ |
|
| 20 | + public const TYPE_BUTTON_SUBMIT = 'submit'; |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + private $valid_type_options; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + public function __construct() |
|
| 30 | + { |
|
| 31 | + $this->valid_type_options = apply_filters( |
|
| 32 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Button__valid_type_options', |
|
| 33 | + [ |
|
| 34 | + Button::TYPE_BUTTON => esc_html__('Button', 'event_espresso'), |
|
| 35 | + Button::TYPE_BUTTON_RESET => esc_html__('Reset Button', 'event_espresso'), |
|
| 36 | + Button::TYPE_BUTTON_SUBMIT => esc_html__('Submit Button', 'event_espresso'), |
|
| 37 | + ] |
|
| 38 | + ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @param bool $constants_only |
|
| 44 | + * @return array |
|
| 45 | + */ |
|
| 46 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 47 | + { |
|
| 48 | + return $constants_only |
|
| 49 | + ? array_keys($this->valid_type_options) |
|
| 50 | + : $this->valid_type_options; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -5,81 +5,81 @@ |
||
| 5 | 5 | class DateTime |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the HTML input type is 'date' |
|
| 10 | - */ |
|
| 11 | - public const TYPE_DATE = 'date'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that the HTML input type is 'datetime-local' |
|
| 15 | - */ |
|
| 16 | - public const TYPE_DATETIME_LOCAL = 'datetime-local'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * indicates that the HTML input type is 'month' |
|
| 20 | - */ |
|
| 21 | - public const TYPE_MONTH = 'month'; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * indicates that the HTML input type is 'time' |
|
| 25 | - */ |
|
| 26 | - public const TYPE_TIME = 'time'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * indicates that the HTML input type is 'week' |
|
| 30 | - */ |
|
| 31 | - public const TYPE_WEEK = 'week'; |
|
| 32 | - |
|
| 33 | - // CUSTOM EE DATE TYPES |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * indicates that the input is an HTML dropdown used for selecting the day for a date |
|
| 37 | - */ |
|
| 38 | - public const TYPE_SELECT_DAY = 'day-select'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * indicates that the input is an HTML dropdown used for selecting the month for a date |
|
| 42 | - */ |
|
| 43 | - public const TYPE_SELECT_MONTH = 'month-select'; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * indicates that the input is an HTML dropdown used for selecting the year for a date |
|
| 47 | - */ |
|
| 48 | - public const TYPE_SELECT_YEAR = 'year-select'; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var array |
|
| 53 | - */ |
|
| 54 | - private $valid_type_options; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - public function __construct() |
|
| 58 | - { |
|
| 59 | - $this->valid_type_options = apply_filters( |
|
| 60 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_DateTime__valid_type_options', |
|
| 61 | - [ |
|
| 62 | - DateTime::TYPE_DATE => esc_html__('Date Picker', 'event_espresso'), |
|
| 63 | - DateTime::TYPE_DATETIME_LOCAL => esc_html__('Local Date Picker', 'event_espresso'), |
|
| 64 | - DateTime::TYPE_MONTH => esc_html__('Month Picker', 'event_espresso'), |
|
| 65 | - DateTime::TYPE_TIME => esc_html__('Time Picker', 'event_espresso'), |
|
| 66 | - DateTime::TYPE_WEEK => esc_html__('Week Picker', 'event_espresso'), |
|
| 67 | - DateTime::TYPE_SELECT_DAY => esc_html__('Day Selector', 'event_espresso'), |
|
| 68 | - DateTime::TYPE_SELECT_MONTH => esc_html__('Month Selector', 'event_espresso'), |
|
| 69 | - DateTime::TYPE_SELECT_YEAR => esc_html__('Year Selector', 'event_espresso'), |
|
| 70 | - ] |
|
| 71 | - ); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @param bool $constants_only |
|
| 77 | - * @return array |
|
| 78 | - */ |
|
| 79 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 80 | - { |
|
| 81 | - return $constants_only |
|
| 82 | - ? array_keys($this->valid_type_options) |
|
| 83 | - : $this->valid_type_options; |
|
| 84 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that the HTML input type is 'date' |
|
| 10 | + */ |
|
| 11 | + public const TYPE_DATE = 'date'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that the HTML input type is 'datetime-local' |
|
| 15 | + */ |
|
| 16 | + public const TYPE_DATETIME_LOCAL = 'datetime-local'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * indicates that the HTML input type is 'month' |
|
| 20 | + */ |
|
| 21 | + public const TYPE_MONTH = 'month'; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * indicates that the HTML input type is 'time' |
|
| 25 | + */ |
|
| 26 | + public const TYPE_TIME = 'time'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * indicates that the HTML input type is 'week' |
|
| 30 | + */ |
|
| 31 | + public const TYPE_WEEK = 'week'; |
|
| 32 | + |
|
| 33 | + // CUSTOM EE DATE TYPES |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * indicates that the input is an HTML dropdown used for selecting the day for a date |
|
| 37 | + */ |
|
| 38 | + public const TYPE_SELECT_DAY = 'day-select'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * indicates that the input is an HTML dropdown used for selecting the month for a date |
|
| 42 | + */ |
|
| 43 | + public const TYPE_SELECT_MONTH = 'month-select'; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * indicates that the input is an HTML dropdown used for selecting the year for a date |
|
| 47 | + */ |
|
| 48 | + public const TYPE_SELECT_YEAR = 'year-select'; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var array |
|
| 53 | + */ |
|
| 54 | + private $valid_type_options; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + public function __construct() |
|
| 58 | + { |
|
| 59 | + $this->valid_type_options = apply_filters( |
|
| 60 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_DateTime__valid_type_options', |
|
| 61 | + [ |
|
| 62 | + DateTime::TYPE_DATE => esc_html__('Date Picker', 'event_espresso'), |
|
| 63 | + DateTime::TYPE_DATETIME_LOCAL => esc_html__('Local Date Picker', 'event_espresso'), |
|
| 64 | + DateTime::TYPE_MONTH => esc_html__('Month Picker', 'event_espresso'), |
|
| 65 | + DateTime::TYPE_TIME => esc_html__('Time Picker', 'event_espresso'), |
|
| 66 | + DateTime::TYPE_WEEK => esc_html__('Week Picker', 'event_espresso'), |
|
| 67 | + DateTime::TYPE_SELECT_DAY => esc_html__('Day Selector', 'event_espresso'), |
|
| 68 | + DateTime::TYPE_SELECT_MONTH => esc_html__('Month Selector', 'event_espresso'), |
|
| 69 | + DateTime::TYPE_SELECT_YEAR => esc_html__('Year Selector', 'event_espresso'), |
|
| 70 | + ] |
|
| 71 | + ); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @param bool $constants_only |
|
| 77 | + * @return array |
|
| 78 | + */ |
|
| 79 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 80 | + { |
|
| 81 | + return $constants_only |
|
| 82 | + ? array_keys($this->valid_type_options) |
|
| 83 | + : $this->valid_type_options; |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -5,49 +5,49 @@ |
||
| 5 | 5 | class Number |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the HTML input type is 'number' whose value is a decimal (float) |
|
| 10 | - */ |
|
| 11 | - public const TYPE_FLOAT = 'decimal'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that the HTML input type is 'number' whose value is an integer (whole number) |
|
| 15 | - */ |
|
| 16 | - public const TYPE_INT = 'integer'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * indicates that the HTML input type is 'range' |
|
| 20 | - */ |
|
| 21 | - public const TYPE_RANGE = 'range'; |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - private $valid_type_options; |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - public function __construct() |
|
| 31 | - { |
|
| 32 | - $this->valid_type_options = apply_filters( |
|
| 33 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options', |
|
| 34 | - [ |
|
| 35 | - Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'), |
|
| 36 | - Number::TYPE_INT => esc_html__('Integer (Whole) Number', 'event_espresso'), |
|
| 37 | - Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'), |
|
| 38 | - ] |
|
| 39 | - ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @param bool $constants_only |
|
| 45 | - * @return array |
|
| 46 | - */ |
|
| 47 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 48 | - { |
|
| 49 | - return $constants_only |
|
| 50 | - ? array_keys($this->valid_type_options) |
|
| 51 | - : $this->valid_type_options; |
|
| 52 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that the HTML input type is 'number' whose value is a decimal (float) |
|
| 10 | + */ |
|
| 11 | + public const TYPE_FLOAT = 'decimal'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that the HTML input type is 'number' whose value is an integer (whole number) |
|
| 15 | + */ |
|
| 16 | + public const TYPE_INT = 'integer'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * indicates that the HTML input type is 'range' |
|
| 20 | + */ |
|
| 21 | + public const TYPE_RANGE = 'range'; |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + private $valid_type_options; |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + public function __construct() |
|
| 31 | + { |
|
| 32 | + $this->valid_type_options = apply_filters( |
|
| 33 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options', |
|
| 34 | + [ |
|
| 35 | + Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'), |
|
| 36 | + Number::TYPE_INT => esc_html__('Integer (Whole) Number', 'event_espresso'), |
|
| 37 | + Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'), |
|
| 38 | + ] |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param bool $constants_only |
|
| 45 | + * @return array |
|
| 46 | + */ |
|
| 47 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 48 | + { |
|
| 49 | + return $constants_only |
|
| 50 | + ? array_keys($this->valid_type_options) |
|
| 51 | + : $this->valid_type_options; |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -5,59 +5,59 @@ |
||
| 5 | 5 | class Select |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
| 10 | - */ |
|
| 11 | - public const TYPE_SELECT = 'select'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
| 15 | - */ |
|
| 16 | - public const TYPE_SELECT_MULTI = 'select-multi'; |
|
| 17 | - |
|
| 18 | - // CUSTOM EE SELECT TYPES |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * indicates that input is an HTML dropdown (select input) |
|
| 22 | - * populated with names of countries that are enabled for the site |
|
| 23 | - */ |
|
| 24 | - public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * indicates that the input is an HTML dropdown (select input) |
|
| 28 | - * populated with names of states for the countries that are enabled for the site |
|
| 29 | - */ |
|
| 30 | - public const TYPE_SELECT_STATE = 'select-state'; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - private $valid_type_options; |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - public function __construct() |
|
| 40 | - { |
|
| 41 | - $this->valid_type_options = apply_filters( |
|
| 42 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
| 43 | - [ |
|
| 44 | - Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
| 45 | - Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
| 46 | - Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
| 47 | - Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
| 48 | - ] |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param bool $constants_only |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 58 | - { |
|
| 59 | - return $constants_only |
|
| 60 | - ? array_keys($this->valid_type_options) |
|
| 61 | - : $this->valid_type_options; |
|
| 62 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
| 10 | + */ |
|
| 11 | + public const TYPE_SELECT = 'select'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
| 15 | + */ |
|
| 16 | + public const TYPE_SELECT_MULTI = 'select-multi'; |
|
| 17 | + |
|
| 18 | + // CUSTOM EE SELECT TYPES |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * indicates that input is an HTML dropdown (select input) |
|
| 22 | + * populated with names of countries that are enabled for the site |
|
| 23 | + */ |
|
| 24 | + public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * indicates that the input is an HTML dropdown (select input) |
|
| 28 | + * populated with names of states for the countries that are enabled for the site |
|
| 29 | + */ |
|
| 30 | + public const TYPE_SELECT_STATE = 'select-state'; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + private $valid_type_options; |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + public function __construct() |
|
| 40 | + { |
|
| 41 | + $this->valid_type_options = apply_filters( |
|
| 42 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
| 43 | + [ |
|
| 44 | + Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
| 45 | + Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
| 46 | + Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
| 47 | + Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
| 48 | + ] |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param bool $constants_only |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 58 | + { |
|
| 59 | + return $constants_only |
|
| 60 | + ? array_keys($this->valid_type_options) |
|
| 61 | + : $this->valid_type_options; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -5,109 +5,109 @@ |
||
| 5 | 5 | class Phone |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the HTML input type is 'tel' |
|
| 10 | - */ |
|
| 11 | - public const INPUT_TYPE = 'tel'; |
|
| 8 | + /** |
|
| 9 | + * indicates that the HTML input type is 'tel' |
|
| 10 | + */ |
|
| 11 | + public const INPUT_TYPE = 'tel'; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
| 15 | - * ########## |
|
| 16 | - * ###-###-#### |
|
| 17 | - * ### ### #### |
|
| 18 | - * (###)-###-#### |
|
| 19 | - * (###) ###-#### |
|
| 20 | - * |
|
| 21 | - * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
| 22 | - * +1 (###) ###-#### |
|
| 23 | - */ |
|
| 24 | - public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
| 13 | + /** |
|
| 14 | + * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
| 15 | + * ########## |
|
| 16 | + * ###-###-#### |
|
| 17 | + * ### ### #### |
|
| 18 | + * (###)-###-#### |
|
| 19 | + * (###) ###-#### |
|
| 20 | + * |
|
| 21 | + * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
| 22 | + * +1 (###) ###-#### |
|
| 23 | + */ |
|
| 24 | + public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
| 28 | - * (###) #### #### |
|
| 29 | - * (####) ### #### |
|
| 30 | - * (#####) ## #### |
|
| 31 | - * |
|
| 32 | - * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
| 33 | - * +44 (###) #### #### |
|
| 34 | - */ |
|
| 35 | - public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
| 26 | + /** |
|
| 27 | + * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
| 28 | + * (###) #### #### |
|
| 29 | + * (####) ### #### |
|
| 30 | + * (#####) ## #### |
|
| 31 | + * |
|
| 32 | + * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
| 33 | + * +44 (###) #### #### |
|
| 34 | + */ |
|
| 35 | + public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
| 39 | - * 0# ## ## ## ## |
|
| 40 | - * 0### ## ## ## |
|
| 41 | - * |
|
| 42 | - * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
| 43 | - * +33 # ## ## ## ## |
|
| 44 | - * 0033 # ## ## ## ## |
|
| 45 | - */ |
|
| 46 | - public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
| 37 | + /** |
|
| 38 | + * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
| 39 | + * 0# ## ## ## ## |
|
| 40 | + * 0### ## ## ## |
|
| 41 | + * |
|
| 42 | + * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
| 43 | + * +33 # ## ## ## ## |
|
| 44 | + * 0033 # ## ## ## ## |
|
| 45 | + */ |
|
| 46 | + public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
| 50 | - * (0##) ####-#### |
|
| 51 | - * (0###) ####-#### |
|
| 52 | - * (0####) ###-#### |
|
| 53 | - * (03####) ##-#### |
|
| 54 | - * |
|
| 55 | - * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
| 56 | - * +49 (0##) ####-#### |
|
| 57 | - */ |
|
| 58 | - public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
| 48 | + /** |
|
| 49 | + * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
| 50 | + * (0##) ####-#### |
|
| 51 | + * (0###) ####-#### |
|
| 52 | + * (0####) ###-#### |
|
| 53 | + * (03####) ##-#### |
|
| 54 | + * |
|
| 55 | + * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
| 56 | + * +49 (0##) ####-#### |
|
| 57 | + */ |
|
| 58 | + public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var array |
|
| 62 | - */ |
|
| 63 | - private $regex_patterns; |
|
| 60 | + /** |
|
| 61 | + * @var array |
|
| 62 | + */ |
|
| 63 | + private $regex_patterns; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 68 | - private $valid_type_options; |
|
| 65 | + /** |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | + private $valid_type_options; |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Phone constructor. |
|
| 73 | - */ |
|
| 74 | - public function __construct() |
|
| 75 | - { |
|
| 76 | - $this->regex_patterns = (array) apply_filters( |
|
| 77 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
| 78 | - [ |
|
| 79 | - 'de_DE' => Phone::PATTERN_DE, |
|
| 80 | - 'fr_FR' => Phone::PATTERN_FR, |
|
| 81 | - 'en_UK' => Phone::PATTERN_UK, |
|
| 82 | - 'en_US' => Phone::PATTERN_US, |
|
| 83 | - ] |
|
| 84 | - ); |
|
| 85 | - $this->valid_type_options = apply_filters( |
|
| 86 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
| 87 | - [ |
|
| 88 | - Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
| 89 | - ] |
|
| 90 | - ); |
|
| 91 | - } |
|
| 71 | + /** |
|
| 72 | + * Phone constructor. |
|
| 73 | + */ |
|
| 74 | + public function __construct() |
|
| 75 | + { |
|
| 76 | + $this->regex_patterns = (array) apply_filters( |
|
| 77 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
| 78 | + [ |
|
| 79 | + 'de_DE' => Phone::PATTERN_DE, |
|
| 80 | + 'fr_FR' => Phone::PATTERN_FR, |
|
| 81 | + 'en_UK' => Phone::PATTERN_UK, |
|
| 82 | + 'en_US' => Phone::PATTERN_US, |
|
| 83 | + ] |
|
| 84 | + ); |
|
| 85 | + $this->valid_type_options = apply_filters( |
|
| 86 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
| 87 | + [ |
|
| 88 | + Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
| 89 | + ] |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return array |
|
| 96 | - */ |
|
| 97 | - public function regexPatterns(): array |
|
| 98 | - { |
|
| 99 | - return $this->regex_patterns; |
|
| 100 | - } |
|
| 94 | + /** |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | + public function regexPatterns(): array |
|
| 98 | + { |
|
| 99 | + return $this->regex_patterns; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param bool $constants_only |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | - { |
|
| 109 | - return $constants_only |
|
| 110 | - ? array_keys($this->valid_type_options) |
|
| 111 | - : $this->valid_type_options; |
|
| 112 | - } |
|
| 103 | + /** |
|
| 104 | + * @param bool $constants_only |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | + { |
|
| 109 | + return $constants_only |
|
| 110 | + ? array_keys($this->valid_type_options) |
|
| 111 | + : $this->valid_type_options; |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | public function __construct() |
| 75 | 75 | { |
| 76 | - $this->regex_patterns = (array) apply_filters( |
|
| 76 | + $this->regex_patterns = (array) apply_filters( |
|
| 77 | 77 | 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
| 78 | 78 | [ |
| 79 | 79 | 'de_DE' => Phone::PATTERN_DE, |