Completed
Branch new-addon-api (b7bde0)
by
unknown
18:29 queued 08:41
created
core/libraries/plugin_api/EE_Register_Privacy_Policy.lib.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
13 13
 class EE_Register_Privacy_Policy implements EEI_Plugin_API
14 14
 {
15 15
 
16
-    /**
17
-     * FQCN for all privacy policy generators
18
-     *
19
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
-     */
21
-    protected static $privacy_policies = [];
16
+	/**
17
+	 * FQCN for all privacy policy generators
18
+	 *
19
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
+	 */
21
+	protected static $privacy_policies = [];
22 22
 
23 23
 
24
-    /*
24
+	/*
25 25
      * @param string $plugin_id
26 26
      * @param array $FQNSs can be the fully qualified namespaces each containing only privacy policies,
27 27
      *              OR fully qualified class names of privacy policies
28 28
      */
29
-    public static function register(string $plugin_id = '', array $FQCNs = []): bool
30
-    {
31
-        self::$privacy_policies[ $plugin_id ] = $FQCNs;
32
-        // add to list of modules to be registered
33
-        add_filter(
34
-            'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
35
-            ['EE_Register_Privacy_Policy', 'addPrivacyPolicies']
36
-        );
37
-        return true;
38
-    }
39
-
40
-
41
-    /**
42
-     * @param string $ID
43
-     */
44
-    public static function deregister(string $ID = '')
45
-    {
46
-        unset(self::$privacy_policies[ $ID ]);
47
-    }
48
-
49
-
50
-    /**
51
-     * Adds our privacy policy generators registered by add-ons
52
-     *
53
-     * @param string[] $privacy_policies
54
-     * @return string[]
55
-     */
56
-    public static function addPrivacyPolicies(array $privacy_policies): array
57
-    {
58
-        return array_merge($privacy_policies, ...self::$privacy_policies);
59
-    }
29
+	public static function register(string $plugin_id = '', array $FQCNs = []): bool
30
+	{
31
+		self::$privacy_policies[ $plugin_id ] = $FQCNs;
32
+		// add to list of modules to be registered
33
+		add_filter(
34
+			'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
35
+			['EE_Register_Privacy_Policy', 'addPrivacyPolicies']
36
+		);
37
+		return true;
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param string $ID
43
+	 */
44
+	public static function deregister(string $ID = '')
45
+	{
46
+		unset(self::$privacy_policies[ $ID ]);
47
+	}
48
+
49
+
50
+	/**
51
+	 * Adds our privacy policy generators registered by add-ons
52
+	 *
53
+	 * @param string[] $privacy_policies
54
+	 * @return string[]
55
+	 */
56
+	public static function addPrivacyPolicies(array $privacy_policies): array
57
+	{
58
+		return array_merge($privacy_policies, ...self::$privacy_policies);
59
+	}
60 60
 }
61 61
 // End of file EE_Register_Privacy_Policy.lib.php
62 62
 // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public static function register(string $plugin_id = '', array $FQCNs = []): bool
30 30
     {
31
-        self::$privacy_policies[ $plugin_id ] = $FQCNs;
31
+        self::$privacy_policies[$plugin_id] = $FQCNs;
32 32
         // add to list of modules to be registered
33 33
         add_filter(
34 34
             'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public static function deregister(string $ID = '')
45 45
     {
46
-        unset(self::$privacy_policies[ $ID ]);
46
+        unset(self::$privacy_policies[$ID]);
47 47
     }
48 48
 
49 49
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Model_Extensions.lib.php 2 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -12,134 +12,134 @@
 block discarded – undo
12 12
 class EE_Register_Model_Extensions implements EEI_Plugin_API
13 13
 {
14 14
 
15
-    protected static $_registry;
15
+	protected static $_registry;
16 16
 
17
-    protected static $_extensions = [];
17
+	protected static $_extensions = [];
18 18
 
19 19
 
20
-    /**
21
-     * register method for setting up model extensions
22
-     *
23
-     * @param string $model_id              unique id for the extensions being setup
24
-     * @param array  $config                {
25
-     * @return bool
26
-     * @throws EE_Error
27
-     * @type  array  $model_extension_paths array of folders containing DB model extensions, where each file follows
28
-     *                                      the models naming convention, which is:
29
-     *                                      EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where
30
-     *                                      your_plugin_slug} is really anything you want (but something having to do
31
-     *                                      with your addon, like
32
-     *                                      'Calendar' or '3D_View') and model_name_extended} is the model extended.
33
-     *                                      The class contained in teh file should extend
34
-     *                                      EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is
35
-     *                                      really anything you want (but something having to do with your addon, like
36
-     *                                      'Calendar' or '3D_View') and
37
-     *                                      {model_name_extended} is the model extended. The class contained in teh
38
-     *                                      file should extend EEME_Base
39
-     * @type array   $class_extension_paths array of folders containing DB class extensions, where each file follows
40
-     *                                      the model class extension naming convention, which is:
41
-     *                                      EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where
42
-     *                                      your_plugin_slug} is something like
43
-     *                                      'Calendar','MailChimp',etc, and model_name_extended} is the name of the
44
-     *                                      model extended, eg
45
-     *                                      'Attendee','Event',etc. The class contained in the file should extend
46
-     *                                      EEE_Base_Class._{model_name_extended}.class_ext.php. Where
47
-     *                                      {your_plugin_slug} is something like
48
-     *                                      'Calendar','MailChimp',etc, and {model_name_extended} is the name of the
49
-     *                                      model extended, eg
50
-     *                                      'Attendee','Event',etc. The class contained in the file should extend
51
-     *                                      EEE_Base_Class.
52
-     *                                      }
53
-     *
54
-     */
55
-    public static function register(string $model_id = '', array $config = []): bool
56
-    {
57
-        // required fields MUST be present, so let's make sure they are.
58
-        if (empty($model_id)
59
-            || ! is_array($config)
60
-            || (empty($config['model_extension_paths']) && empty($config['class_extension_paths']))
61
-        ) {
62
-            throw new EE_Error(
63
-                __(
64
-                    'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)',
65
-                    'event_espresso'
66
-                )
67
-            );
68
-        }
20
+	/**
21
+	 * register method for setting up model extensions
22
+	 *
23
+	 * @param string $model_id              unique id for the extensions being setup
24
+	 * @param array  $config                {
25
+	 * @return bool
26
+	 * @throws EE_Error
27
+	 * @type  array  $model_extension_paths array of folders containing DB model extensions, where each file follows
28
+	 *                                      the models naming convention, which is:
29
+	 *                                      EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where
30
+	 *                                      your_plugin_slug} is really anything you want (but something having to do
31
+	 *                                      with your addon, like
32
+	 *                                      'Calendar' or '3D_View') and model_name_extended} is the model extended.
33
+	 *                                      The class contained in teh file should extend
34
+	 *                                      EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is
35
+	 *                                      really anything you want (but something having to do with your addon, like
36
+	 *                                      'Calendar' or '3D_View') and
37
+	 *                                      {model_name_extended} is the model extended. The class contained in teh
38
+	 *                                      file should extend EEME_Base
39
+	 * @type array   $class_extension_paths array of folders containing DB class extensions, where each file follows
40
+	 *                                      the model class extension naming convention, which is:
41
+	 *                                      EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where
42
+	 *                                      your_plugin_slug} is something like
43
+	 *                                      'Calendar','MailChimp',etc, and model_name_extended} is the name of the
44
+	 *                                      model extended, eg
45
+	 *                                      'Attendee','Event',etc. The class contained in the file should extend
46
+	 *                                      EEE_Base_Class._{model_name_extended}.class_ext.php. Where
47
+	 *                                      {your_plugin_slug} is something like
48
+	 *                                      'Calendar','MailChimp',etc, and {model_name_extended} is the name of the
49
+	 *                                      model extended, eg
50
+	 *                                      'Attendee','Event',etc. The class contained in the file should extend
51
+	 *                                      EEE_Base_Class.
52
+	 *                                      }
53
+	 *
54
+	 */
55
+	public static function register(string $model_id = '', array $config = []): bool
56
+	{
57
+		// required fields MUST be present, so let's make sure they are.
58
+		if (empty($model_id)
59
+			|| ! is_array($config)
60
+			|| (empty($config['model_extension_paths']) && empty($config['class_extension_paths']))
61
+		) {
62
+			throw new EE_Error(
63
+				__(
64
+					'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)',
65
+					'event_espresso'
66
+				)
67
+			);
68
+		}
69 69
 
70
-        // make sure we don't register twice
71
-        if (isset(self::$_registry[ $model_id ])) {
72
-            return true;
73
-        }
74
-        // check correct loading
75
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
76
-            EE_Error::doing_it_wrong(
77
-                __METHOD__,
78
-                sprintf(
79
-                    __(
80
-                        'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s',
81
-                        'event_espresso'
82
-                    ),
83
-                    $model_id,
84
-                    '<br />',
85
-                    did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done',
86
-                    did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done'
87
-                ),
88
-                '4.3'
89
-            );
90
-        }
70
+		// make sure we don't register twice
71
+		if (isset(self::$_registry[ $model_id ])) {
72
+			return true;
73
+		}
74
+		// check correct loading
75
+		if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
76
+			EE_Error::doing_it_wrong(
77
+				__METHOD__,
78
+				sprintf(
79
+					__(
80
+						'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s',
81
+						'event_espresso'
82
+					),
83
+					$model_id,
84
+					'<br />',
85
+					did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done',
86
+					did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done'
87
+				),
88
+				'4.3'
89
+			);
90
+		}
91 91
 
92
-        self::$_registry[ $model_id ]   = $config;
93
-        self::$_extensions[ $model_id ] = [];
92
+		self::$_registry[ $model_id ]   = $config;
93
+		self::$_extensions[ $model_id ] = [];
94 94
 
95
-        if (isset($config['model_extension_paths'])) {
96
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
97
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
98
-            // remove all files that are not PHP
99
-            foreach ($class_to_filepath_map as $class => $path) {
100
-                if (substr($path, strlen($path) - 3) !== 'php') {
101
-                    unset($class_to_filepath_map[ $class ]);
102
-                    continue;
103
-                }
104
-            }
105
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
106
-            foreach (array_keys($class_to_filepath_map) as $classname) {
107
-                self::$_extensions[ $model_id ]['models'][ $classname ] = new $classname;
108
-            }
109
-            unset($config['model_extension_paths']);
110
-        }
111
-        if (isset($config['class_extension_paths'])) {
112
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
113
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
114
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
115
-            foreach (array_keys($class_to_filepath_map) as $classname) {
116
-                self::$_extensions[ $model_id ]['classes'][ $classname ] = new $classname;
117
-            }
118
-            unset($config['class_extension_paths']);
119
-        }
120
-        foreach ($config as $unknown_key => $unknown_config) {
121
-            throw new EE_Error(
122
-                sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
123
-            );
124
-        }
125
-        return true;
126
-    }
95
+		if (isset($config['model_extension_paths'])) {
96
+			require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
97
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
98
+			// remove all files that are not PHP
99
+			foreach ($class_to_filepath_map as $class => $path) {
100
+				if (substr($path, strlen($path) - 3) !== 'php') {
101
+					unset($class_to_filepath_map[ $class ]);
102
+					continue;
103
+				}
104
+			}
105
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
106
+			foreach (array_keys($class_to_filepath_map) as $classname) {
107
+				self::$_extensions[ $model_id ]['models'][ $classname ] = new $classname;
108
+			}
109
+			unset($config['model_extension_paths']);
110
+		}
111
+		if (isset($config['class_extension_paths'])) {
112
+			require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
113
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
114
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
115
+			foreach (array_keys($class_to_filepath_map) as $classname) {
116
+				self::$_extensions[ $model_id ]['classes'][ $classname ] = new $classname;
117
+			}
118
+			unset($config['class_extension_paths']);
119
+		}
120
+		foreach ($config as $unknown_key => $unknown_config) {
121
+			throw new EE_Error(
122
+				sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
123
+			);
124
+		}
125
+		return true;
126
+	}
127 127
 
128 128
 
129
-    /**
130
-     * deregister
131
-     *
132
-     * @param string $model_id
133
-     */
134
-    public static function deregister(string $model_id = '')
135
-    {
136
-        if (isset(self::$_registry[ $model_id ])) {
137
-            unset(self::$_registry[ $model_id ]);
138
-            foreach (self::$_extensions[ $model_id ] as $extension_of_type) {
139
-                foreach ($extension_of_type as $extension) {
140
-                    $extension->deregister();
141
-                }
142
-            }
143
-        }
144
-    }
129
+	/**
130
+	 * deregister
131
+	 *
132
+	 * @param string $model_id
133
+	 */
134
+	public static function deregister(string $model_id = '')
135
+	{
136
+		if (isset(self::$_registry[ $model_id ])) {
137
+			unset(self::$_registry[ $model_id ]);
138
+			foreach (self::$_extensions[ $model_id ] as $extension_of_type) {
139
+				foreach ($extension_of_type as $extension) {
140
+					$extension->deregister();
141
+				}
142
+			}
143
+		}
144
+	}
145 145
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
         }
69 69
 
70 70
         // make sure we don't register twice
71
-        if (isset(self::$_registry[ $model_id ])) {
71
+        if (isset(self::$_registry[$model_id])) {
72 72
             return true;
73 73
         }
74 74
         // check correct loading
75
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
75
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
76 76
             EE_Error::doing_it_wrong(
77 77
                 __METHOD__,
78 78
                 sprintf(
@@ -89,31 +89,31 @@  discard block
 block discarded – undo
89 89
             );
90 90
         }
91 91
 
92
-        self::$_registry[ $model_id ]   = $config;
93
-        self::$_extensions[ $model_id ] = [];
92
+        self::$_registry[$model_id]   = $config;
93
+        self::$_extensions[$model_id] = [];
94 94
 
95 95
         if (isset($config['model_extension_paths'])) {
96
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
96
+            require_once(EE_LIBRARIES.'plugin_api/db/EEME_Base.lib.php');
97 97
             $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
98 98
             // remove all files that are not PHP
99 99
             foreach ($class_to_filepath_map as $class => $path) {
100 100
                 if (substr($path, strlen($path) - 3) !== 'php') {
101
-                    unset($class_to_filepath_map[ $class ]);
101
+                    unset($class_to_filepath_map[$class]);
102 102
                     continue;
103 103
                 }
104 104
             }
105 105
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
106 106
             foreach (array_keys($class_to_filepath_map) as $classname) {
107
-                self::$_extensions[ $model_id ]['models'][ $classname ] = new $classname;
107
+                self::$_extensions[$model_id]['models'][$classname] = new $classname;
108 108
             }
109 109
             unset($config['model_extension_paths']);
110 110
         }
111 111
         if (isset($config['class_extension_paths'])) {
112
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
112
+            require_once(EE_LIBRARIES.'plugin_api/db/EEE_Base_Class.lib.php');
113 113
             $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
114 114
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
115 115
             foreach (array_keys($class_to_filepath_map) as $classname) {
116
-                self::$_extensions[ $model_id ]['classes'][ $classname ] = new $classname;
116
+                self::$_extensions[$model_id]['classes'][$classname] = new $classname;
117 117
             }
118 118
             unset($config['class_extension_paths']);
119 119
         }
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public static function deregister(string $model_id = '')
135 135
     {
136
-        if (isset(self::$_registry[ $model_id ])) {
137
-            unset(self::$_registry[ $model_id ]);
138
-            foreach (self::$_extensions[ $model_id ] as $extension_of_type) {
136
+        if (isset(self::$_registry[$model_id])) {
137
+            unset(self::$_registry[$model_id]);
138
+            foreach (self::$_extensions[$model_id] as $extension_of_type) {
139 139
                 foreach ($extension_of_type as $extension) {
140 140
                     $extension->deregister();
141 141
                 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Capabilities.lib.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -15,210 +15,210 @@
 block discarded – undo
15 15
 class EE_Register_Capabilities implements EEI_Plugin_API
16 16
 {
17 17
 
18
-    /**
19
-     * Holds the settings for a specific registration.
20
-     *
21
-     * @var array
22
-     */
23
-    protected static $_registry = [];
18
+	/**
19
+	 * Holds the settings for a specific registration.
20
+	 *
21
+	 * @var array
22
+	 */
23
+	protected static $_registry = [];
24 24
 
25 25
 
26
-    /**
27
-     * Used to register capability items with EE core.
28
-     *
29
-     * @param string $cap_reference     usually will be a class name that references capability
30
-     *                                  related items setup for something.
31
-     * @param array  $setup_args        An array of items related to registering capabilities.
32
-     *      @type array   $capabilities     An array mapping capability strings to core WP Role.
33
-     *                                      Something like: array(
34
-     *                                          'administrator'    => array(
35
-     *                                              'read_cap', 'edit_cap',
36
-     *                                              'delete_cap'
37
-     *                                          ),
38
-     *                                          'author' => array( 'read_cap' )
39
-     *                                      ).
40
-     *      @type array   $capability_maps EE_Meta_Capability_Map[]
41
-     * @return boolean|null
42
-     * @throws EE_Error
43
-     * @since 4.5.0
44
-     * @see EE_Capabilities.php for php docs on these objects.
45
-     *                          Should be indexed by the classname for the capability
46
-     *                          map and values representing the arguments for the map.
47
-     */
48
-    public static function register(string $cap_reference = '', array $setup_args = []): bool
49
-    {
50
-        // required fields MUST be present, so let's make sure they are.
51
-        if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) {
52
-            throw new EE_Error(
53
-                __(
54
-                    'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".',
55
-                    'event_espresso'
56
-                )
57
-            );
58
-        }
59
-        // make sure we don't register twice
60
-        if (isset(self::$_registry[ $cap_reference ])) {
61
-            return true;
62
-        }
63
-        // make sure this is not registered too late or too early.
64
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
65
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
66
-        ) {
67
-            EE_Error::doing_it_wrong(
68
-                __METHOD__,
69
-                sprintf(
70
-                    __(
71
-                        '%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.',
72
-                        'event_espresso'
73
-                    ),
74
-                    $cap_reference
75
-                ),
76
-                '4.5.0'
77
-            );
78
-            return false;
79
-        }
80
-        // some preliminary sanitization and setting to the $_registry property
81
-        self::$_registry[ $cap_reference ] = [
82
-            'caps'     => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83
-                ? $setup_args['capabilities']
84
-                : [],
85
-            'cap_maps' => isset($setup_args['capability_maps'])
86
-                ? $setup_args['capability_maps']
87
-                : [],
88
-        ];
89
-        // set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once)
90
-        add_filter(
91
-            'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
92
-            ['EE_Register_Capabilities', 'register_capabilities']
93
-        );
94
-        // add filter for cap maps
95
-        add_filter(
96
-            'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
97
-            ['EE_Register_Capabilities', 'register_cap_maps']
98
-        );
99
-        return true;
100
-    }
26
+	/**
27
+	 * Used to register capability items with EE core.
28
+	 *
29
+	 * @param string $cap_reference     usually will be a class name that references capability
30
+	 *                                  related items setup for something.
31
+	 * @param array  $setup_args        An array of items related to registering capabilities.
32
+	 *      @type array   $capabilities     An array mapping capability strings to core WP Role.
33
+	 *                                      Something like: array(
34
+	 *                                          'administrator'    => array(
35
+	 *                                              'read_cap', 'edit_cap',
36
+	 *                                              'delete_cap'
37
+	 *                                          ),
38
+	 *                                          'author' => array( 'read_cap' )
39
+	 *                                      ).
40
+	 *      @type array   $capability_maps EE_Meta_Capability_Map[]
41
+	 * @return boolean|null
42
+	 * @throws EE_Error
43
+	 * @since 4.5.0
44
+	 * @see EE_Capabilities.php for php docs on these objects.
45
+	 *                          Should be indexed by the classname for the capability
46
+	 *                          map and values representing the arguments for the map.
47
+	 */
48
+	public static function register(string $cap_reference = '', array $setup_args = []): bool
49
+	{
50
+		// required fields MUST be present, so let's make sure they are.
51
+		if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) {
52
+			throw new EE_Error(
53
+				__(
54
+					'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".',
55
+					'event_espresso'
56
+				)
57
+			);
58
+		}
59
+		// make sure we don't register twice
60
+		if (isset(self::$_registry[ $cap_reference ])) {
61
+			return true;
62
+		}
63
+		// make sure this is not registered too late or too early.
64
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
65
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
66
+		) {
67
+			EE_Error::doing_it_wrong(
68
+				__METHOD__,
69
+				sprintf(
70
+					__(
71
+						'%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.',
72
+						'event_espresso'
73
+					),
74
+					$cap_reference
75
+				),
76
+				'4.5.0'
77
+			);
78
+			return false;
79
+		}
80
+		// some preliminary sanitization and setting to the $_registry property
81
+		self::$_registry[ $cap_reference ] = [
82
+			'caps'     => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83
+				? $setup_args['capabilities']
84
+				: [],
85
+			'cap_maps' => isset($setup_args['capability_maps'])
86
+				? $setup_args['capability_maps']
87
+				: [],
88
+		];
89
+		// set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once)
90
+		add_filter(
91
+			'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
92
+			['EE_Register_Capabilities', 'register_capabilities']
93
+		);
94
+		// add filter for cap maps
95
+		add_filter(
96
+			'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
97
+			['EE_Register_Capabilities', 'register_cap_maps']
98
+		);
99
+		return true;
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * callback for FHEE__EE_Capabilities__init_caps_map__caps filter.
105
-     * Takes care of registering additional capabilities to the caps map.   Note, that this also on the initial
106
-     * registration ensures that new capabilities are added to existing roles.
107
-     *
108
-     * @param array $incoming_caps The original caps map.
109
-     * @return array merged in new caps.
110
-     */
111
-    public static function register_capabilities(array $incoming_caps): array
112
-    {
113
-        $caps = [];
114
-        foreach (self::$_registry as $cap_reference => $caps_and_cap_map) {
115
-            $caps[] = $caps_and_cap_map['caps'];
116
-        }
117
-        return array_merge_recursive($incoming_caps, ...$caps);
118
-    }
103
+	/**
104
+	 * callback for FHEE__EE_Capabilities__init_caps_map__caps filter.
105
+	 * Takes care of registering additional capabilities to the caps map.   Note, that this also on the initial
106
+	 * registration ensures that new capabilities are added to existing roles.
107
+	 *
108
+	 * @param array $incoming_caps The original caps map.
109
+	 * @return array merged in new caps.
110
+	 */
111
+	public static function register_capabilities(array $incoming_caps): array
112
+	{
113
+		$caps = [];
114
+		foreach (self::$_registry as $cap_reference => $caps_and_cap_map) {
115
+			$caps[] = $caps_and_cap_map['caps'];
116
+		}
117
+		return array_merge_recursive($incoming_caps, ...$caps);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of
123
-     * capability maps for the WP meta_caps filter called in EE_Capabilities.
124
-     *
125
-     * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array.
126
-     * @return EE_Meta_Capability_Map[]
127
-     * @throws EE_Error
128
-     * @since 4.5.0
129
-     */
130
-    public static function register_cap_maps(array $cap_maps): array
131
-    {
132
-        // loop through and instantiate cap maps.
133
-        foreach (self::$_registry as $cap_reference => $setup) {
134
-            if (! isset($setup['cap_maps'])) {
135
-                continue;
136
-            }
137
-            foreach ($setup['cap_maps'] as $cap_class => $args) {
121
+	/**
122
+	 * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of
123
+	 * capability maps for the WP meta_caps filter called in EE_Capabilities.
124
+	 *
125
+	 * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array.
126
+	 * @return EE_Meta_Capability_Map[]
127
+	 * @throws EE_Error
128
+	 * @since 4.5.0
129
+	 */
130
+	public static function register_cap_maps(array $cap_maps): array
131
+	{
132
+		// loop through and instantiate cap maps.
133
+		foreach (self::$_registry as $cap_reference => $setup) {
134
+			if (! isset($setup['cap_maps'])) {
135
+				continue;
136
+			}
137
+			foreach ($setup['cap_maps'] as $cap_class => $args) {
138 138
 
139
-                /**
140
-                 * account for cases where capability maps may be indexed
141
-                 * numerically to allow for the same map class to be utilized
142
-                 * In those cases, maps will be setup in an array like:
143
-                 * array(
144
-                 *    0 => array( 'EE_Meta_Capability' => array(
145
-                 *        'ee_edit_cap', array( 'Object_Name',
146
-                 *        'ee_edit_published_cap',
147
-                 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
148
-                 *        ) )
149
-                 *    1 => ...
150
-                 * )
151
-                 * instead of:
152
-                 * array(
153
-                 *    'EE_Meta_Capability' => array(
154
-                 *        'ee_edit_cap', array( 'Object_Name',
155
-                 *        'ee_edit_published_cap',
156
-                 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
157
-                 *        ),
158
-                 *    ...
159
-                 * )
160
-                 */
161
-                if (is_numeric($cap_class)) {
162
-                    $cap_class = key($args);
163
-                    $args      = $args[ $cap_class ];
164
-                }
139
+				/**
140
+				 * account for cases where capability maps may be indexed
141
+				 * numerically to allow for the same map class to be utilized
142
+				 * In those cases, maps will be setup in an array like:
143
+				 * array(
144
+				 *    0 => array( 'EE_Meta_Capability' => array(
145
+				 *        'ee_edit_cap', array( 'Object_Name',
146
+				 *        'ee_edit_published_cap',
147
+				 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
148
+				 *        ) )
149
+				 *    1 => ...
150
+				 * )
151
+				 * instead of:
152
+				 * array(
153
+				 *    'EE_Meta_Capability' => array(
154
+				 *        'ee_edit_cap', array( 'Object_Name',
155
+				 *        'ee_edit_published_cap',
156
+				 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
157
+				 *        ),
158
+				 *    ...
159
+				 * )
160
+				 */
161
+				if (is_numeric($cap_class)) {
162
+					$cap_class = key($args);
163
+					$args      = $args[ $cap_class ];
164
+				}
165 165
 
166
-                if (! class_exists($cap_class)) {
167
-                    throw new EE_Error(
168
-                        sprintf(
169
-                            __(
170
-                                'An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments',
171
-                                'event_espresso'
172
-                            ),
173
-                            $cap_reference
174
-                        )
175
-                    );
176
-                }
166
+				if (! class_exists($cap_class)) {
167
+					throw new EE_Error(
168
+						sprintf(
169
+							__(
170
+								'An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments',
171
+								'event_espresso'
172
+							),
173
+							$cap_reference
174
+						)
175
+					);
176
+				}
177 177
 
178
-                if (count($args) !== 2) {
179
-                    throw new EE_Error(
180
-                        sprintf(
181
-                            __(
182
-                                'An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.',
183
-                                'event_espresso'
184
-                            ),
185
-                            $cap_reference
186
-                        )
187
-                    );
188
-                }
189
-                $cap_maps[] = new $cap_class($args[0], $args[1]);
190
-            }
191
-        }
192
-        return $cap_maps;
193
-    }
178
+				if (count($args) !== 2) {
179
+					throw new EE_Error(
180
+						sprintf(
181
+							__(
182
+								'An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.',
183
+								'event_espresso'
184
+							),
185
+							$cap_reference
186
+						)
187
+					);
188
+				}
189
+				$cap_maps[] = new $cap_class($args[0], $args[1]);
190
+			}
191
+		}
192
+		return $cap_maps;
193
+	}
194 194
 
195 195
 
196
-    /**
197
-     * @param string $cap_reference
198
-     * @throws InvalidArgumentException
199
-     * @throws InvalidDataTypeException
200
-     * @throws InvalidInterfaceException
201
-     */
202
-    public static function deregister(string $cap_reference = '')
203
-    {
204
-        if (! empty(self::$_registry[ $cap_reference ])) {
205
-            if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
206
-                // if it's too early to remove capabilities, wait to do this until core is loaded and ready
207
-                $caps_to_remove = self::$_registry[ $cap_reference ]['caps'];
208
-                if (did_action('AHEE__EE_System__core_loaded_and_ready')) {
209
-                    $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
210
-                    $capabilities->removeCaps($caps_to_remove);
211
-                } else {
212
-                    add_action(
213
-                        'AHEE__EE_System__core_loaded_and_ready',
214
-                        function () use ($caps_to_remove) {
215
-                            $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
216
-                            $capabilities->removeCaps($caps_to_remove);
217
-                        }
218
-                    );
219
-                }
220
-            }
221
-            unset(self::$_registry[ $cap_reference ]);
222
-        }
223
-    }
196
+	/**
197
+	 * @param string $cap_reference
198
+	 * @throws InvalidArgumentException
199
+	 * @throws InvalidDataTypeException
200
+	 * @throws InvalidInterfaceException
201
+	 */
202
+	public static function deregister(string $cap_reference = '')
203
+	{
204
+		if (! empty(self::$_registry[ $cap_reference ])) {
205
+			if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
206
+				// if it's too early to remove capabilities, wait to do this until core is loaded and ready
207
+				$caps_to_remove = self::$_registry[ $cap_reference ]['caps'];
208
+				if (did_action('AHEE__EE_System__core_loaded_and_ready')) {
209
+					$capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
210
+					$capabilities->removeCaps($caps_to_remove);
211
+				} else {
212
+					add_action(
213
+						'AHEE__EE_System__core_loaded_and_ready',
214
+						function () use ($caps_to_remove) {
215
+							$capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
216
+							$capabilities->removeCaps($caps_to_remove);
217
+						}
218
+					);
219
+				}
220
+			}
221
+			unset(self::$_registry[ $cap_reference ]);
222
+		}
223
+	}
224 224
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
             );
58 58
         }
59 59
         // make sure we don't register twice
60
-        if (isset(self::$_registry[ $cap_reference ])) {
60
+        if (isset(self::$_registry[$cap_reference])) {
61 61
             return true;
62 62
         }
63 63
         // make sure this is not registered too late or too early.
64
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
64
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
65 65
             || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
66 66
         ) {
67 67
             EE_Error::doing_it_wrong(
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             return false;
79 79
         }
80 80
         // some preliminary sanitization and setting to the $_registry property
81
-        self::$_registry[ $cap_reference ] = [
81
+        self::$_registry[$cap_reference] = [
82 82
             'caps'     => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83 83
                 ? $setup_args['capabilities']
84 84
                 : [],
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         // loop through and instantiate cap maps.
133 133
         foreach (self::$_registry as $cap_reference => $setup) {
134
-            if (! isset($setup['cap_maps'])) {
134
+            if ( ! isset($setup['cap_maps'])) {
135 135
                 continue;
136 136
             }
137 137
             foreach ($setup['cap_maps'] as $cap_class => $args) {
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
                  */
161 161
                 if (is_numeric($cap_class)) {
162 162
                     $cap_class = key($args);
163
-                    $args      = $args[ $cap_class ];
163
+                    $args      = $args[$cap_class];
164 164
                 }
165 165
 
166
-                if (! class_exists($cap_class)) {
166
+                if ( ! class_exists($cap_class)) {
167 167
                     throw new EE_Error(
168 168
                         sprintf(
169 169
                             __(
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public static function deregister(string $cap_reference = '')
203 203
     {
204
-        if (! empty(self::$_registry[ $cap_reference ])) {
205
-            if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
204
+        if ( ! empty(self::$_registry[$cap_reference])) {
205
+            if ( ! empty(self::$_registry[$cap_reference]['caps'])) {
206 206
                 // if it's too early to remove capabilities, wait to do this until core is loaded and ready
207
-                $caps_to_remove = self::$_registry[ $cap_reference ]['caps'];
207
+                $caps_to_remove = self::$_registry[$cap_reference]['caps'];
208 208
                 if (did_action('AHEE__EE_System__core_loaded_and_ready')) {
209 209
                     $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
210 210
                     $capabilities->removeCaps($caps_to_remove);
211 211
                 } else {
212 212
                     add_action(
213 213
                         'AHEE__EE_System__core_loaded_and_ready',
214
-                        function () use ($caps_to_remove) {
214
+                        function() use ($caps_to_remove) {
215 215
                             $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities');
216 216
                             $capabilities->removeCaps($caps_to_remove);
217 217
                         }
218 218
                     );
219 219
                 }
220 220
             }
221
-            unset(self::$_registry[ $cap_reference ]);
221
+            unset(self::$_registry[$cap_reference]);
222 222
         }
223 223
     }
224 224
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Config.lib.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -12,114 +12,114 @@
 block discarded – undo
12 12
 class EE_Register_Config implements EEI_Plugin_API
13 13
 {
14 14
 
15
-    /**
16
-     * Holds registered EE_Config items
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_ee_config_registry = [];
15
+	/**
16
+	 * Holds registered EE_Config items
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_ee_config_registry = [];
21 21
 
22 22
 
23
-    /**
24
-     * Handles registering the new config with the EE_Config::instance()->addons property
25
-     *
26
-     * @param string $config_class                        The name of the Config class being registered.
27
-     *                                                    Note this class must extend EE_Config Base and must have
28
-     *                                                    already been registered with an autoloader.
29
-     * @param array  $setup_args                          {
30
-     *
31
-     * @type  string $config_name                         Optional.  by default the new config will be registered to
32
-     *        EE_Config::instance()->addons->{config_class}, but supplying a "config_name" will set the property name
33
-     *        that this variable is accessible by. ie: EE_Config::instance()->addons->{config_name}
34
-     *                            }
35
-     * @return bool
36
-     * @throws EE_Error
37
-     *
38
-     * @since    4.3.0
39
-     */
40
-    public static function register(string $config_class = '', array $setup_args = []): bool
41
-    {
23
+	/**
24
+	 * Handles registering the new config with the EE_Config::instance()->addons property
25
+	 *
26
+	 * @param string $config_class                        The name of the Config class being registered.
27
+	 *                                                    Note this class must extend EE_Config Base and must have
28
+	 *                                                    already been registered with an autoloader.
29
+	 * @param array  $setup_args                          {
30
+	 *
31
+	 * @type  string $config_name                         Optional.  by default the new config will be registered to
32
+	 *        EE_Config::instance()->addons->{config_class}, but supplying a "config_name" will set the property name
33
+	 *        that this variable is accessible by. ie: EE_Config::instance()->addons->{config_name}
34
+	 *                            }
35
+	 * @return bool
36
+	 * @throws EE_Error
37
+	 *
38
+	 * @since    4.3.0
39
+	 */
40
+	public static function register(string $config_class = '', array $setup_args = []): bool
41
+	{
42 42
 
43
-        $setup_args['config_name']    = isset($setup_args['config_name']) && ! empty($setup_args['config_name'])
44
-            ? $setup_args['config_name'] : $config_class;
45
-        $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section'])
46
-            ? $setup_args['config_section'] : 'addons';
43
+		$setup_args['config_name']    = isset($setup_args['config_name']) && ! empty($setup_args['config_name'])
44
+			? $setup_args['config_name'] : $config_class;
45
+		$setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section'])
46
+			? $setup_args['config_section'] : 'addons';
47 47
 
48
-        // required fields MUST be present, so let's make sure they are.
49
-        if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) {
50
-            throw new EE_Error(
51
-                __(
52
-                    'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})',
53
-                    'event_espresso'
54
-                )
55
-            );
56
-        }
48
+		// required fields MUST be present, so let's make sure they are.
49
+		if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) {
50
+			throw new EE_Error(
51
+				__(
52
+					'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})',
53
+					'event_espresso'
54
+				)
55
+			);
56
+		}
57 57
 
58
-        // make sure we don't register twice
59
-        if (isset(self::$_ee_config_registry[ $config_class ])) {
60
-            return true;
61
-        }
58
+		// make sure we don't register twice
59
+		if (isset(self::$_ee_config_registry[ $config_class ])) {
60
+			return true;
61
+		}
62 62
 
63 63
 
64
-        // first find out if this happened too late.
65
-        if (did_action('AHEE__EE_System__load_core_configuration__begin')) {
66
-            EE_Error::doing_it_wrong(
67
-                __METHOD__,
68
-                sprintf(
69
-                    __(
70
-                        'An attempt to register "%s" as an EE_Config object has failed because it was not registered at the correct hookpoint.  Please register before the "AHEE__EE_System__load_core_configuration__begin" hook has fired',
71
-                        'event_espresso'
72
-                    ),
73
-                    $setup_args['config_name']
74
-                ),
75
-                '4.3'
76
-            );
77
-        }
78
-        // add incoming stuff to our registry property
79
-        self::$_ee_config_registry[ $config_class ] = [
80
-            'section' => $setup_args['config_section'],
81
-            'name'    => $setup_args['config_name'],
82
-        ];
64
+		// first find out if this happened too late.
65
+		if (did_action('AHEE__EE_System__load_core_configuration__begin')) {
66
+			EE_Error::doing_it_wrong(
67
+				__METHOD__,
68
+				sprintf(
69
+					__(
70
+						'An attempt to register "%s" as an EE_Config object has failed because it was not registered at the correct hookpoint.  Please register before the "AHEE__EE_System__load_core_configuration__begin" hook has fired',
71
+						'event_espresso'
72
+					),
73
+					$setup_args['config_name']
74
+				),
75
+				'4.3'
76
+			);
77
+		}
78
+		// add incoming stuff to our registry property
79
+		self::$_ee_config_registry[ $config_class ] = [
80
+			'section' => $setup_args['config_section'],
81
+			'name'    => $setup_args['config_name'],
82
+		];
83 83
 
84
-        add_action('AHEE__EE_Config___load_core_config__end', ['EE_Register_Config', 'set_config'], 15, 1);
85
-        add_action('AHEE__EE_Config__update_espresso_config__end', ['EE_Register_Config', 'set_config'], 15, 1);
86
-        return true;
87
-    }
84
+		add_action('AHEE__EE_Config___load_core_config__end', ['EE_Register_Config', 'set_config'], 15, 1);
85
+		add_action('AHEE__EE_Config__update_espresso_config__end', ['EE_Register_Config', 'set_config'], 15, 1);
86
+		return true;
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * Callback for the AHEE__EE_Config___load_core_config__end hook.
92
-     * basically just calls EE_Config->get_config() which will take care of loading or creating our config object for us
93
-     *
94
-     * @param EE_Config $EE_Config
95
-     * @throws EE_Error
96
-     * @since    4.3.0
97
-     */
98
-    public static function set_config(EE_Config $EE_Config)
99
-    {
100
-        foreach (self::$_ee_config_registry as $config_class => $settings) {
101
-            // first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
102
-            if (! class_exists($config_class)) {
103
-                throw new EE_Error(
104
-                    sprintf(
105
-                        __(
106
-                            'The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class',
107
-                            'event_espresso'
108
-                        ),
109
-                        $config_class
110
-                    )
111
-                );
112
-            }
113
-            $EE_Config->get_config($settings['section'], $settings['name'], $config_class);
114
-        }
115
-    }
90
+	/**
91
+	 * Callback for the AHEE__EE_Config___load_core_config__end hook.
92
+	 * basically just calls EE_Config->get_config() which will take care of loading or creating our config object for us
93
+	 *
94
+	 * @param EE_Config $EE_Config
95
+	 * @throws EE_Error
96
+	 * @since    4.3.0
97
+	 */
98
+	public static function set_config(EE_Config $EE_Config)
99
+	{
100
+		foreach (self::$_ee_config_registry as $config_class => $settings) {
101
+			// first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
102
+			if (! class_exists($config_class)) {
103
+				throw new EE_Error(
104
+					sprintf(
105
+						__(
106
+							'The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class',
107
+							'event_espresso'
108
+						),
109
+						$config_class
110
+					)
111
+				);
112
+			}
113
+			$EE_Config->get_config($settings['section'], $settings['name'], $config_class);
114
+		}
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * @param mixed $config_class_name
120
-     */
121
-    public static function deregister(string $config_class_name = '')
122
-    {
123
-        unset(self::$_ee_config_registry[ $config_class_name ]);
124
-    }
118
+	/**
119
+	 * @param mixed $config_class_name
120
+	 */
121
+	public static function deregister(string $config_class_name = '')
122
+	{
123
+		unset(self::$_ee_config_registry[ $config_class_name ]);
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
         // make sure we don't register twice
59
-        if (isset(self::$_ee_config_registry[ $config_class ])) {
59
+        if (isset(self::$_ee_config_registry[$config_class])) {
60 60
             return true;
61 61
         }
62 62
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             );
77 77
         }
78 78
         // add incoming stuff to our registry property
79
-        self::$_ee_config_registry[ $config_class ] = [
79
+        self::$_ee_config_registry[$config_class] = [
80 80
             'section' => $setup_args['config_section'],
81 81
             'name'    => $setup_args['config_name'],
82 82
         ];
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         foreach (self::$_ee_config_registry as $config_class => $settings) {
101 101
             // first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
102
-            if (! class_exists($config_class)) {
102
+            if ( ! class_exists($config_class)) {
103 103
                 throw new EE_Error(
104 104
                     sprintf(
105 105
                         __(
@@ -120,6 +120,6 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function deregister(string $config_class_name = '')
122 122
     {
123
-        unset(self::$_ee_config_registry[ $config_class_name ]);
123
+        unset(self::$_ee_config_registry[$config_class_name]);
124 124
     }
125 125
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Shortcode.lib.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -20,163 +20,163 @@
 block discarded – undo
20 20
 class EE_Register_Shortcode implements EEI_Plugin_API
21 21
 {
22 22
 
23
-    /**
24
-     * Holds values for registered shortcodes
25
-     *
26
-     * @var array
27
-     */
28
-    protected static $_settings = [];
23
+	/**
24
+	 * Holds values for registered shortcodes
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected static $_settings = [];
29 29
 
30 30
 
31
-    /**
32
-     *    Method for registering new EE_Shortcodes
33
-     *
34
-     * @param string $shortcode_id                      a unique identifier for this set of modules Required.
35
-     * @param array  $setup_args                        an array of arguments provided for registering shortcodes
36
-     *                                                  Required.
37
-     * @type array shortcode_paths        an array of full server paths to folders containing any
38
-     *                                                  EES_Shortcodes
39
-     * @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
40
-     *                                                  classes to register.  Shortcode classes should extend
41
-     *                                                  EspressoShortcode and be properly namespaced so they are
42
-     *                                                  autoloaded.
43
-     * @return bool
44
-     * @throws EE_Error
45
-     * @since    4.3.0
46
-     * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
47
-     */
48
-    public static function register(string $shortcode_id = '', array $setup_args = []): bool
49
-    {
50
-        // required fields MUST be present, so let's make sure they are.
51
-        if (empty($shortcode_id)
52
-            || ! is_array($setup_args)
53
-            || (
54
-               empty($setup_args['shortcode_paths']))
55
-               && empty($setup_args['shortcode_fqcns'])
56
-        ) {
57
-            throw new EE_Error(
58
-                esc_html__(
59
-                    'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
60
-                    'event_espresso'
61
-                )
62
-            );
63
-        }
31
+	/**
32
+	 *    Method for registering new EE_Shortcodes
33
+	 *
34
+	 * @param string $shortcode_id                      a unique identifier for this set of modules Required.
35
+	 * @param array  $setup_args                        an array of arguments provided for registering shortcodes
36
+	 *                                                  Required.
37
+	 * @type array shortcode_paths        an array of full server paths to folders containing any
38
+	 *                                                  EES_Shortcodes
39
+	 * @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
40
+	 *                                                  classes to register.  Shortcode classes should extend
41
+	 *                                                  EspressoShortcode and be properly namespaced so they are
42
+	 *                                                  autoloaded.
43
+	 * @return bool
44
+	 * @throws EE_Error
45
+	 * @since    4.3.0
46
+	 * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
47
+	 */
48
+	public static function register(string $shortcode_id = '', array $setup_args = []): bool
49
+	{
50
+		// required fields MUST be present, so let's make sure they are.
51
+		if (empty($shortcode_id)
52
+			|| ! is_array($setup_args)
53
+			|| (
54
+			   empty($setup_args['shortcode_paths']))
55
+			   && empty($setup_args['shortcode_fqcns'])
56
+		) {
57
+			throw new EE_Error(
58
+				esc_html__(
59
+					'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
60
+					'event_espresso'
61
+				)
62
+			);
63
+		}
64 64
 
65
-        // make sure we don't register twice
66
-        if (isset(self::$_settings[ $shortcode_id ])) {
67
-            return true;
68
-        }
65
+		// make sure we don't register twice
66
+		if (isset(self::$_settings[ $shortcode_id ])) {
67
+			return true;
68
+		}
69 69
 
70
-        // make sure this was called in the right place!
71
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
72
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
73
-        ) {
74
-            EE_Error::doing_it_wrong(
75
-                __METHOD__,
76
-                esc_html__(
77
-                    'An attempt to register shortcodes has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.',
78
-                    'event_espresso'
79
-                ),
80
-                '4.3.0'
81
-            );
82
-        }
83
-        // setup $_settings array from incoming values.
84
-        self::$_settings[ $shortcode_id ] = [
85
-            // array of full server paths to any EES_Shortcodes used by the shortcode
86
-            'shortcode_paths' => isset($setup_args['shortcode_paths'])
87
-                ? (array) $setup_args['shortcode_paths']
88
-                : [],
89
-            'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
90
-                ? (array) $setup_args['shortcode_fqcns']
91
-                : [],
92
-        ];
93
-        // add to list of shortcodes to be registered
94
-        add_filter(
95
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
96
-            ['EE_Register_Shortcode', 'add_shortcodes']
97
-        );
70
+		// make sure this was called in the right place!
71
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
72
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
73
+		) {
74
+			EE_Error::doing_it_wrong(
75
+				__METHOD__,
76
+				esc_html__(
77
+					'An attempt to register shortcodes has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.',
78
+					'event_espresso'
79
+				),
80
+				'4.3.0'
81
+			);
82
+		}
83
+		// setup $_settings array from incoming values.
84
+		self::$_settings[ $shortcode_id ] = [
85
+			// array of full server paths to any EES_Shortcodes used by the shortcode
86
+			'shortcode_paths' => isset($setup_args['shortcode_paths'])
87
+				? (array) $setup_args['shortcode_paths']
88
+				: [],
89
+			'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
90
+				? (array) $setup_args['shortcode_fqcns']
91
+				: [],
92
+		];
93
+		// add to list of shortcodes to be registered
94
+		add_filter(
95
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
96
+			['EE_Register_Shortcode', 'add_shortcodes']
97
+		);
98 98
 
99
-        add_filter(
100
-            'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
101
-            ['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection']
102
-        );
103
-        return true;
104
-    }
99
+		add_filter(
100
+			'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
101
+			['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection']
102
+		);
103
+		return true;
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * Filters the list of shortcodes to add ours.
109
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
110
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey', etc)
111
-     *
112
-     * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
113
-     * @return array
114
-     */
115
-    public static function add_shortcodes(array $shortcodes_to_register): array
116
-    {
117
-        $shortcode_paths = [];
118
-        foreach (self::$_settings as $settings) {
119
-            $shortcode_paths[] = $settings['shortcode_paths'];
120
-        }
121
-        return array_merge($shortcodes_to_register, ...$shortcode_paths);
122
-    }
107
+	/**
108
+	 * Filters the list of shortcodes to add ours.
109
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
110
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey', etc)
111
+	 *
112
+	 * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
113
+	 * @return array
114
+	 */
115
+	public static function add_shortcodes(array $shortcodes_to_register): array
116
+	{
117
+		$shortcode_paths = [];
118
+		foreach (self::$_settings as $settings) {
119
+			$shortcode_paths[] = $settings['shortcode_paths'];
120
+		}
121
+		return array_merge($shortcodes_to_register, ...$shortcode_paths);
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Hooks into
127
-     * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
128
-     * registers any provided shortcode fully qualified class names.
129
-     *
130
-     * @param CollectionInterface $shortcodes_collection
131
-     * @return CollectionInterface
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidClassException
134
-     * @throws InvalidDataTypeException
135
-     * @throws InvalidInterfaceException
136
-     */
137
-    public static function instantiateAndAddToShortcodeCollection(
138
-        CollectionInterface $shortcodes_collection
139
-    ): CollectionInterface {
140
-        foreach (self::$_settings as $settings) {
141
-            if (! empty($settings['shortcode_fqcns'])) {
142
-                foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
143
-                    if (! class_exists($shortcode_fqcn)) {
144
-                        throw new InvalidClassException(
145
-                            sprintf(
146
-                                esc_html__(
147
-                                    'Are you sure %s is the right fully qualified class name for the shortcode class?',
148
-                                    'event_espresso'
149
-                                ),
150
-                                $shortcode_fqcn
151
-                            )
152
-                        );
153
-                    }
154
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
155
-                        // register dependencies
156
-                        EE_Dependency_Map::register_dependencies(
157
-                            $shortcode_fqcn,
158
-                            [
159
-                                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
160
-                            ]
161
-                        );
162
-                    }
163
-                    $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
164
-                }
165
-            }
166
-        }
167
-        return $shortcodes_collection;
168
-    }
125
+	/**
126
+	 * Hooks into
127
+	 * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
128
+	 * registers any provided shortcode fully qualified class names.
129
+	 *
130
+	 * @param CollectionInterface $shortcodes_collection
131
+	 * @return CollectionInterface
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidClassException
134
+	 * @throws InvalidDataTypeException
135
+	 * @throws InvalidInterfaceException
136
+	 */
137
+	public static function instantiateAndAddToShortcodeCollection(
138
+		CollectionInterface $shortcodes_collection
139
+	): CollectionInterface {
140
+		foreach (self::$_settings as $settings) {
141
+			if (! empty($settings['shortcode_fqcns'])) {
142
+				foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
143
+					if (! class_exists($shortcode_fqcn)) {
144
+						throw new InvalidClassException(
145
+							sprintf(
146
+								esc_html__(
147
+									'Are you sure %s is the right fully qualified class name for the shortcode class?',
148
+									'event_espresso'
149
+								),
150
+								$shortcode_fqcn
151
+							)
152
+						);
153
+					}
154
+					if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
155
+						// register dependencies
156
+						EE_Dependency_Map::register_dependencies(
157
+							$shortcode_fqcn,
158
+							[
159
+								'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
160
+							]
161
+						);
162
+					}
163
+					$shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
164
+				}
165
+			}
166
+		}
167
+		return $shortcodes_collection;
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
173
-     *
174
-     * @param string $shortcode_id the name for the shortcode that was previously registered
175
-     * @return void
176
-     * @since 4.3.0
177
-     */
178
-    public static function deregister(string $shortcode_id = '')
179
-    {
180
-        unset(self::$_settings[ $shortcode_id ]);
181
-    }
171
+	/**
172
+	 * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
173
+	 *
174
+	 * @param string $shortcode_id the name for the shortcode that was previously registered
175
+	 * @return void
176
+	 * @since 4.3.0
177
+	 */
178
+	public static function deregister(string $shortcode_id = '')
179
+	{
180
+		unset(self::$_settings[ $shortcode_id ]);
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
         }
64 64
 
65 65
         // make sure we don't register twice
66
-        if (isset(self::$_settings[ $shortcode_id ])) {
66
+        if (isset(self::$_settings[$shortcode_id])) {
67 67
             return true;
68 68
         }
69 69
 
70 70
         // make sure this was called in the right place!
71
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
71
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
72 72
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
73 73
         ) {
74 74
             EE_Error::doing_it_wrong(
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             );
82 82
         }
83 83
         // setup $_settings array from incoming values.
84
-        self::$_settings[ $shortcode_id ] = [
84
+        self::$_settings[$shortcode_id] = [
85 85
             // array of full server paths to any EES_Shortcodes used by the shortcode
86 86
             'shortcode_paths' => isset($setup_args['shortcode_paths'])
87 87
                 ? (array) $setup_args['shortcode_paths']
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
         CollectionInterface $shortcodes_collection
139 139
     ): CollectionInterface {
140 140
         foreach (self::$_settings as $settings) {
141
-            if (! empty($settings['shortcode_fqcns'])) {
141
+            if ( ! empty($settings['shortcode_fqcns'])) {
142 142
                 foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
143
-                    if (! class_exists($shortcode_fqcn)) {
143
+                    if ( ! class_exists($shortcode_fqcn)) {
144 144
                         throw new InvalidClassException(
145 145
                             sprintf(
146 146
                                 esc_html__(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                             )
152 152
                         );
153 153
                     }
154
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
154
+                    if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
155 155
                         // register dependencies
156 156
                         EE_Dependency_Map::register_dependencies(
157 157
                             $shortcode_fqcn,
@@ -177,6 +177,6 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public static function deregister(string $shortcode_id = '')
179 179
     {
180
-        unset(self::$_settings[ $shortcode_id ]);
180
+        unset(self::$_settings[$shortcode_id]);
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Template_Variations.lib.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -11,319 +11,319 @@
 block discarded – undo
11 11
 class EE_Register_Messages_Template_Variations implements EEI_Plugin_API
12 12
 {
13 13
 
14
-    /**
15
-     * Holds values for registered variations
16
-     *
17
-     * @since 4.5.0
18
-     *
19
-     * @var array
20
-     */
21
-    protected static $_registry = array();
14
+	/**
15
+	 * Holds values for registered variations
16
+	 *
17
+	 * @since 4.5.0
18
+	 *
19
+	 * @var array
20
+	 */
21
+	protected static $_registry = array();
22 22
 
23 23
 
24
-    /**
25
-     * Used to register new variations
26
-     *
27
-     * Variations are attached to template packs and do not typically change any structural layout but merely tweak the
28
-     * style of the layout.  The most commonly known variation is css.  CSS does not affect html structure just the
29
-     * style of existing structure.
30
-     *
31
-     * It's important to remember that when variation files are loaded, the file structure looked for is:
32
-     * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'.
33
-     *
34
-     *    - Every variation applies to specific messengers.  That's why the variation file includes the messenger name
35
-     *    it.   This ensures that if a template pack the variation is registered with supports multiple variations that
36
-     *    you can have the correct variation loaded.
37
-     *    - EE_messengers also implicitly define variation "types" which typically are the context in which a specific
38
-     *    variation is loaded.  For instance the email messenger has: 'inline', which is the css added inline to the
39
-     *    email templates; 'preview', which is the same css only customized for when emails are previewed; and
40
-     *    'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to
41
-     *    give a accurate representation of the style in the wysiwyg editor.  This means that for each variation, if
42
-     *    you want it to be accurately represented in various template contexts you need to have that relevant
43
-     *    variation file available.
44
-     *    - $variation_slug  is simply the variation slug for that variation.
45
-     *    - $extension = whatever the extension is for the variation used for the messenger calling it.  In MOST cases
46
-     *    messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT
47
-     *    be loaded.  The EE messages template pack system will fallback to corresponding default template pack for the
48
-     *    given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any
49
-     *    variation (so the template pack would be unstyled)
50
-     *
51
-     * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html
52
-     *      messengers.
53
-     *
54
-     * @param string $variation_ref                   unique reference used to describe this variation registry. If
55
-     *                                                this ISN'T unique then this method will make it unique (and it
56
-     *                                                becomes harder to deregister).
57
-     * @param array  $setup_args                      {
58
-     *                                                an array of required values for registering the variations.
59
-     * @type array   $variations                      {
60
-     *                                                An array indexed by template_pack->dbref. and values are an array
61
-     *                                                indexed by messenger name and values are an array indexed by
62
-     *                                                message_type and values are an array indexed by variation_slug
63
-     *                                                and value  is the localized label for the variation.  Note this
64
-     *                                                api reserves the "default" variation name for the default
65
-     *                                                template pack so you can't register a default variation.  Also,
66
-     *                                                try to use unique variation slugs to reference your variations
67
-     *                                                because this api checks if any existing variations are in place
68
-     *                                                with that name.  If there are then subsequent variations for that
69
-     *                                                template pack with that same name will fail to register with a
70
-     *                                                persistent notice put up for the user. Required.
71
-     *                                                'default' => array(
72
-     *                                                'email' => array(
73
-     *                                                'registration_approved' => array(
74
-     *                                                my_ee_addon_blue_lagoon' => __('Blue Lagoon',
75
-     *                                                'text_domain'),
76
-     *                                                'my_ee_addon_red_sunset' => __('Red Sunset',
77
-     *                                                'text_domain')
78
-     *                                                )
79
-     *                                                )
80
-     *                                                )
81
-     *                                                }
82
-     * @type string  $base_path                       The base path for where all your variations are found.  Although
83
-     *       the full path to your variation files should include '/variations/' in it, do not include the
84
-     *       'variations/' in this. Required.
85
-     * @type string  $base_url                        The base url for where all your variations are found. See note
86
-     *       above about the 'variations/' string. Required.
87
-     *                                                }
88
-     *                                                }
89
-     *
90
-     * @throws EE_Error
91
-     * @return bool
92
-     */
93
-    public static function register(string $variation_ref = '', array $setup_args = array()): bool
94
-    {
24
+	/**
25
+	 * Used to register new variations
26
+	 *
27
+	 * Variations are attached to template packs and do not typically change any structural layout but merely tweak the
28
+	 * style of the layout.  The most commonly known variation is css.  CSS does not affect html structure just the
29
+	 * style of existing structure.
30
+	 *
31
+	 * It's important to remember that when variation files are loaded, the file structure looked for is:
32
+	 * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'.
33
+	 *
34
+	 *    - Every variation applies to specific messengers.  That's why the variation file includes the messenger name
35
+	 *    it.   This ensures that if a template pack the variation is registered with supports multiple variations that
36
+	 *    you can have the correct variation loaded.
37
+	 *    - EE_messengers also implicitly define variation "types" which typically are the context in which a specific
38
+	 *    variation is loaded.  For instance the email messenger has: 'inline', which is the css added inline to the
39
+	 *    email templates; 'preview', which is the same css only customized for when emails are previewed; and
40
+	 *    'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to
41
+	 *    give a accurate representation of the style in the wysiwyg editor.  This means that for each variation, if
42
+	 *    you want it to be accurately represented in various template contexts you need to have that relevant
43
+	 *    variation file available.
44
+	 *    - $variation_slug  is simply the variation slug for that variation.
45
+	 *    - $extension = whatever the extension is for the variation used for the messenger calling it.  In MOST cases
46
+	 *    messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT
47
+	 *    be loaded.  The EE messages template pack system will fallback to corresponding default template pack for the
48
+	 *    given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any
49
+	 *    variation (so the template pack would be unstyled)
50
+	 *
51
+	 * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html
52
+	 *      messengers.
53
+	 *
54
+	 * @param string $variation_ref                   unique reference used to describe this variation registry. If
55
+	 *                                                this ISN'T unique then this method will make it unique (and it
56
+	 *                                                becomes harder to deregister).
57
+	 * @param array  $setup_args                      {
58
+	 *                                                an array of required values for registering the variations.
59
+	 * @type array   $variations                      {
60
+	 *                                                An array indexed by template_pack->dbref. and values are an array
61
+	 *                                                indexed by messenger name and values are an array indexed by
62
+	 *                                                message_type and values are an array indexed by variation_slug
63
+	 *                                                and value  is the localized label for the variation.  Note this
64
+	 *                                                api reserves the "default" variation name for the default
65
+	 *                                                template pack so you can't register a default variation.  Also,
66
+	 *                                                try to use unique variation slugs to reference your variations
67
+	 *                                                because this api checks if any existing variations are in place
68
+	 *                                                with that name.  If there are then subsequent variations for that
69
+	 *                                                template pack with that same name will fail to register with a
70
+	 *                                                persistent notice put up for the user. Required.
71
+	 *                                                'default' => array(
72
+	 *                                                'email' => array(
73
+	 *                                                'registration_approved' => array(
74
+	 *                                                my_ee_addon_blue_lagoon' => __('Blue Lagoon',
75
+	 *                                                'text_domain'),
76
+	 *                                                'my_ee_addon_red_sunset' => __('Red Sunset',
77
+	 *                                                'text_domain')
78
+	 *                                                )
79
+	 *                                                )
80
+	 *                                                )
81
+	 *                                                }
82
+	 * @type string  $base_path                       The base path for where all your variations are found.  Although
83
+	 *       the full path to your variation files should include '/variations/' in it, do not include the
84
+	 *       'variations/' in this. Required.
85
+	 * @type string  $base_url                        The base url for where all your variations are found. See note
86
+	 *       above about the 'variations/' string. Required.
87
+	 *                                                }
88
+	 *                                                }
89
+	 *
90
+	 * @throws EE_Error
91
+	 * @return bool
92
+	 */
93
+	public static function register(string $variation_ref = '', array $setup_args = array()): bool
94
+	{
95 95
 
96
-        // check for required params
97
-        if (empty($variation_ref)) {
98
-            throw new EE_Error(
99
-                __(
100
-                    'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered',
101
-                    'event_espresso'
102
-                )
103
-            );
104
-        }
96
+		// check for required params
97
+		if (empty($variation_ref)) {
98
+			throw new EE_Error(
99
+				__(
100
+					'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered',
101
+					'event_espresso'
102
+				)
103
+			);
104
+		}
105 105
 
106
-        if (! is_array($setup_args)
107
-            || empty($setup_args['variations'])
108
-            || empty($setup_args['base_path'])
109
-            || empty($setup_args['base_url'])
110
-        ) {
111
-            throw new EE_Error(
112
-                __(
113
-                    'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"',
114
-                    'event_espresso'
115
-                )
116
-            );
117
-        }
106
+		if (! is_array($setup_args)
107
+			|| empty($setup_args['variations'])
108
+			|| empty($setup_args['base_path'])
109
+			|| empty($setup_args['base_url'])
110
+		) {
111
+			throw new EE_Error(
112
+				__(
113
+					'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"',
114
+					'event_espresso'
115
+				)
116
+			);
117
+		}
118 118
 
119
-        // make sure we don't register twice
120
-        if (isset(self::$_registry[ $variation_ref ])) {
121
-            return true;
122
-        }
119
+		// make sure we don't register twice
120
+		if (isset(self::$_registry[ $variation_ref ])) {
121
+			return true;
122
+		}
123 123
 
124
-        // make sure variation ref is unique.
125
-        if (isset(self::$_registry[ $variation_ref ])) {
126
-            $variation_ref = uniqid() . '_' . $variation_ref;
127
-        }
124
+		// make sure variation ref is unique.
125
+		if (isset(self::$_registry[ $variation_ref ])) {
126
+			$variation_ref = uniqid() . '_' . $variation_ref;
127
+		}
128 128
 
129 129
 
130
-        // make sure this was called in the right place!
131
-        if (! did_action('EE_Brewing_Regular___messages_caf')
132
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
133
-        ) {
134
-            EE_Error::doing_it_wrong(
135
-                __METHOD__,
136
-                sprintf(
137
-                    __(
138
-                        'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
139
-                        'event_espresso'
140
-                    ),
141
-                    $variation_ref
142
-                ),
143
-                '4.5.0'
144
-            );
145
-        }
130
+		// make sure this was called in the right place!
131
+		if (! did_action('EE_Brewing_Regular___messages_caf')
132
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
133
+		) {
134
+			EE_Error::doing_it_wrong(
135
+				__METHOD__,
136
+				sprintf(
137
+					__(
138
+						'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
139
+						'event_espresso'
140
+					),
141
+					$variation_ref
142
+				),
143
+				'4.5.0'
144
+			);
145
+		}
146 146
 
147
-        // validate/sanitize incoming args.
148
-        $validated = array(
149
-            'variations' => (array) $setup_args['variations'],
150
-            'base_path'  => (string) $setup_args['base_path'],
151
-            'base_url'   => (string) $setup_args['base_url'],
152
-        );
147
+		// validate/sanitize incoming args.
148
+		$validated = array(
149
+			'variations' => (array) $setup_args['variations'],
150
+			'base_path'  => (string) $setup_args['base_path'],
151
+			'base_url'   => (string) $setup_args['base_url'],
152
+		);
153 153
 
154 154
 
155
-        // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack.  The former will throw an error.  The latter will remove the conflicting variation name but still register the others and will add EE_Error notice.
156
-        $validated = self::_verify_variations($variation_ref, $validated);
157
-        self::$_registry[ $variation_ref ] = $validated;
155
+		// check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack.  The former will throw an error.  The latter will remove the conflicting variation name but still register the others and will add EE_Error notice.
156
+		$validated = self::_verify_variations($variation_ref, $validated);
157
+		self::$_registry[ $variation_ref ] = $validated;
158 158
 
159
-        add_filter(
160
-            'FHEE__EE_Messages_Template_Pack__get_variations',
161
-            array('EE_Register_Messages_Template_Variations', 'get_variations'),
162
-            10,
163
-            4
164
-        );
165
-        add_filter(
166
-            'FHEE__EE_Messages_Template_Pack__get_variation',
167
-            array('EE_Register_Messages_Template_Variations', 'get_variation'),
168
-            10,
169
-            8
170
-        );
171
-        return true;
172
-    }
159
+		add_filter(
160
+			'FHEE__EE_Messages_Template_Pack__get_variations',
161
+			array('EE_Register_Messages_Template_Variations', 'get_variations'),
162
+			10,
163
+			4
164
+		);
165
+		add_filter(
166
+			'FHEE__EE_Messages_Template_Pack__get_variation',
167
+			array('EE_Register_Messages_Template_Variations', 'get_variation'),
168
+			10,
169
+			8
170
+		);
171
+		return true;
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * Cycles through the variations registered and makes sure there are no reserved variations being registered which
177
-     * throws an error.  Also checks if there is already a
178
-     *
179
-     * @param string $variation_ref        the reference for the variations being registered
180
-     * @param array  $validated_variations The variations setup array that's being registered (and verified).
181
-     * @return array
182
-     * @throws EE_Error
183
-     * @since  4.5.0
184
-     */
185
-    private static function _verify_variations(string $variation_ref, array $validated_variations): array
186
-    {
187
-        foreach (self::$_registry as $variation_ref => $settings) {
188
-            foreach ($settings['variations'] as $template_pack => $messenger) {
189
-                foreach ($messenger as $all_variations) {
190
-                    if (isset($all_variations['default'])) {
191
-                        throw new EE_Error(
192
-                            sprintf(
193
-                                __(
194
-                                    'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template.  Please check the code registering variations with this reference, "%s" and modify.',
195
-                                    'event_espresso'
196
-                                ),
197
-                                $variation_ref
198
-                            )
199
-                        );
200
-                    }
201
-                }
202
-            }
203
-        }
175
+	/**
176
+	 * Cycles through the variations registered and makes sure there are no reserved variations being registered which
177
+	 * throws an error.  Also checks if there is already a
178
+	 *
179
+	 * @param string $variation_ref        the reference for the variations being registered
180
+	 * @param array  $validated_variations The variations setup array that's being registered (and verified).
181
+	 * @return array
182
+	 * @throws EE_Error
183
+	 * @since  4.5.0
184
+	 */
185
+	private static function _verify_variations(string $variation_ref, array $validated_variations): array
186
+	{
187
+		foreach (self::$_registry as $variation_ref => $settings) {
188
+			foreach ($settings['variations'] as $template_pack => $messenger) {
189
+				foreach ($messenger as $all_variations) {
190
+					if (isset($all_variations['default'])) {
191
+						throw new EE_Error(
192
+							sprintf(
193
+								__(
194
+									'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template.  Please check the code registering variations with this reference, "%s" and modify.',
195
+									'event_espresso'
196
+								),
197
+								$variation_ref
198
+							)
199
+						);
200
+					}
201
+				}
202
+			}
203
+		}
204 204
 
205
-        // is there already a variation registered with a given variation slug?
206
-        foreach ($validated_variations['variations'] as $template_pack => $messenger) {
207
-            foreach ($messenger as $message_type => $variations) {
208
-                foreach ($variations as $slug => $label) {
209
-                    foreach (self::$_registry as $registered_var => $reg_settings) {
210
-                        if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) {
211
-                            unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]);
212
-                            EE_Error::add_error(
213
-                                sprintf(
214
-                                    __(
215
-                                        'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.',
216
-                                        'event_espresso'
217
-                                    ),
218
-                                    $label,
219
-                                    $template_pack,
220
-                                    $messenger,
221
-                                    $message_type,
222
-                                    $registered_var
223
-                                )
224
-                            );
225
-                        }
226
-                    }
227
-                }
228
-            }
229
-        }
230
-        return $validated_variations;
231
-    }
205
+		// is there already a variation registered with a given variation slug?
206
+		foreach ($validated_variations['variations'] as $template_pack => $messenger) {
207
+			foreach ($messenger as $message_type => $variations) {
208
+				foreach ($variations as $slug => $label) {
209
+					foreach (self::$_registry as $registered_var => $reg_settings) {
210
+						if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) {
211
+							unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]);
212
+							EE_Error::add_error(
213
+								sprintf(
214
+									__(
215
+										'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.',
216
+										'event_espresso'
217
+									),
218
+									$label,
219
+									$template_pack,
220
+									$messenger,
221
+									$message_type,
222
+									$registered_var
223
+								)
224
+							);
225
+						}
226
+					}
227
+				}
228
+			}
229
+		}
230
+		return $validated_variations;
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used.
236
-     *
237
-     * @since 4.5.0
238
-     *
239
-     * @param string                    $variation_path The path generated for the current variation
240
-     * @param string                    $messenger      The messenger the variation is for
241
-     * @param string                    $message_type   EE_message_type->name
242
-     * @param string                    $type           The type of variation being requested
243
-     * @param string                    $variation      The slug for the variation being requested
244
-     * @param string                    $file_extension What the file extension is for the variation
245
-     * @param bool                      $url            Whether url or path is being returned.
246
-     * @param EE_Messages_Template_Pack $template_pack
247
-     *
248
-     * @return string                    The path to the requested variation.
249
-     */
250
-    public static function get_variation(
251
-        string $variation_path,
252
-        string $messenger,
253
-        string $message_type,
254
-        string $type,
255
-        string $variation,
256
-        string $file_extension,
257
-        bool $url,
258
-        EE_Messages_Template_Pack $template_pack
259
-    ): string {
234
+	/**
235
+	 * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used.
236
+	 *
237
+	 * @since 4.5.0
238
+	 *
239
+	 * @param string                    $variation_path The path generated for the current variation
240
+	 * @param string                    $messenger      The messenger the variation is for
241
+	 * @param string                    $message_type   EE_message_type->name
242
+	 * @param string                    $type           The type of variation being requested
243
+	 * @param string                    $variation      The slug for the variation being requested
244
+	 * @param string                    $file_extension What the file extension is for the variation
245
+	 * @param bool                      $url            Whether url or path is being returned.
246
+	 * @param EE_Messages_Template_Pack $template_pack
247
+	 *
248
+	 * @return string                    The path to the requested variation.
249
+	 */
250
+	public static function get_variation(
251
+		string $variation_path,
252
+		string $messenger,
253
+		string $message_type,
254
+		string $type,
255
+		string $variation,
256
+		string $file_extension,
257
+		bool $url,
258
+		EE_Messages_Template_Pack $template_pack
259
+	): string {
260 260
 
261
-        // so let's loop through our registered variations and then pull any details matching the request.
262
-        foreach (self::$_registry as $registry_slug => $registry_settings) {
263
-            $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path'];
264
-            $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension;
265
-            // see if this file exists
266
-            if (is_readable($registry_settings['base_path'] . $file_string)) {
267
-                return $base . $file_string;
268
-            }
269
-        }
261
+		// so let's loop through our registered variations and then pull any details matching the request.
262
+		foreach (self::$_registry as $registry_slug => $registry_settings) {
263
+			$base = $url ? $registry_settings['base_url'] : $registry_settings['base_path'];
264
+			$file_string = $messenger . '_' . $type . '_' . $variation . $file_extension;
265
+			// see if this file exists
266
+			if (is_readable($registry_settings['base_path'] . $file_string)) {
267
+				return $base . $file_string;
268
+			}
269
+		}
270 270
 
271
-        // no match
272
-        return $variation_path;
273
-    }
271
+		// no match
272
+		return $variation_path;
273
+	}
274 274
 
275 275
 
276
-    /**
277
-     * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter.
278
-     *
279
-     *
280
-     * @param array                     $variations The original contents for the template pack variations property.
281
-     * @param string                    $messenger  The messenger requesting the variations.
282
-     * @param string                    $message_type
283
-     * @param EE_Messages_Template_Pack $template_pack
284
-     *
285
-     * @return array                   new variations array (or existing one if nothing registered)
286
-     * @since 4.5.0
287
-     *
288
-     * @see   $_variation property definition in EE_Messages_Template_Pack
289
-     */
290
-    public static function get_variations(
291
-        array $variations,
292
-        string $messenger,
293
-        string $message_type,
294
-        EE_Messages_Template_Pack $template_pack
295
-    ): array {
296
-        // first let's check if we even have registered variations and get out early.
297
-        if (empty(self::$_registry)) {
298
-            return $variations;
299
-        }
300
-        $template_variations = [];
301
-        // do we have any new variations for the given messenger, $message_type, and template packs
302
-        foreach (self::$_registry as $registry_slug => $registry_settings) {
303
-            // allow for different conditions.
304
-            if (empty($messenger)) {
305
-                $template_variations[] = $registry_settings['variations'];
306
-            } elseif (empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) {
307
-                $template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ];
308
-            } elseif (! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) {
309
-                $template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ];
310
-            }
311
-        }
312
-        return array_merge($variations, ...$template_variations);
313
-    }
276
+	/**
277
+	 * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter.
278
+	 *
279
+	 *
280
+	 * @param array                     $variations The original contents for the template pack variations property.
281
+	 * @param string                    $messenger  The messenger requesting the variations.
282
+	 * @param string                    $message_type
283
+	 * @param EE_Messages_Template_Pack $template_pack
284
+	 *
285
+	 * @return array                   new variations array (or existing one if nothing registered)
286
+	 * @since 4.5.0
287
+	 *
288
+	 * @see   $_variation property definition in EE_Messages_Template_Pack
289
+	 */
290
+	public static function get_variations(
291
+		array $variations,
292
+		string $messenger,
293
+		string $message_type,
294
+		EE_Messages_Template_Pack $template_pack
295
+	): array {
296
+		// first let's check if we even have registered variations and get out early.
297
+		if (empty(self::$_registry)) {
298
+			return $variations;
299
+		}
300
+		$template_variations = [];
301
+		// do we have any new variations for the given messenger, $message_type, and template packs
302
+		foreach (self::$_registry as $registry_slug => $registry_settings) {
303
+			// allow for different conditions.
304
+			if (empty($messenger)) {
305
+				$template_variations[] = $registry_settings['variations'];
306
+			} elseif (empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) {
307
+				$template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ];
308
+			} elseif (! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) {
309
+				$template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ];
310
+			}
311
+		}
312
+		return array_merge($variations, ...$template_variations);
313
+	}
314 314
 
315 315
 
316
-    /**
317
-     * This deregisters a variation set that was previously registered with the given slug.
318
-     *
319
-     * @since 4.5.0
320
-     *
321
-     * @param string $variation_ref The name for the variation set that was previously registered.
322
-     *
323
-     * @return void
324
-     */
325
-    public static function deregister(string $variation_ref = '')
326
-    {
327
-        unset(self::$_registry[ $variation_ref ]);
328
-    }
316
+	/**
317
+	 * This deregisters a variation set that was previously registered with the given slug.
318
+	 *
319
+	 * @since 4.5.0
320
+	 *
321
+	 * @param string $variation_ref The name for the variation set that was previously registered.
322
+	 *
323
+	 * @return void
324
+	 */
325
+	public static function deregister(string $variation_ref = '')
326
+	{
327
+		unset(self::$_registry[ $variation_ref ]);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             );
104 104
         }
105 105
 
106
-        if (! is_array($setup_args)
106
+        if ( ! is_array($setup_args)
107 107
             || empty($setup_args['variations'])
108 108
             || empty($setup_args['base_path'])
109 109
             || empty($setup_args['base_url'])
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         // make sure we don't register twice
120
-        if (isset(self::$_registry[ $variation_ref ])) {
120
+        if (isset(self::$_registry[$variation_ref])) {
121 121
             return true;
122 122
         }
123 123
 
124 124
         // make sure variation ref is unique.
125
-        if (isset(self::$_registry[ $variation_ref ])) {
126
-            $variation_ref = uniqid() . '_' . $variation_ref;
125
+        if (isset(self::$_registry[$variation_ref])) {
126
+            $variation_ref = uniqid().'_'.$variation_ref;
127 127
         }
128 128
 
129 129
 
130 130
         // make sure this was called in the right place!
131
-        if (! did_action('EE_Brewing_Regular___messages_caf')
131
+        if ( ! did_action('EE_Brewing_Regular___messages_caf')
132 132
             || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
133 133
         ) {
134 134
             EE_Error::doing_it_wrong(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack.  The former will throw an error.  The latter will remove the conflicting variation name but still register the others and will add EE_Error notice.
156 156
         $validated = self::_verify_variations($variation_ref, $validated);
157
-        self::$_registry[ $variation_ref ] = $validated;
157
+        self::$_registry[$variation_ref] = $validated;
158 158
 
159 159
         add_filter(
160 160
             'FHEE__EE_Messages_Template_Pack__get_variations',
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
             foreach ($messenger as $message_type => $variations) {
208 208
                 foreach ($variations as $slug => $label) {
209 209
                     foreach (self::$_registry as $registered_var => $reg_settings) {
210
-                        if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) {
211
-                            unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]);
210
+                        if (isset($reg_settings['variations'][$template_pack][$messenger][$message_type][$slug])) {
211
+                            unset($validated_variations['variations'][$template_pack][$messenger][$message_type][$slug]);
212 212
                             EE_Error::add_error(
213 213
                                 sprintf(
214 214
                                     __(
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
         // so let's loop through our registered variations and then pull any details matching the request.
262 262
         foreach (self::$_registry as $registry_slug => $registry_settings) {
263 263
             $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path'];
264
-            $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension;
264
+            $file_string = $messenger.'_'.$type.'_'.$variation.$file_extension;
265 265
             // see if this file exists
266
-            if (is_readable($registry_settings['base_path'] . $file_string)) {
267
-                return $base . $file_string;
266
+            if (is_readable($registry_settings['base_path'].$file_string)) {
267
+                return $base.$file_string;
268 268
             }
269 269
         }
270 270
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
             // allow for different conditions.
304 304
             if (empty($messenger)) {
305 305
                 $template_variations[] = $registry_settings['variations'];
306
-            } elseif (empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) {
307
-                $template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ];
308
-            } elseif (! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) {
309
-                $template_variations[] = $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ];
306
+            } elseif (empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger])) {
307
+                $template_variations[] = $registry_settings['variations'][$template_pack->dbref][$messenger];
308
+            } elseif ( ! empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type])) {
309
+                $template_variations[] = $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type];
310 310
             }
311 311
         }
312 312
         return array_merge($variations, ...$template_variations);
@@ -324,6 +324,6 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public static function deregister(string $variation_ref = '')
326 326
     {
327
-        unset(self::$_registry[ $variation_ref ]);
327
+        unset(self::$_registry[$variation_ref]);
328 328
     }
329 329
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Module.lib.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -15,100 +15,100 @@
 block discarded – undo
15 15
 class EE_Register_Module implements EEI_Plugin_API
16 16
 {
17 17
 
18
-    /**
19
-     * Holds values for registered modules
20
-     *
21
-     * @var array
22
-     */
23
-    protected static $_settings = [];
18
+	/**
19
+	 * Holds values for registered modules
20
+	 *
21
+	 * @var array
22
+	 */
23
+	protected static $_settings = [];
24 24
 
25 25
 
26
-    /**
27
-     *    Method for registering new EED_Modules
28
-     *
29
-     * @param string $module_id  a unique identifier for this set of modules Required.
30
-     * @param array  $setup_args an array of full server paths to folders containing any EED_Modules, or to the
31
-     *                           EED_Module files themselves Required.
32
-     * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
33
-     *                           EED_Module files themselves
34
-     * @return bool
35
-     * @throws EE_Error
36
-     * @since    4.3.0
37
-     */
38
-    public static function register(string $module_id = '', array $setup_args = []): bool
39
-    {
40
-        // required fields MUST be present, so let's make sure they are.
41
-        if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
42
-            throw new EE_Error(
43
-                __(
44
-                    'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
45
-                    'event_espresso'
46
-                )
47
-            );
48
-        }
26
+	/**
27
+	 *    Method for registering new EED_Modules
28
+	 *
29
+	 * @param string $module_id  a unique identifier for this set of modules Required.
30
+	 * @param array  $setup_args an array of full server paths to folders containing any EED_Modules, or to the
31
+	 *                           EED_Module files themselves Required.
32
+	 * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
33
+	 *                           EED_Module files themselves
34
+	 * @return bool
35
+	 * @throws EE_Error
36
+	 * @since    4.3.0
37
+	 */
38
+	public static function register(string $module_id = '', array $setup_args = []): bool
39
+	{
40
+		// required fields MUST be present, so let's make sure they are.
41
+		if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
42
+			throw new EE_Error(
43
+				__(
44
+					'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
45
+					'event_espresso'
46
+				)
47
+			);
48
+		}
49 49
 
50
-        // make sure we don't register twice
51
-        if (isset(self::$_settings[ $module_id ])) {
52
-            return true;
53
-        }
50
+		// make sure we don't register twice
51
+		if (isset(self::$_settings[ $module_id ])) {
52
+			return true;
53
+		}
54 54
 
55
-        // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
57
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
-        ) {
59
-            EE_Error::doing_it_wrong(
60
-                __METHOD__,
61
-                __(
62
-                    'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
63
-                    'event_espresso'
64
-                ),
65
-                '4.3.0'
66
-            );
67
-        }
68
-        // setup $_settings array from incoming values.
69
-        self::$_settings[ $module_id ] = [
70
-            // array of full server paths to any EED_Modules used by the module
71
-            'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [],
72
-        ];
73
-        // add to list of modules to be registered
74
-        add_filter(
75
-            'FHEE__EE_Config__register_modules__modules_to_register',
76
-            ['EE_Register_Module', 'add_modules']
77
-        );
78
-        return true;
79
-    }
55
+		// make sure this was called in the right place!
56
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
57
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
+		) {
59
+			EE_Error::doing_it_wrong(
60
+				__METHOD__,
61
+				__(
62
+					'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
63
+					'event_espresso'
64
+				),
65
+				'4.3.0'
66
+			);
67
+		}
68
+		// setup $_settings array from incoming values.
69
+		self::$_settings[ $module_id ] = [
70
+			// array of full server paths to any EED_Modules used by the module
71
+			'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [],
72
+		];
73
+		// add to list of modules to be registered
74
+		add_filter(
75
+			'FHEE__EE_Config__register_modules__modules_to_register',
76
+			['EE_Register_Module', 'add_modules']
77
+		);
78
+		return true;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Filters the list of modules to add ours.
84
-     * and they're just full filepaths to FOLDERS containing a module class file. Eg.
85
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey', etc)
86
-     *
87
-     * @param array $modules_to_register array of paths to all modules that require registering
88
-     * @return array
89
-     */
90
-    public static function add_modules(array $modules_to_register): array
91
-    {
92
-        $module_paths = [];
93
-        foreach (self::$_settings as $settings) {
94
-            $module_paths[] = $settings['module_paths'];
95
-        }
96
-        return array_merge($modules_to_register, ...$module_paths);
97
-    }
82
+	/**
83
+	 * Filters the list of modules to add ours.
84
+	 * and they're just full filepaths to FOLDERS containing a module class file. Eg.
85
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey', etc)
86
+	 *
87
+	 * @param array $modules_to_register array of paths to all modules that require registering
88
+	 * @return array
89
+	 */
90
+	public static function add_modules(array $modules_to_register): array
91
+	{
92
+		$module_paths = [];
93
+		foreach (self::$_settings as $settings) {
94
+			$module_paths[] = $settings['module_paths'];
95
+		}
96
+		return array_merge($modules_to_register, ...$module_paths);
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * This deregisters a module that was previously registered with a specific $module_id.
102
-     *
103
-     * @param string $module_id the name for the module that was previously registered
104
-     * @return void
105
-     * @since    4.3.0
106
-     *
107
-     */
108
-    public static function deregister(string $module_id = '')
109
-    {
110
-        if (isset(self::$_settings[ $module_id ])) {
111
-            unset(self::$_settings[ $module_id ]);
112
-        }
113
-    }
100
+	/**
101
+	 * This deregisters a module that was previously registered with a specific $module_id.
102
+	 *
103
+	 * @param string $module_id the name for the module that was previously registered
104
+	 * @return void
105
+	 * @since    4.3.0
106
+	 *
107
+	 */
108
+	public static function deregister(string $module_id = '')
109
+	{
110
+		if (isset(self::$_settings[ $module_id ])) {
111
+			unset(self::$_settings[ $module_id ]);
112
+		}
113
+	}
114 114
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         // make sure we don't register twice
51
-        if (isset(self::$_settings[ $module_id ])) {
51
+        if (isset(self::$_settings[$module_id])) {
52 52
             return true;
53 53
         }
54 54
 
55 55
         // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
56
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
57 57
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58 58
         ) {
59 59
             EE_Error::doing_it_wrong(
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             );
67 67
         }
68 68
         // setup $_settings array from incoming values.
69
-        self::$_settings[ $module_id ] = [
69
+        self::$_settings[$module_id] = [
70 70
             // array of full server paths to any EED_Modules used by the module
71 71
             'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [],
72 72
         ];
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public static function deregister(string $module_id = '')
109 109
     {
110
-        if (isset(self::$_settings[ $module_id ])) {
111
-            unset(self::$_settings[ $module_id ]);
110
+        if (isset(self::$_settings[$module_id])) {
111
+            unset(self::$_settings[$module_id]);
112 112
         }
113 113
     }
114 114
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +1012 added lines, -1012 removed lines patch added patch discarded remove patch
@@ -21,1016 +21,1016 @@
 block discarded – undo
21 21
 class EE_Dependency_Map
22 22
 {
23 23
 
24
-    /**
25
-     * This means that the requested class dependency is not present in the dependency map
26
-     */
27
-    const not_registered = 0;
28
-
29
-    /**
30
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
-     */
32
-    const load_new_object = 1;
33
-
34
-    /**
35
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
-     */
38
-    const load_from_cache = 2;
39
-
40
-    /**
41
-     * When registering a dependency,
42
-     * this indicates to keep any existing dependencies that already exist,
43
-     * and simply discard any new dependencies declared in the incoming data
44
-     */
45
-    const KEEP_EXISTING_DEPENDENCIES = 0;
46
-
47
-    /**
48
-     * When registering a dependency,
49
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
-     */
51
-    const OVERWRITE_DEPENDENCIES = 1;
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = [];
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = [];
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     * @throws InvalidAliasException
109
-     */
110
-    public function initialize()
111
-    {
112
-        $this->_register_core_dependencies();
113
-        $this->_register_core_class_loaders();
114
-        $this->_register_core_aliases();
115
-    }
116
-
117
-
118
-    /**
119
-     * @singleton method used to instantiate class object
120
-     * @param ClassInterfaceCache|null $class_cache
121
-     * @return EE_Dependency_Map
122
-     */
123
-    public static function instance(ClassInterfaceCache $class_cache = null)
124
-    {
125
-        // check if class object is instantiated, and instantiated properly
126
-        if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127
-            && $class_cache instanceof ClassInterfaceCache
128
-        ) {
129
-            EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
130
-        }
131
-        return EE_Dependency_Map::$_instance;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param RequestInterface $request
137
-     */
138
-    public function setRequest(RequestInterface $request)
139
-    {
140
-        $this->request = $request;
141
-    }
142
-
143
-
144
-    /**
145
-     * @param LegacyRequestInterface $legacy_request
146
-     */
147
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
148
-    {
149
-        $this->legacy_request = $legacy_request;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param ResponseInterface $response
155
-     */
156
-    public function setResponse(ResponseInterface $response)
157
-    {
158
-        $this->response = $response;
159
-    }
160
-
161
-
162
-    /**
163
-     * @param LoaderInterface $loader
164
-     */
165
-    public function setLoader(LoaderInterface $loader)
166
-    {
167
-        $this->loader = $loader;
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $class
173
-     * @param array  $dependencies
174
-     * @param int    $overwrite
175
-     * @return bool
176
-     */
177
-    public static function register_dependencies(
178
-        $class,
179
-        array $dependencies,
180
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
181
-    ) {
182
-        return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
183
-    }
184
-
185
-
186
-    /**
187
-     * Assigns an array of class names and corresponding load sources (new or cached)
188
-     * to the class specified by the first parameter.
189
-     * IMPORTANT !!!
190
-     * The order of elements in the incoming $dependencies array MUST match
191
-     * the order of the constructor parameters for the class in question.
192
-     * This is especially important when overriding any existing dependencies that are registered.
193
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
194
-     *
195
-     * @param string $class
196
-     * @param array  $dependencies
197
-     * @param int    $overwrite
198
-     * @return bool
199
-     */
200
-    public function registerDependencies(
201
-        $class,
202
-        array $dependencies,
203
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
204
-    ) {
205
-        $class      = trim($class, '\\');
206
-        $registered = false;
207
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
209
-        }
210
-        // we need to make sure that any aliases used when registering a dependency
211
-        // get resolved to the correct class name
212
-        foreach ($dependencies as $dependency => $load_source) {
213
-            $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
216
-            ) {
217
-                unset($dependencies[ $dependency ]);
218
-                $dependencies[ $alias ] = $load_source;
219
-                $registered             = true;
220
-            }
221
-        }
222
-        // now add our two lists of dependencies together.
223
-        // using Union (+=) favours the arrays in precedence from left to right,
224
-        // so $dependencies is NOT overwritten because it is listed first
225
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
226
-        // Union is way faster than array_merge() but should be used with caution...
227
-        // especially with numerically indexed arrays
228
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
229
-        // now we need to ensure that the resulting dependencies
230
-        // array only has the entries that are required for the class
231
-        // so first count how many dependencies were originally registered for the class
232
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
233
-        // if that count is non-zero (meaning dependencies were already registered)
234
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
235
-            // then truncate the  final array to match that count
236
-            ? array_slice($dependencies, 0, $dependency_count)
237
-            // otherwise just take the incoming array because nothing previously existed
238
-            : $dependencies;
239
-        return $registered;
240
-    }
241
-
242
-
243
-    /**
244
-     * @param string $class_name
245
-     * @param string $loader
246
-     * @return bool
247
-     * @throws DomainException
248
-     */
249
-    public static function register_class_loader($class_name, $loader = 'load_core')
250
-    {
251
-        return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader);
252
-    }
253
-
254
-
255
-    /**
256
-     * @param string $class_name
257
-     * @param string $loader
258
-     * @return bool
259
-     * @throws DomainException
260
-     */
261
-    public function registerClassLoader($class_name, $loader = 'load_core')
262
-    {
263
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264
-            throw new DomainException(
265
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266
-            );
267
-        }
268
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
269
-        if (! is_callable($loader)
270
-            && (
271
-                strpos($loader, 'load_') !== 0
272
-                || ! method_exists('EE_Registry', $loader)
273
-            )
274
-        ) {
275
-            throw new DomainException(
276
-                sprintf(
277
-                    esc_html__(
278
-                        '"%1$s" is not a valid loader method on EE_Registry.',
279
-                        'event_espresso'
280
-                    ),
281
-                    $loader
282
-                )
283
-            );
284
-        }
285
-        $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
288
-            return true;
289
-        }
290
-        return false;
291
-    }
292
-
293
-
294
-    /**
295
-     * @return array
296
-     */
297
-    public function dependency_map()
298
-    {
299
-        return $this->_dependency_map;
300
-    }
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[ $class_name ]);
316
-    }
317
-
318
-
319
-    /**
320
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
321
-     *
322
-     * @param string $class_name
323
-     * @param string $dependency
324
-     * @return bool
325
-     */
326
-    public function has_dependency_for_class($class_name = '', $dependency = '')
327
-    {
328
-        // all legacy models have the same dependencies
329
-        if (strpos($class_name, 'EEM_') === 0) {
330
-            $class_name = 'LEGACY_MODELS';
331
-        }
332
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
333
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
334
-    }
335
-
336
-
337
-    /**
338
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
339
-     *
340
-     * @param string $class_name
341
-     * @param string $dependency
342
-     * @return int
343
-     */
344
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
345
-    {
346
-        // all legacy models have the same dependencies
347
-        if (strpos($class_name, 'EEM_') === 0) {
348
-            $class_name = 'LEGACY_MODELS';
349
-        }
350
-        $dependency = $this->getFqnForAlias($dependency);
351
-        return $this->has_dependency_for_class($class_name, $dependency)
352
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
353
-            : EE_Dependency_Map::not_registered;
354
-    }
355
-
356
-
357
-    /**
358
-     * @param string $class_name
359
-     * @return string | Closure
360
-     */
361
-    public function class_loader($class_name)
362
-    {
363
-        // all legacy models use load_model()
364
-        if (strpos($class_name, 'EEM_') === 0) {
365
-            return 'load_model';
366
-        }
367
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
368
-        // perform strpos() first to avoid loading regex every time we load a class
369
-        if (strpos($class_name, 'EE_CPT_') === 0
370
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
371
-        ) {
372
-            return 'load_core';
373
-        }
374
-        $class_name = $this->getFqnForAlias($class_name);
375
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
376
-    }
377
-
378
-
379
-    /**
380
-     * @return array
381
-     */
382
-    public function class_loaders()
383
-    {
384
-        return $this->_class_loaders;
385
-    }
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
394
-     * @throws InvalidAliasException
395
-     */
396
-    public function add_alias($fqcn, $alias, $for_class = '')
397
-    {
398
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
399
-    }
400
-
401
-
402
-    /**
403
-     * Returns TRUE if the provided fully qualified name IS an alias
404
-     * WHY?
405
-     * Because if a class is type hinting for a concretion,
406
-     * then why would we need to find another class to supply it?
407
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
408
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
409
-     * Don't go looking for some substitute.
410
-     * Whereas if a class is type hinting for an interface...
411
-     * then we need to find an actual class to use.
412
-     * So the interface IS the alias for some other FQN,
413
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
414
-     * represents some other class.
415
-     *
416
-     * @param string $fqn
417
-     * @param string $for_class
418
-     * @return bool
419
-     */
420
-    public function isAlias($fqn = '', $for_class = '')
421
-    {
422
-        return $this->class_cache->isAlias($fqn, $for_class);
423
-    }
424
-
425
-
426
-    /**
427
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
428
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $alias
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function getFqnForAlias($alias = '', $for_class = '')
443
-    {
444
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
445
-    }
446
-
447
-
448
-    /**
449
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
450
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
451
-     * This is done by using the following class constants:
452
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
453
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
454
-     */
455
-    protected function _register_core_dependencies()
456
-    {
457
-        $this->_dependency_map = [
458
-            'EE_Request_Handler'                                                                                          => [
459
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
460
-            ],
461
-            'EE_System'                                                                                                   => [
462
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
463
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
464
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
465
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
466
-                'EventEspresso\core\services\routing\Router'  => EE_Dependency_Map::load_from_cache,
467
-            ],
468
-            'EE_Admin'                                                                                                    => [
469
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
471
-            ],
472
-            'EE_Cart'                                                                                                     => [
473
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
474
-            ],
475
-            'EE_Messenger_Collection_Loader'                                                                              => [
476
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
477
-            ],
478
-            'EE_Message_Type_Collection_Loader'                                                                           => [
479
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
480
-            ],
481
-            'EE_Message_Resource_Manager'                                                                                 => [
482
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
483
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
484
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
485
-            ],
486
-            'EE_Message_Factory'                                                                                          => [
487
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
488
-            ],
489
-            'EE_messages'                                                                                                 => [
490
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
491
-            ],
492
-            'EE_Messages_Generator'                                                                                       => [
493
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
494
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
495
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
496
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
497
-            ],
498
-            'EE_Messages_Processor'                                                                                       => [
499
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
500
-            ],
501
-            'EE_Messages_Queue'                                                                                           => [
502
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
503
-            ],
504
-            'EE_Messages_Template_Defaults'                                                                               => [
505
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
506
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
507
-            ],
508
-            'EE_Message_To_Generate_From_Request'                                                                         => [
509
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
510
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
511
-            ],
512
-            'EventEspresso\core\services\commands\CommandBus'                                                             => [
513
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
514
-            ],
515
-            'EventEspresso\services\commands\CommandHandler'                                                              => [
516
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
517
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
518
-            ],
519
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
520
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
521
-            ],
522
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
523
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
524
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
525
-            ],
526
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => [
527
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
528
-            ],
529
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
530
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
531
-            ],
532
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
533
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
534
-            ],
535
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
536
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
537
-            ],
538
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
539
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
540
-            ],
541
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
542
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
543
-            ],
544
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
545
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
546
-            ],
547
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
548
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
-            ],
550
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
551
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
552
-            ],
553
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
554
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
-            ],
556
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
557
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
558
-            ],
559
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
560
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
561
-            ],
562
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
563
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
564
-            ],
565
-            'EventEspresso\core\services\database\TableManager'                                                           => [
566
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
567
-            ],
568
-            'EE_Data_Migration_Class_Base'                                                                                => [
569
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
570
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
571
-            ],
572
-            'EE_DMS_Core_4_1_0'                                                                                           => [
573
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
574
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
575
-            ],
576
-            'EE_DMS_Core_4_2_0'                                                                                           => [
577
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
578
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
579
-            ],
580
-            'EE_DMS_Core_4_3_0'                                                                                           => [
581
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
582
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
583
-            ],
584
-            'EE_DMS_Core_4_4_0'                                                                                           => [
585
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
586
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
587
-            ],
588
-            'EE_DMS_Core_4_5_0'                                                                                           => [
589
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
590
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
591
-            ],
592
-            'EE_DMS_Core_4_6_0'                                                                                           => [
593
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
594
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
595
-            ],
596
-            'EE_DMS_Core_4_7_0'                                                                                           => [
597
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
598
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
599
-            ],
600
-            'EE_DMS_Core_4_8_0'                                                                                           => [
601
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
602
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
603
-            ],
604
-            'EE_DMS_Core_4_9_0'                                                                                           => [
605
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
606
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
607
-            ],
608
-            'EE_DMS_Core_4_10_0'                                                                                          => [
609
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
610
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
611
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
612
-            ],
613
-            'EE_DMS_Core_4_11_0'                                                                                          => [
614
-                'EE_DMS_Core_4_10_0'                                 => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
616
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
617
-            ],
618
-            'EventEspresso\core\services\assets\Registry'                                                                 => [
619
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object,
620
-                'EventEspresso\core\services\assets\AssetManifest'   => EE_Dependency_Map::load_from_cache,
621
-            ],
622
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
623
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
-            ],
625
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
626
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
627
-            ],
628
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
629
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
630
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
631
-            ],
632
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => [
633
-                null,
634
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
635
-            ],
636
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
637
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
638
-            ],
639
-            'LEGACY_MODELS'                                                                                               => [
640
-                null,
641
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
642
-            ],
643
-            'EE_Module_Request_Router'                                                                                    => [
644
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
645
-            ],
646
-            'EE_Registration_Processor'                                                                                   => [
647
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
648
-            ],
649
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
650
-                null,
651
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
652
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
653
-            ],
654
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
655
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
656
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
657
-            ],
658
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
659
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
660
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
661
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
662
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
663
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
664
-            ],
665
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
666
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
667
-            ],
668
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
669
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
670
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
671
-            ],
672
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
673
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
674
-            ],
675
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
676
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
677
-            ],
678
-            'EE_CPT_Strategy'                                                                                             => [
679
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
680
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
681
-            ],
682
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
683
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
684
-            ],
685
-            'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
686
-                null,
687
-                null,
688
-                null,
689
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
690
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
691
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
692
-            ],
693
-            'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
694
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
695
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
696
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
697
-            ],
698
-            'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
699
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
700
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
701
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
702
-            ],
703
-            'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
704
-                'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
705
-                'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
706
-            ],
707
-            'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
708
-                'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
709
-                'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
710
-            ],
711
-            'EE_URL_Validation_Strategy'                                                                                  => [
712
-                null,
713
-                null,
714
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
715
-            ],
716
-            'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
717
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
718
-            ],
719
-            'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
720
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
-            ],
722
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
723
-                'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
724
-                'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
726
-                null,
727
-            ],
728
-            'EventEspresso\core\services\routing\RouteHandler'                                                            => [
729
-                'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\services\loaders\Loader'           => EE_Dependency_Map::load_from_cache,
731
-                'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
732
-                'EventEspresso\core\services\routing\RouteCollection'  => EE_Dependency_Map::load_from_cache,
733
-            ],
734
-            'EventEspresso\core\services\json\JsonDataNodeHandler'                                                        => [
735
-                'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
736
-            ],
737
-            'EventEspresso\core\services\routing\Router'                                                                  => [
738
-                'EE_Dependency_Map'                                => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\services\loaders\Loader'       => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache,
741
-            ],
742
-            'EventEspresso\core\services\assets\AssetManifest'                                                            => [
743
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
744
-            ],
745
-            'EventEspresso\core\services\assets\AssetManifestFactory'                                                     => [
746
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
747
-            ],
748
-            'EventEspresso\core\services\assets\BaristaFactory'                                                           => [
749
-                'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache,
750
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
751
-            ],
752
-            'EventEspresso\core\domain\services\capabilities\FeatureFlags'                                                => [
753
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
754
-            ],
755
-            'EventEspresso\core\services\addon\AddonManager' => [
756
-                'EventEspresso\core\services\addon\AddonCollection'              => EE_Dependency_Map::load_from_cache,
757
-                'EventEspresso\core\Psr4Autoloader'                              => EE_Dependency_Map::load_from_cache,
758
-                'EventEspresso\core\services\addon\api\v1\RegisterAddon'         => EE_Dependency_Map::load_from_cache,
759
-                'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache,
760
-                'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'  => EE_Dependency_Map::load_from_cache,
761
-            ],
762
-            'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [
763
-                'EventEspresso\core\services\request\Request'  => EE_Dependency_Map::load_from_cache,
764
-            ],
765
-        ];
766
-    }
767
-
768
-
769
-    /**
770
-     * Registers how core classes are loaded.
771
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
772
-     *        'EE_Request_Handler' => 'load_core'
773
-     *        'EE_Messages_Queue'  => 'load_lib'
774
-     *        'EEH_Debug_Tools'    => 'load_helper'
775
-     * or, if greater control is required, by providing a custom closure. For example:
776
-     *        'Some_Class' => function () {
777
-     *            return new Some_Class();
778
-     *        },
779
-     * This is required for instantiating dependencies
780
-     * where an interface has been type hinted in a class constructor. For example:
781
-     *        'Required_Interface' => function () {
782
-     *            return new A_Class_That_Implements_Required_Interface();
783
-     *        },
784
-     */
785
-    protected function _register_core_class_loaders()
786
-    {
787
-        $this->_class_loaders = [
788
-            // load_core
789
-            'EE_Dependency_Map'                            => function () {
790
-                return $this;
791
-            },
792
-            'EE_Capabilities'                              => 'load_core',
793
-            'EE_Encryption'                                => 'load_core',
794
-            'EE_Front_Controller'                          => 'load_core',
795
-            'EE_Module_Request_Router'                     => 'load_core',
796
-            'EE_Registry'                                  => 'load_core',
797
-            'EE_Request'                                   => function () {
798
-                return $this->legacy_request;
799
-            },
800
-            'EventEspresso\core\services\request\Request'  => function () {
801
-                return $this->request;
802
-            },
803
-            'EventEspresso\core\services\request\Response' => function () {
804
-                return $this->response;
805
-            },
806
-            'EE_Base'                                      => 'load_core',
807
-            'EE_Request_Handler'                           => 'load_core',
808
-            'EE_Session'                                   => 'load_core',
809
-            'EE_Cron_Tasks'                                => 'load_core',
810
-            'EE_System'                                    => 'load_core',
811
-            'EE_Maintenance_Mode'                          => 'load_core',
812
-            'EE_Register_CPTs'                             => 'load_core',
813
-            'EE_Admin'                                     => 'load_core',
814
-            'EE_CPT_Strategy'                              => 'load_core',
815
-            // load_class
816
-            'EE_Registration_Processor'                    => 'load_class',
817
-            // load_lib
818
-            'EE_Message_Resource_Manager'                  => 'load_lib',
819
-            'EE_Message_Type_Collection'                   => 'load_lib',
820
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
821
-            'EE_Messenger_Collection'                      => 'load_lib',
822
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
823
-            'EE_Messages_Processor'                        => 'load_lib',
824
-            'EE_Message_Repository'                        => 'load_lib',
825
-            'EE_Messages_Queue'                            => 'load_lib',
826
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
827
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
828
-            'EE_Payment_Method_Manager'                    => 'load_lib',
829
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
830
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
831
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
832
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
833
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
834
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
835
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
836
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
837
-            'EE_DMS_Core_4_10_0'                           => 'load_dms',
838
-            'EE_Messages_Generator'                        => static function () {
839
-                return EE_Registry::instance()->load_lib(
840
-                    'Messages_Generator',
841
-                    [],
842
-                    false,
843
-                    false
844
-                );
845
-            },
846
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
847
-                return EE_Registry::instance()->load_lib(
848
-                    'Messages_Template_Defaults',
849
-                    $arguments,
850
-                    false,
851
-                    false
852
-                );
853
-            },
854
-            // load_helper
855
-            'EEH_Parse_Shortcodes'                         => static function () {
856
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
857
-                    return new EEH_Parse_Shortcodes();
858
-                }
859
-                return null;
860
-            },
861
-            'EE_Template_Config'                           => static function () {
862
-                return EE_Config::instance()->template_settings;
863
-            },
864
-            'EE_Currency_Config'                           => static function () {
865
-                return EE_Config::instance()->currency;
866
-            },
867
-            'EE_Registration_Config'                       => static function () {
868
-                return EE_Config::instance()->registration;
869
-            },
870
-            'EE_Core_Config'                               => static function () {
871
-                return EE_Config::instance()->core;
872
-            },
873
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
874
-                return LoaderFactory::getLoader();
875
-            },
876
-            'EE_Network_Config'                            => static function () {
877
-                return EE_Network_Config::instance();
878
-            },
879
-            'EE_Config'                                    => static function () {
880
-                return EE_Config::instance();
881
-            },
882
-            'EventEspresso\core\domain\Domain'             => static function () {
883
-                return DomainFactory::getEventEspressoCoreDomain();
884
-            },
885
-            'EE_Admin_Config'                              => static function () {
886
-                return EE_Config::instance()->admin;
887
-            },
888
-            'EE_Organization_Config'                       => static function () {
889
-                return EE_Config::instance()->organization;
890
-            },
891
-            'EE_Network_Core_Config'                       => static function () {
892
-                return EE_Network_Config::instance()->core;
893
-            },
894
-            'EE_Environment_Config'                        => static function () {
895
-                return EE_Config::instance()->environment;
896
-            },
897
-            'EED_Core_Rest_Api'                            => static function () {
898
-                return EED_Core_Rest_Api::instance();
899
-            },
900
-            'WP_REST_Server'                               => static function () {
901
-                return rest_get_server();
902
-            },
903
-            'EventEspresso\core\Psr4Autoloader'            => static function () {
904
-                return EE_Psr4AutoloaderInit::psr4_loader();
905
-            },
906
-        ];
907
-    }
908
-
909
-
910
-    /**
911
-     * can be used for supplying alternate names for classes,
912
-     * or for connecting interface names to instantiable classes
913
-     *
914
-     * @throws InvalidAliasException
915
-     */
916
-    protected function _register_core_aliases()
917
-    {
918
-        $aliases = [
919
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
920
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
921
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
922
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
923
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
924
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
925
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
926
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
927
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
928
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
929
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
930
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
931
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
932
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
933
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
934
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
935
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
936
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
937
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
938
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
939
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
940
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
941
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
942
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
943
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
944
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
945
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
946
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
947
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
948
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
949
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
950
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
951
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
952
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
953
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
954
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
955
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
956
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
957
-            'EventEspresso\core\services\assets\AssetManifestInterface'                    => 'EventEspresso\core\services\assets\AssetManifest',
958
-        ];
959
-        foreach ($aliases as $alias => $fqn) {
960
-            if (is_array($fqn)) {
961
-                foreach ($fqn as $class => $for_class) {
962
-                    $this->class_cache->addAlias($class, $alias, $for_class);
963
-                }
964
-                continue;
965
-            }
966
-            $this->class_cache->addAlias($fqn, $alias);
967
-        }
968
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
969
-            $this->class_cache->addAlias(
970
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
971
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
972
-            );
973
-        }
974
-    }
975
-
976
-
977
-    /**
978
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
979
-     * request Primarily used by unit tests.
980
-     */
981
-    public function reset()
982
-    {
983
-        $this->_register_core_class_loaders();
984
-        $this->_register_core_dependencies();
985
-    }
986
-
987
-
988
-    /**
989
-     * PLZ NOTE: a better name for this method would be is_alias()
990
-     * because it returns TRUE if the provided fully qualified name IS an alias
991
-     * WHY?
992
-     * Because if a class is type hinting for a concretion,
993
-     * then why would we need to find another class to supply it?
994
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
995
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
996
-     * Don't go looking for some substitute.
997
-     * Whereas if a class is type hinting for an interface...
998
-     * then we need to find an actual class to use.
999
-     * So the interface IS the alias for some other FQN,
1000
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1001
-     * represents some other class.
1002
-     *
1003
-     * @param string $fqn
1004
-     * @param string $for_class
1005
-     * @return bool
1006
-     * @deprecated 4.9.62.p
1007
-     */
1008
-    public function has_alias($fqn = '', $for_class = '')
1009
-    {
1010
-        return $this->isAlias($fqn, $for_class);
1011
-    }
1012
-
1013
-
1014
-    /**
1015
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1016
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1017
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1018
-     *  for example:
1019
-     *      if the following two entries were added to the _aliases array:
1020
-     *          array(
1021
-     *              'interface_alias'           => 'some\namespace\interface'
1022
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1023
-     *          )
1024
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1025
-     *      to load an instance of 'some\namespace\classname'
1026
-     *
1027
-     * @param string $alias
1028
-     * @param string $for_class
1029
-     * @return string
1030
-     * @deprecated 4.9.62.p
1031
-     */
1032
-    public function get_alias($alias = '', $for_class = '')
1033
-    {
1034
-        return $this->getFqnForAlias($alias, $for_class);
1035
-    }
24
+	/**
25
+	 * This means that the requested class dependency is not present in the dependency map
26
+	 */
27
+	const not_registered = 0;
28
+
29
+	/**
30
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
+	 */
32
+	const load_new_object = 1;
33
+
34
+	/**
35
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
+	 */
38
+	const load_from_cache = 2;
39
+
40
+	/**
41
+	 * When registering a dependency,
42
+	 * this indicates to keep any existing dependencies that already exist,
43
+	 * and simply discard any new dependencies declared in the incoming data
44
+	 */
45
+	const KEEP_EXISTING_DEPENDENCIES = 0;
46
+
47
+	/**
48
+	 * When registering a dependency,
49
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
+	 */
51
+	const OVERWRITE_DEPENDENCIES = 1;
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = [];
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = [];
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 * @throws InvalidAliasException
109
+	 */
110
+	public function initialize()
111
+	{
112
+		$this->_register_core_dependencies();
113
+		$this->_register_core_class_loaders();
114
+		$this->_register_core_aliases();
115
+	}
116
+
117
+
118
+	/**
119
+	 * @singleton method used to instantiate class object
120
+	 * @param ClassInterfaceCache|null $class_cache
121
+	 * @return EE_Dependency_Map
122
+	 */
123
+	public static function instance(ClassInterfaceCache $class_cache = null)
124
+	{
125
+		// check if class object is instantiated, and instantiated properly
126
+		if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127
+			&& $class_cache instanceof ClassInterfaceCache
128
+		) {
129
+			EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
130
+		}
131
+		return EE_Dependency_Map::$_instance;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param RequestInterface $request
137
+	 */
138
+	public function setRequest(RequestInterface $request)
139
+	{
140
+		$this->request = $request;
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param LegacyRequestInterface $legacy_request
146
+	 */
147
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
148
+	{
149
+		$this->legacy_request = $legacy_request;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param ResponseInterface $response
155
+	 */
156
+	public function setResponse(ResponseInterface $response)
157
+	{
158
+		$this->response = $response;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param LoaderInterface $loader
164
+	 */
165
+	public function setLoader(LoaderInterface $loader)
166
+	{
167
+		$this->loader = $loader;
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $class
173
+	 * @param array  $dependencies
174
+	 * @param int    $overwrite
175
+	 * @return bool
176
+	 */
177
+	public static function register_dependencies(
178
+		$class,
179
+		array $dependencies,
180
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
181
+	) {
182
+		return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
183
+	}
184
+
185
+
186
+	/**
187
+	 * Assigns an array of class names and corresponding load sources (new or cached)
188
+	 * to the class specified by the first parameter.
189
+	 * IMPORTANT !!!
190
+	 * The order of elements in the incoming $dependencies array MUST match
191
+	 * the order of the constructor parameters for the class in question.
192
+	 * This is especially important when overriding any existing dependencies that are registered.
193
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
194
+	 *
195
+	 * @param string $class
196
+	 * @param array  $dependencies
197
+	 * @param int    $overwrite
198
+	 * @return bool
199
+	 */
200
+	public function registerDependencies(
201
+		$class,
202
+		array $dependencies,
203
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
204
+	) {
205
+		$class      = trim($class, '\\');
206
+		$registered = false;
207
+		if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
+			EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
209
+		}
210
+		// we need to make sure that any aliases used when registering a dependency
211
+		// get resolved to the correct class name
212
+		foreach ($dependencies as $dependency => $load_source) {
213
+			$alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
+				|| ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
216
+			) {
217
+				unset($dependencies[ $dependency ]);
218
+				$dependencies[ $alias ] = $load_source;
219
+				$registered             = true;
220
+			}
221
+		}
222
+		// now add our two lists of dependencies together.
223
+		// using Union (+=) favours the arrays in precedence from left to right,
224
+		// so $dependencies is NOT overwritten because it is listed first
225
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
226
+		// Union is way faster than array_merge() but should be used with caution...
227
+		// especially with numerically indexed arrays
228
+		$dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
229
+		// now we need to ensure that the resulting dependencies
230
+		// array only has the entries that are required for the class
231
+		// so first count how many dependencies were originally registered for the class
232
+		$dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
233
+		// if that count is non-zero (meaning dependencies were already registered)
234
+		EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
235
+			// then truncate the  final array to match that count
236
+			? array_slice($dependencies, 0, $dependency_count)
237
+			// otherwise just take the incoming array because nothing previously existed
238
+			: $dependencies;
239
+		return $registered;
240
+	}
241
+
242
+
243
+	/**
244
+	 * @param string $class_name
245
+	 * @param string $loader
246
+	 * @return bool
247
+	 * @throws DomainException
248
+	 */
249
+	public static function register_class_loader($class_name, $loader = 'load_core')
250
+	{
251
+		return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader);
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param string $class_name
257
+	 * @param string $loader
258
+	 * @return bool
259
+	 * @throws DomainException
260
+	 */
261
+	public function registerClassLoader($class_name, $loader = 'load_core')
262
+	{
263
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264
+			throw new DomainException(
265
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266
+			);
267
+		}
268
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
269
+		if (! is_callable($loader)
270
+			&& (
271
+				strpos($loader, 'load_') !== 0
272
+				|| ! method_exists('EE_Registry', $loader)
273
+			)
274
+		) {
275
+			throw new DomainException(
276
+				sprintf(
277
+					esc_html__(
278
+						'"%1$s" is not a valid loader method on EE_Registry.',
279
+						'event_espresso'
280
+					),
281
+					$loader
282
+				)
283
+			);
284
+		}
285
+		$class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
+		if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
+			EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
288
+			return true;
289
+		}
290
+		return false;
291
+	}
292
+
293
+
294
+	/**
295
+	 * @return array
296
+	 */
297
+	public function dependency_map()
298
+	{
299
+		return $this->_dependency_map;
300
+	}
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[ $class_name ]);
316
+	}
317
+
318
+
319
+	/**
320
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
321
+	 *
322
+	 * @param string $class_name
323
+	 * @param string $dependency
324
+	 * @return bool
325
+	 */
326
+	public function has_dependency_for_class($class_name = '', $dependency = '')
327
+	{
328
+		// all legacy models have the same dependencies
329
+		if (strpos($class_name, 'EEM_') === 0) {
330
+			$class_name = 'LEGACY_MODELS';
331
+		}
332
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
333
+		return isset($this->_dependency_map[ $class_name ][ $dependency ]);
334
+	}
335
+
336
+
337
+	/**
338
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
339
+	 *
340
+	 * @param string $class_name
341
+	 * @param string $dependency
342
+	 * @return int
343
+	 */
344
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
345
+	{
346
+		// all legacy models have the same dependencies
347
+		if (strpos($class_name, 'EEM_') === 0) {
348
+			$class_name = 'LEGACY_MODELS';
349
+		}
350
+		$dependency = $this->getFqnForAlias($dependency);
351
+		return $this->has_dependency_for_class($class_name, $dependency)
352
+			? $this->_dependency_map[ $class_name ][ $dependency ]
353
+			: EE_Dependency_Map::not_registered;
354
+	}
355
+
356
+
357
+	/**
358
+	 * @param string $class_name
359
+	 * @return string | Closure
360
+	 */
361
+	public function class_loader($class_name)
362
+	{
363
+		// all legacy models use load_model()
364
+		if (strpos($class_name, 'EEM_') === 0) {
365
+			return 'load_model';
366
+		}
367
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
368
+		// perform strpos() first to avoid loading regex every time we load a class
369
+		if (strpos($class_name, 'EE_CPT_') === 0
370
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
371
+		) {
372
+			return 'load_core';
373
+		}
374
+		$class_name = $this->getFqnForAlias($class_name);
375
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
376
+	}
377
+
378
+
379
+	/**
380
+	 * @return array
381
+	 */
382
+	public function class_loaders()
383
+	{
384
+		return $this->_class_loaders;
385
+	}
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
394
+	 * @throws InvalidAliasException
395
+	 */
396
+	public function add_alias($fqcn, $alias, $for_class = '')
397
+	{
398
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Returns TRUE if the provided fully qualified name IS an alias
404
+	 * WHY?
405
+	 * Because if a class is type hinting for a concretion,
406
+	 * then why would we need to find another class to supply it?
407
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
408
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
409
+	 * Don't go looking for some substitute.
410
+	 * Whereas if a class is type hinting for an interface...
411
+	 * then we need to find an actual class to use.
412
+	 * So the interface IS the alias for some other FQN,
413
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
414
+	 * represents some other class.
415
+	 *
416
+	 * @param string $fqn
417
+	 * @param string $for_class
418
+	 * @return bool
419
+	 */
420
+	public function isAlias($fqn = '', $for_class = '')
421
+	{
422
+		return $this->class_cache->isAlias($fqn, $for_class);
423
+	}
424
+
425
+
426
+	/**
427
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $alias
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function getFqnForAlias($alias = '', $for_class = '')
443
+	{
444
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
445
+	}
446
+
447
+
448
+	/**
449
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
450
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
451
+	 * This is done by using the following class constants:
452
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
453
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
454
+	 */
455
+	protected function _register_core_dependencies()
456
+	{
457
+		$this->_dependency_map = [
458
+			'EE_Request_Handler'                                                                                          => [
459
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
460
+			],
461
+			'EE_System'                                                                                                   => [
462
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
463
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
464
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
465
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
466
+				'EventEspresso\core\services\routing\Router'  => EE_Dependency_Map::load_from_cache,
467
+			],
468
+			'EE_Admin'                                                                                                    => [
469
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
471
+			],
472
+			'EE_Cart'                                                                                                     => [
473
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
474
+			],
475
+			'EE_Messenger_Collection_Loader'                                                                              => [
476
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
477
+			],
478
+			'EE_Message_Type_Collection_Loader'                                                                           => [
479
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
480
+			],
481
+			'EE_Message_Resource_Manager'                                                                                 => [
482
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
483
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
484
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
485
+			],
486
+			'EE_Message_Factory'                                                                                          => [
487
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
488
+			],
489
+			'EE_messages'                                                                                                 => [
490
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
491
+			],
492
+			'EE_Messages_Generator'                                                                                       => [
493
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
494
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
495
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
496
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
497
+			],
498
+			'EE_Messages_Processor'                                                                                       => [
499
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
500
+			],
501
+			'EE_Messages_Queue'                                                                                           => [
502
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
503
+			],
504
+			'EE_Messages_Template_Defaults'                                                                               => [
505
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
506
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
507
+			],
508
+			'EE_Message_To_Generate_From_Request'                                                                         => [
509
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
510
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
511
+			],
512
+			'EventEspresso\core\services\commands\CommandBus'                                                             => [
513
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
514
+			],
515
+			'EventEspresso\services\commands\CommandHandler'                                                              => [
516
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
517
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
518
+			],
519
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
520
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
521
+			],
522
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
523
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
524
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
525
+			],
526
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => [
527
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
528
+			],
529
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
530
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
531
+			],
532
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
533
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
534
+			],
535
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
536
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
537
+			],
538
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
539
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
540
+			],
541
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
542
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
543
+			],
544
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
545
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
546
+			],
547
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
548
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
+			],
550
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
551
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
552
+			],
553
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
554
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
+			],
556
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
557
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
558
+			],
559
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
560
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
561
+			],
562
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
563
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
564
+			],
565
+			'EventEspresso\core\services\database\TableManager'                                                           => [
566
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
567
+			],
568
+			'EE_Data_Migration_Class_Base'                                                                                => [
569
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
570
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
571
+			],
572
+			'EE_DMS_Core_4_1_0'                                                                                           => [
573
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
574
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
575
+			],
576
+			'EE_DMS_Core_4_2_0'                                                                                           => [
577
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
578
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
579
+			],
580
+			'EE_DMS_Core_4_3_0'                                                                                           => [
581
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
582
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
583
+			],
584
+			'EE_DMS_Core_4_4_0'                                                                                           => [
585
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
586
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
587
+			],
588
+			'EE_DMS_Core_4_5_0'                                                                                           => [
589
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
590
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
591
+			],
592
+			'EE_DMS_Core_4_6_0'                                                                                           => [
593
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
594
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
595
+			],
596
+			'EE_DMS_Core_4_7_0'                                                                                           => [
597
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
598
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
599
+			],
600
+			'EE_DMS_Core_4_8_0'                                                                                           => [
601
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
602
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
603
+			],
604
+			'EE_DMS_Core_4_9_0'                                                                                           => [
605
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
606
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
607
+			],
608
+			'EE_DMS_Core_4_10_0'                                                                                          => [
609
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
610
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
611
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
612
+			],
613
+			'EE_DMS_Core_4_11_0'                                                                                          => [
614
+				'EE_DMS_Core_4_10_0'                                 => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
616
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
617
+			],
618
+			'EventEspresso\core\services\assets\Registry'                                                                 => [
619
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object,
620
+				'EventEspresso\core\services\assets\AssetManifest'   => EE_Dependency_Map::load_from_cache,
621
+			],
622
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
623
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
+			],
625
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
626
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
627
+			],
628
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
629
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
630
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
631
+			],
632
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => [
633
+				null,
634
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
635
+			],
636
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
637
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
638
+			],
639
+			'LEGACY_MODELS'                                                                                               => [
640
+				null,
641
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
642
+			],
643
+			'EE_Module_Request_Router'                                                                                    => [
644
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
645
+			],
646
+			'EE_Registration_Processor'                                                                                   => [
647
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
648
+			],
649
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
650
+				null,
651
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
652
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
653
+			],
654
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
655
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
656
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
657
+			],
658
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
659
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
660
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
661
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
662
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
663
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
664
+			],
665
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
666
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
667
+			],
668
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
669
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
670
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
671
+			],
672
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
673
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
674
+			],
675
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
676
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
677
+			],
678
+			'EE_CPT_Strategy'                                                                                             => [
679
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
680
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
681
+			],
682
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
683
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
684
+			],
685
+			'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
686
+				null,
687
+				null,
688
+				null,
689
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
690
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
691
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
692
+			],
693
+			'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
694
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
695
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
696
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
697
+			],
698
+			'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
699
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
700
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
701
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
702
+			],
703
+			'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
704
+				'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
705
+				'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
706
+			],
707
+			'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
708
+				'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
709
+				'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
710
+			],
711
+			'EE_URL_Validation_Strategy'                                                                                  => [
712
+				null,
713
+				null,
714
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
715
+			],
716
+			'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
717
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
718
+			],
719
+			'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
720
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
+			],
722
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
723
+				'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
724
+				'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
726
+				null,
727
+			],
728
+			'EventEspresso\core\services\routing\RouteHandler'                                                            => [
729
+				'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\services\loaders\Loader'           => EE_Dependency_Map::load_from_cache,
731
+				'EventEspresso\core\services\request\Request'          => EE_Dependency_Map::load_from_cache,
732
+				'EventEspresso\core\services\routing\RouteCollection'  => EE_Dependency_Map::load_from_cache,
733
+			],
734
+			'EventEspresso\core\services\json\JsonDataNodeHandler'                                                        => [
735
+				'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
736
+			],
737
+			'EventEspresso\core\services\routing\Router'                                                                  => [
738
+				'EE_Dependency_Map'                                => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\services\loaders\Loader'       => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache,
741
+			],
742
+			'EventEspresso\core\services\assets\AssetManifest'                                                            => [
743
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
744
+			],
745
+			'EventEspresso\core\services\assets\AssetManifestFactory'                                                     => [
746
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
747
+			],
748
+			'EventEspresso\core\services\assets\BaristaFactory'                                                           => [
749
+				'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache,
750
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
751
+			],
752
+			'EventEspresso\core\domain\services\capabilities\FeatureFlags'                                                => [
753
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
754
+			],
755
+			'EventEspresso\core\services\addon\AddonManager' => [
756
+				'EventEspresso\core\services\addon\AddonCollection'              => EE_Dependency_Map::load_from_cache,
757
+				'EventEspresso\core\Psr4Autoloader'                              => EE_Dependency_Map::load_from_cache,
758
+				'EventEspresso\core\services\addon\api\v1\RegisterAddon'         => EE_Dependency_Map::load_from_cache,
759
+				'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache,
760
+				'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler'  => EE_Dependency_Map::load_from_cache,
761
+			],
762
+			'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [
763
+				'EventEspresso\core\services\request\Request'  => EE_Dependency_Map::load_from_cache,
764
+			],
765
+		];
766
+	}
767
+
768
+
769
+	/**
770
+	 * Registers how core classes are loaded.
771
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
772
+	 *        'EE_Request_Handler' => 'load_core'
773
+	 *        'EE_Messages_Queue'  => 'load_lib'
774
+	 *        'EEH_Debug_Tools'    => 'load_helper'
775
+	 * or, if greater control is required, by providing a custom closure. For example:
776
+	 *        'Some_Class' => function () {
777
+	 *            return new Some_Class();
778
+	 *        },
779
+	 * This is required for instantiating dependencies
780
+	 * where an interface has been type hinted in a class constructor. For example:
781
+	 *        'Required_Interface' => function () {
782
+	 *            return new A_Class_That_Implements_Required_Interface();
783
+	 *        },
784
+	 */
785
+	protected function _register_core_class_loaders()
786
+	{
787
+		$this->_class_loaders = [
788
+			// load_core
789
+			'EE_Dependency_Map'                            => function () {
790
+				return $this;
791
+			},
792
+			'EE_Capabilities'                              => 'load_core',
793
+			'EE_Encryption'                                => 'load_core',
794
+			'EE_Front_Controller'                          => 'load_core',
795
+			'EE_Module_Request_Router'                     => 'load_core',
796
+			'EE_Registry'                                  => 'load_core',
797
+			'EE_Request'                                   => function () {
798
+				return $this->legacy_request;
799
+			},
800
+			'EventEspresso\core\services\request\Request'  => function () {
801
+				return $this->request;
802
+			},
803
+			'EventEspresso\core\services\request\Response' => function () {
804
+				return $this->response;
805
+			},
806
+			'EE_Base'                                      => 'load_core',
807
+			'EE_Request_Handler'                           => 'load_core',
808
+			'EE_Session'                                   => 'load_core',
809
+			'EE_Cron_Tasks'                                => 'load_core',
810
+			'EE_System'                                    => 'load_core',
811
+			'EE_Maintenance_Mode'                          => 'load_core',
812
+			'EE_Register_CPTs'                             => 'load_core',
813
+			'EE_Admin'                                     => 'load_core',
814
+			'EE_CPT_Strategy'                              => 'load_core',
815
+			// load_class
816
+			'EE_Registration_Processor'                    => 'load_class',
817
+			// load_lib
818
+			'EE_Message_Resource_Manager'                  => 'load_lib',
819
+			'EE_Message_Type_Collection'                   => 'load_lib',
820
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
821
+			'EE_Messenger_Collection'                      => 'load_lib',
822
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
823
+			'EE_Messages_Processor'                        => 'load_lib',
824
+			'EE_Message_Repository'                        => 'load_lib',
825
+			'EE_Messages_Queue'                            => 'load_lib',
826
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
827
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
828
+			'EE_Payment_Method_Manager'                    => 'load_lib',
829
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
830
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
831
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
832
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
833
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
834
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
835
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
836
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
837
+			'EE_DMS_Core_4_10_0'                           => 'load_dms',
838
+			'EE_Messages_Generator'                        => static function () {
839
+				return EE_Registry::instance()->load_lib(
840
+					'Messages_Generator',
841
+					[],
842
+					false,
843
+					false
844
+				);
845
+			},
846
+			'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
847
+				return EE_Registry::instance()->load_lib(
848
+					'Messages_Template_Defaults',
849
+					$arguments,
850
+					false,
851
+					false
852
+				);
853
+			},
854
+			// load_helper
855
+			'EEH_Parse_Shortcodes'                         => static function () {
856
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
857
+					return new EEH_Parse_Shortcodes();
858
+				}
859
+				return null;
860
+			},
861
+			'EE_Template_Config'                           => static function () {
862
+				return EE_Config::instance()->template_settings;
863
+			},
864
+			'EE_Currency_Config'                           => static function () {
865
+				return EE_Config::instance()->currency;
866
+			},
867
+			'EE_Registration_Config'                       => static function () {
868
+				return EE_Config::instance()->registration;
869
+			},
870
+			'EE_Core_Config'                               => static function () {
871
+				return EE_Config::instance()->core;
872
+			},
873
+			'EventEspresso\core\services\loaders\Loader'   => static function () {
874
+				return LoaderFactory::getLoader();
875
+			},
876
+			'EE_Network_Config'                            => static function () {
877
+				return EE_Network_Config::instance();
878
+			},
879
+			'EE_Config'                                    => static function () {
880
+				return EE_Config::instance();
881
+			},
882
+			'EventEspresso\core\domain\Domain'             => static function () {
883
+				return DomainFactory::getEventEspressoCoreDomain();
884
+			},
885
+			'EE_Admin_Config'                              => static function () {
886
+				return EE_Config::instance()->admin;
887
+			},
888
+			'EE_Organization_Config'                       => static function () {
889
+				return EE_Config::instance()->organization;
890
+			},
891
+			'EE_Network_Core_Config'                       => static function () {
892
+				return EE_Network_Config::instance()->core;
893
+			},
894
+			'EE_Environment_Config'                        => static function () {
895
+				return EE_Config::instance()->environment;
896
+			},
897
+			'EED_Core_Rest_Api'                            => static function () {
898
+				return EED_Core_Rest_Api::instance();
899
+			},
900
+			'WP_REST_Server'                               => static function () {
901
+				return rest_get_server();
902
+			},
903
+			'EventEspresso\core\Psr4Autoloader'            => static function () {
904
+				return EE_Psr4AutoloaderInit::psr4_loader();
905
+			},
906
+		];
907
+	}
908
+
909
+
910
+	/**
911
+	 * can be used for supplying alternate names for classes,
912
+	 * or for connecting interface names to instantiable classes
913
+	 *
914
+	 * @throws InvalidAliasException
915
+	 */
916
+	protected function _register_core_aliases()
917
+	{
918
+		$aliases = [
919
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
920
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
921
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
922
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
923
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
924
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
925
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
926
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
927
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
928
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
929
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
930
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
931
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
932
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
933
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
934
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
935
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
936
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
937
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
938
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
939
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
940
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
941
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
942
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
943
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
944
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
945
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
946
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
947
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
948
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
949
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
950
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
951
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
952
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
953
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
954
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
955
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
956
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
957
+			'EventEspresso\core\services\assets\AssetManifestInterface'                    => 'EventEspresso\core\services\assets\AssetManifest',
958
+		];
959
+		foreach ($aliases as $alias => $fqn) {
960
+			if (is_array($fqn)) {
961
+				foreach ($fqn as $class => $for_class) {
962
+					$this->class_cache->addAlias($class, $alias, $for_class);
963
+				}
964
+				continue;
965
+			}
966
+			$this->class_cache->addAlias($fqn, $alias);
967
+		}
968
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
969
+			$this->class_cache->addAlias(
970
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
971
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
972
+			);
973
+		}
974
+	}
975
+
976
+
977
+	/**
978
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
979
+	 * request Primarily used by unit tests.
980
+	 */
981
+	public function reset()
982
+	{
983
+		$this->_register_core_class_loaders();
984
+		$this->_register_core_dependencies();
985
+	}
986
+
987
+
988
+	/**
989
+	 * PLZ NOTE: a better name for this method would be is_alias()
990
+	 * because it returns TRUE if the provided fully qualified name IS an alias
991
+	 * WHY?
992
+	 * Because if a class is type hinting for a concretion,
993
+	 * then why would we need to find another class to supply it?
994
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
995
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
996
+	 * Don't go looking for some substitute.
997
+	 * Whereas if a class is type hinting for an interface...
998
+	 * then we need to find an actual class to use.
999
+	 * So the interface IS the alias for some other FQN,
1000
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1001
+	 * represents some other class.
1002
+	 *
1003
+	 * @param string $fqn
1004
+	 * @param string $for_class
1005
+	 * @return bool
1006
+	 * @deprecated 4.9.62.p
1007
+	 */
1008
+	public function has_alias($fqn = '', $for_class = '')
1009
+	{
1010
+		return $this->isAlias($fqn, $for_class);
1011
+	}
1012
+
1013
+
1014
+	/**
1015
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1016
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1017
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1018
+	 *  for example:
1019
+	 *      if the following two entries were added to the _aliases array:
1020
+	 *          array(
1021
+	 *              'interface_alias'           => 'some\namespace\interface'
1022
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1023
+	 *          )
1024
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1025
+	 *      to load an instance of 'some\namespace\classname'
1026
+	 *
1027
+	 * @param string $alias
1028
+	 * @param string $for_class
1029
+	 * @return string
1030
+	 * @deprecated 4.9.62.p
1031
+	 */
1032
+	public function get_alias($alias = '', $for_class = '')
1033
+	{
1034
+		return $this->getFqnForAlias($alias, $for_class);
1035
+	}
1036 1036
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public static function instance(ClassInterfaceCache $class_cache = null)
124 124
     {
125 125
         // check if class object is instantiated, and instantiated properly
126
-        if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
126
+        if ( ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127 127
             && $class_cache instanceof ClassInterfaceCache
128 128
         ) {
129 129
             EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
     ) {
205 205
         $class      = trim($class, '\\');
206 206
         $registered = false;
207
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
207
+        if (empty(EE_Dependency_Map::$_instance->_dependency_map[$class])) {
208
+            EE_Dependency_Map::$_instance->_dependency_map[$class] = [];
209 209
         }
210 210
         // we need to make sure that any aliases used when registering a dependency
211 211
         // get resolved to the correct class name
212 212
         foreach ($dependencies as $dependency => $load_source) {
213 213
             $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214 214
             if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
215
+                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[$class][$alias])
216 216
             ) {
217
-                unset($dependencies[ $dependency ]);
218
-                $dependencies[ $alias ] = $load_source;
217
+                unset($dependencies[$dependency]);
218
+                $dependencies[$alias] = $load_source;
219 219
                 $registered             = true;
220 220
             }
221 221
         }
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
226 226
         // Union is way faster than array_merge() but should be used with caution...
227 227
         // especially with numerically indexed arrays
228
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
228
+        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[$class];
229 229
         // now we need to ensure that the resulting dependencies
230 230
         // array only has the entries that are required for the class
231 231
         // so first count how many dependencies were originally registered for the class
232
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
232
+        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[$class]);
233 233
         // if that count is non-zero (meaning dependencies were already registered)
234
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
234
+        EE_Dependency_Map::$_instance->_dependency_map[$class] = $dependency_count
235 235
             // then truncate the  final array to match that count
236 236
             ? array_slice($dependencies, 0, $dependency_count)
237 237
             // otherwise just take the incoming array because nothing previously existed
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function registerClassLoader($class_name, $loader = 'load_core')
262 262
     {
263
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
263
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264 264
             throw new DomainException(
265 265
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266 266
             );
267 267
         }
268 268
         // check that loader is callable or method starts with "load_" and exists in EE_Registry
269
-        if (! is_callable($loader)
269
+        if ( ! is_callable($loader)
270 270
             && (
271 271
                 strpos($loader, 'load_') !== 0
272 272
                 || ! method_exists('EE_Registry', $loader)
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
             );
284 284
         }
285 285
         $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
286
+        if ( ! isset(EE_Dependency_Map::$_instance->_class_loaders[$class_name])) {
287
+            EE_Dependency_Map::$_instance->_class_loaders[$class_name] = $loader;
288 288
             return true;
289 289
         }
290 290
         return false;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         if (strpos($class_name, 'EEM_') === 0) {
313 313
             $class_name = 'LEGACY_MODELS';
314 314
         }
315
-        return isset($this->_dependency_map[ $class_name ]);
315
+        return isset($this->_dependency_map[$class_name]);
316 316
     }
317 317
 
318 318
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             $class_name = 'LEGACY_MODELS';
331 331
         }
332 332
         $dependency = $this->getFqnForAlias($dependency, $class_name);
333
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
333
+        return isset($this->_dependency_map[$class_name][$dependency]);
334 334
     }
335 335
 
336 336
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         }
350 350
         $dependency = $this->getFqnForAlias($dependency);
351 351
         return $this->has_dependency_for_class($class_name, $dependency)
352
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
352
+            ? $this->_dependency_map[$class_name][$dependency]
353 353
             : EE_Dependency_Map::not_registered;
354 354
     }
355 355
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
             return 'load_core';
373 373
         }
374 374
         $class_name = $this->getFqnForAlias($class_name);
375
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
375
+        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
376 376
     }
377 377
 
378 378
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     {
787 787
         $this->_class_loaders = [
788 788
             // load_core
789
-            'EE_Dependency_Map'                            => function () {
789
+            'EE_Dependency_Map'                            => function() {
790 790
                 return $this;
791 791
             },
792 792
             'EE_Capabilities'                              => 'load_core',
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
             'EE_Front_Controller'                          => 'load_core',
795 795
             'EE_Module_Request_Router'                     => 'load_core',
796 796
             'EE_Registry'                                  => 'load_core',
797
-            'EE_Request'                                   => function () {
797
+            'EE_Request'                                   => function() {
798 798
                 return $this->legacy_request;
799 799
             },
800
-            'EventEspresso\core\services\request\Request'  => function () {
800
+            'EventEspresso\core\services\request\Request'  => function() {
801 801
                 return $this->request;
802 802
             },
803
-            'EventEspresso\core\services\request\Response' => function () {
803
+            'EventEspresso\core\services\request\Response' => function() {
804 804
                 return $this->response;
805 805
             },
806 806
             'EE_Base'                                      => 'load_core',
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
             'EE_DMS_Core_4_8_0'                            => 'load_dms',
836 836
             'EE_DMS_Core_4_9_0'                            => 'load_dms',
837 837
             'EE_DMS_Core_4_10_0'                           => 'load_dms',
838
-            'EE_Messages_Generator'                        => static function () {
838
+            'EE_Messages_Generator'                        => static function() {
839 839
                 return EE_Registry::instance()->load_lib(
840 840
                     'Messages_Generator',
841 841
                     [],
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                     false
844 844
                 );
845 845
             },
846
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
846
+            'EE_Messages_Template_Defaults'                => static function($arguments = []) {
847 847
                 return EE_Registry::instance()->load_lib(
848 848
                     'Messages_Template_Defaults',
849 849
                     $arguments,
@@ -852,55 +852,55 @@  discard block
 block discarded – undo
852 852
                 );
853 853
             },
854 854
             // load_helper
855
-            'EEH_Parse_Shortcodes'                         => static function () {
855
+            'EEH_Parse_Shortcodes'                         => static function() {
856 856
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
857 857
                     return new EEH_Parse_Shortcodes();
858 858
                 }
859 859
                 return null;
860 860
             },
861
-            'EE_Template_Config'                           => static function () {
861
+            'EE_Template_Config'                           => static function() {
862 862
                 return EE_Config::instance()->template_settings;
863 863
             },
864
-            'EE_Currency_Config'                           => static function () {
864
+            'EE_Currency_Config'                           => static function() {
865 865
                 return EE_Config::instance()->currency;
866 866
             },
867
-            'EE_Registration_Config'                       => static function () {
867
+            'EE_Registration_Config'                       => static function() {
868 868
                 return EE_Config::instance()->registration;
869 869
             },
870
-            'EE_Core_Config'                               => static function () {
870
+            'EE_Core_Config'                               => static function() {
871 871
                 return EE_Config::instance()->core;
872 872
             },
873
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
873
+            'EventEspresso\core\services\loaders\Loader'   => static function() {
874 874
                 return LoaderFactory::getLoader();
875 875
             },
876
-            'EE_Network_Config'                            => static function () {
876
+            'EE_Network_Config'                            => static function() {
877 877
                 return EE_Network_Config::instance();
878 878
             },
879
-            'EE_Config'                                    => static function () {
879
+            'EE_Config'                                    => static function() {
880 880
                 return EE_Config::instance();
881 881
             },
882
-            'EventEspresso\core\domain\Domain'             => static function () {
882
+            'EventEspresso\core\domain\Domain'             => static function() {
883 883
                 return DomainFactory::getEventEspressoCoreDomain();
884 884
             },
885
-            'EE_Admin_Config'                              => static function () {
885
+            'EE_Admin_Config'                              => static function() {
886 886
                 return EE_Config::instance()->admin;
887 887
             },
888
-            'EE_Organization_Config'                       => static function () {
888
+            'EE_Organization_Config'                       => static function() {
889 889
                 return EE_Config::instance()->organization;
890 890
             },
891
-            'EE_Network_Core_Config'                       => static function () {
891
+            'EE_Network_Core_Config'                       => static function() {
892 892
                 return EE_Network_Config::instance()->core;
893 893
             },
894
-            'EE_Environment_Config'                        => static function () {
894
+            'EE_Environment_Config'                        => static function() {
895 895
                 return EE_Config::instance()->environment;
896 896
             },
897
-            'EED_Core_Rest_Api'                            => static function () {
897
+            'EED_Core_Rest_Api'                            => static function() {
898 898
                 return EED_Core_Rest_Api::instance();
899 899
             },
900
-            'WP_REST_Server'                               => static function () {
900
+            'WP_REST_Server'                               => static function() {
901 901
                 return rest_get_server();
902 902
             },
903
-            'EventEspresso\core\Psr4Autoloader'            => static function () {
903
+            'EventEspresso\core\Psr4Autoloader'            => static function() {
904 904
                 return EE_Psr4AutoloaderInit::psr4_loader();
905 905
             },
906 906
         ];
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
             }
966 966
             $this->class_cache->addAlias($fqn, $alias);
967 967
         }
968
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
968
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
969 969
             $this->class_cache->addAlias(
970 970
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
971 971
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
core/domain/values/FilePath.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
 class FilePath
17 17
 {
18 18
 
19
-    /**
20
-     * @var string file_path
21
-     */
22
-    private $file_path;
23
-
24
-
25
-    /**
26
-     * FilePath constructor.
27
-     *
28
-     * @param string $file_path
29
-     * @throws InvalidDataTypeException
30
-     * @throws InvalidFilePathException
31
-     */
32
-    public function __construct(string $file_path)
33
-    {
34
-        if (! is_string($file_path)) {
35
-            throw new InvalidDataTypeException(
36
-                '$file_path',
37
-                $file_path,
38
-                'string'
39
-            );
40
-        }
41
-        if (! is_readable($file_path)) {
42
-            throw new InvalidFilePathException($file_path);
43
-        }
44
-        $this->file_path = $file_path;
45
-    }
46
-
47
-
48
-    /**
49
-     * @return string
50
-     */
51
-    public function __toString(): string
52
-    {
53
-        return $this->file_path;
54
-    }
19
+	/**
20
+	 * @var string file_path
21
+	 */
22
+	private $file_path;
23
+
24
+
25
+	/**
26
+	 * FilePath constructor.
27
+	 *
28
+	 * @param string $file_path
29
+	 * @throws InvalidDataTypeException
30
+	 * @throws InvalidFilePathException
31
+	 */
32
+	public function __construct(string $file_path)
33
+	{
34
+		if (! is_string($file_path)) {
35
+			throw new InvalidDataTypeException(
36
+				'$file_path',
37
+				$file_path,
38
+				'string'
39
+			);
40
+		}
41
+		if (! is_readable($file_path)) {
42
+			throw new InvalidFilePathException($file_path);
43
+		}
44
+		$this->file_path = $file_path;
45
+	}
46
+
47
+
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function __toString(): string
52
+	{
53
+		return $this->file_path;
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@
 block discarded – undo
31 31
      */
32 32
     public function __construct(string $file_path)
33 33
     {
34
-        if (! is_string($file_path)) {
34
+        if ( ! is_string($file_path)) {
35 35
             throw new InvalidDataTypeException(
36 36
                 '$file_path',
37 37
                 $file_path,
38 38
                 'string'
39 39
             );
40 40
         }
41
-        if (! is_readable($file_path)) {
41
+        if ( ! is_readable($file_path)) {
42 42
             throw new InvalidFilePathException($file_path);
43 43
         }
44 44
         $this->file_path = $file_path;
Please login to merge, or discard this patch.