Completed
Branch FET/reg-form-builder/main (69a760)
by
unknown
04:39 queued 02:08
created
core/EE_Psr4AutoloaderInit.core.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,41 +17,41 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @type Psr4Autoloader
22
-     */
23
-    protected static $psr4_loader;
24
-
25
-
26
-    /**
27
-     * @return void
28
-     * @throws EE_Error
29
-     */
30
-    public function initializeAutoloader()
31
-    {
32
-        static $initialized = false;
33
-        if (! $initialized) {
34
-            // instantiate PSR4 autoloader
35
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
36
-            EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
37
-            // register the autoloader
38
-            EE_Psr4AutoloaderInit::$psr4_loader->register();
39
-            // register the base directories for the namespace prefix
40
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
41
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
42
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
43
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EETests', EE_PLUGIN_DIR_PATH . 'tests');
44
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EndyJasmi', EE_THIRD_PARTY . 'cuid');
45
-            $initialized = true;
46
-        }
47
-    }
48
-
49
-
50
-    /**
51
-     * @return Psr4Autoloader
52
-     */
53
-    public static function psr4_loader(): Psr4Autoloader
54
-    {
55
-        return self::$psr4_loader;
56
-    }
20
+	/**
21
+	 * @type Psr4Autoloader
22
+	 */
23
+	protected static $psr4_loader;
24
+
25
+
26
+	/**
27
+	 * @return void
28
+	 * @throws EE_Error
29
+	 */
30
+	public function initializeAutoloader()
31
+	{
32
+		static $initialized = false;
33
+		if (! $initialized) {
34
+			// instantiate PSR4 autoloader
35
+			espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
36
+			EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
37
+			// register the autoloader
38
+			EE_Psr4AutoloaderInit::$psr4_loader->register();
39
+			// register the base directories for the namespace prefix
40
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
41
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
42
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
43
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EETests', EE_PLUGIN_DIR_PATH . 'tests');
44
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EndyJasmi', EE_THIRD_PARTY . 'cuid');
45
+			$initialized = true;
46
+		}
47
+	}
48
+
49
+
50
+	/**
51
+	 * @return Psr4Autoloader
52
+	 */
53
+	public static function psr4_loader(): Psr4Autoloader
54
+	{
55
+		return self::$psr4_loader;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,18 +30,18 @@
 block discarded – undo
30 30
     public function initializeAutoloader()
31 31
     {
32 32
         static $initialized = false;
33
-        if (! $initialized) {
33
+        if ( ! $initialized) {
34 34
             // instantiate PSR4 autoloader
35
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
35
+            espresso_load_required('Psr4Autoloader', EE_CORE.'Psr4Autoloader.php');
36 36
             EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
37 37
             // register the autoloader
38 38
             EE_Psr4AutoloaderInit::$psr4_loader->register();
39 39
             // register the base directories for the namespace prefix
40 40
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
41
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
41
+            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES.'batch');
42 42
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
43
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EETests', EE_PLUGIN_DIR_PATH . 'tests');
44
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EndyJasmi', EE_THIRD_PARTY . 'cuid');
43
+            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EETests', EE_PLUGIN_DIR_PATH.'tests');
44
+            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EndyJasmi', EE_THIRD_PARTY.'cuid');
45 45
             $initialized = true;
46 46
         }
47 47
     }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Model.lib.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,194 +11,194 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Register_Model implements EEI_Plugin_API
13 13
 {
14
-    /**
15
-     *
16
-     * @var array keys are the model_id used to register with, values are the array provided to register them, exactly
17
-     *      like EE_Register_Model::register()'s 2nd arg
18
-     */
19
-    protected static $_model_registry;
14
+	/**
15
+	 *
16
+	 * @var array keys are the model_id used to register with, values are the array provided to register them, exactly
17
+	 *      like EE_Register_Model::register()'s 2nd arg
18
+	 */
19
+	protected static $_model_registry;
20 20
 
21
-    /**
22
-     *
23
-     * @var array keys are model names, values are their class names. Stored on registration and used
24
-     * on a hook
25
-     */
26
-    protected static $_model_name_to_classname_map;
21
+	/**
22
+	 *
23
+	 * @var array keys are model names, values are their class names. Stored on registration and used
24
+	 * on a hook
25
+	 */
26
+	protected static $_model_name_to_classname_map;
27 27
 
28 28
 
29
-    /**
30
-     * @param string $addon_name  unique id for it
31
-     * @param array  $setup_args  {
32
-     * @type array   $model_paths array of folders containing DB models, where each file follows the models naming
33
-     *                            convention, which is: EEM_{model_name}.model.php which contains a single class called
34
-     *                            EEM_{model_name}. Eg. you could pass
35
-     *                            "public_html/wp-content/plugins/my_addon/db_models" (with or without trailing slash)
36
-     *                            and in that folder put each of your model files, like "EEM_Food.model.php" which
37
-     *                            contains the class "EEM_Food" and
38
-     *                            "EEM_Monkey.model.php" which contains the class "EEM_Monkey". These will be
39
-     *                            autoloaded and added to the EE registry so they can be used like ordinary models. The
40
-     *                            class contained in each file should extend EEM_Base.
41
-     * @type array   $class_paths array of folders containing DB classes, where each file follows the model class
42
-     *                            naming convention, which is EE_{model_name}.class.php. The class contained in each
43
-     *                            file should extend EE_Base_Class
44
-     *
45
-     * }
46
-     * @return bool
47
-     * @throws EE_Error
48
-     */
49
-    public static function register(string $addon_name = '', array $setup_args = []): bool
50
-    {
51
-        // required fields MUST be present, so let's make sure they are.
52
-        if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['model_paths'])) {
53
-            throw new EE_Error(
54
-                __(
55
-                    'In order to register Models with EE_Register_Model::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_paths" (an array of full server paths to folders that contain models)',
56
-                    'event_espresso'
57
-                )
58
-            );
59
-        }
29
+	/**
30
+	 * @param string $addon_name  unique id for it
31
+	 * @param array  $setup_args  {
32
+	 * @type array   $model_paths array of folders containing DB models, where each file follows the models naming
33
+	 *                            convention, which is: EEM_{model_name}.model.php which contains a single class called
34
+	 *                            EEM_{model_name}. Eg. you could pass
35
+	 *                            "public_html/wp-content/plugins/my_addon/db_models" (with or without trailing slash)
36
+	 *                            and in that folder put each of your model files, like "EEM_Food.model.php" which
37
+	 *                            contains the class "EEM_Food" and
38
+	 *                            "EEM_Monkey.model.php" which contains the class "EEM_Monkey". These will be
39
+	 *                            autoloaded and added to the EE registry so they can be used like ordinary models. The
40
+	 *                            class contained in each file should extend EEM_Base.
41
+	 * @type array   $class_paths array of folders containing DB classes, where each file follows the model class
42
+	 *                            naming convention, which is EE_{model_name}.class.php. The class contained in each
43
+	 *                            file should extend EE_Base_Class
44
+	 *
45
+	 * }
46
+	 * @return bool
47
+	 * @throws EE_Error
48
+	 */
49
+	public static function register(string $addon_name = '', array $setup_args = []): bool
50
+	{
51
+		// required fields MUST be present, so let's make sure they are.
52
+		if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['model_paths'])) {
53
+			throw new EE_Error(
54
+				__(
55
+					'In order to register Models with EE_Register_Model::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_paths" (an array of full server paths to folders that contain models)',
56
+					'event_espresso'
57
+				)
58
+			);
59
+		}
60 60
 
61
-        // make sure we don't register twice
62
-        if (isset(self::$_model_registry[ $addon_name ])) {
63
-            return true;
64
-        }
61
+		// make sure we don't register twice
62
+		if (isset(self::$_model_registry[ $addon_name ])) {
63
+			return true;
64
+		}
65 65
 
66
-        if (
67
-            ! did_action('AHEE__EE_System__load_espresso_addons')
68
-            || did_action('FHEE__EE_System__parse_model_names')
69
-            || did_action('FHEE__EE_System__parse_implemented_model_names')
70
-        ) {
71
-            EE_Error::doing_it_wrong(
72
-                __METHOD__,
73
-                sprintf(
74
-                    __(
75
-                        'An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.',
76
-                        'event_espresso'
77
-                    ),
78
-                    $addon_name
79
-                ),
80
-                '4.5'
81
-            );
82
-        }
83
-        self::$_model_registry[ $addon_name ] = $setup_args;
66
+		if (
67
+			! did_action('AHEE__EE_System__load_espresso_addons')
68
+			|| did_action('FHEE__EE_System__parse_model_names')
69
+			|| did_action('FHEE__EE_System__parse_implemented_model_names')
70
+		) {
71
+			EE_Error::doing_it_wrong(
72
+				__METHOD__,
73
+				sprintf(
74
+					__(
75
+						'An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.',
76
+						'event_espresso'
77
+					),
78
+					$addon_name
79
+				),
80
+				'4.5'
81
+			);
82
+		}
83
+		self::$_model_registry[ $addon_name ] = $setup_args;
84 84
 
85
-        if (
86
-            (
87
-                isset($setup_args['model_paths']) && ! isset($setup_args['class_paths'])
88
-            )
89
-            || (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
90
-        ) {
91
-            throw new EE_Error(
92
-                sprintf(
93
-                    __(
94
-                        'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
95
-                        'event_espresso'
96
-                    ),
97
-                    implode(", ", array_keys($setup_args))
98
-                )
99
-            );
100
-        }
101
-        if (isset($setup_args['model_paths'])) {
102
-            // make sure they passed in an array
103
-            if (! is_array($setup_args['model_paths'])) {
104
-                $setup_args['model_paths'] = [$setup_args['model_paths']];
105
-            }
106
-            // we want to add this as a model folder
107
-            // and autoload them all
108
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_paths']);
109
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
110
-            $model_name_to_classname_map = [];
111
-            foreach (array_keys($class_to_filepath_map) as $classname) {
112
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
113
-            }
114
-            self::$_model_name_to_classname_map[ $addon_name ] = $model_name_to_classname_map;
115
-            add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
116
-            add_filter(
117
-                'FHEE__EE_System__parse_implemented_model_names',
118
-                ['EE_Register_Model', 'add_addon_models']
119
-            );
120
-            add_filter('FHEE__EE_Registry__load_model__paths', ['EE_Register_Model', 'add_model_folders']);
121
-            unset($setup_args['model_paths']);
122
-        }
123
-        if (isset($setup_args['class_paths'])) {
124
-            // make sure they passed in an array
125
-            if (! is_array($setup_args['class_paths'])) {
126
-                $setup_args['class_paths'] = [$setup_args['class_paths']];
127
-            }
128
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
129
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
130
-            add_filter('FHEE__EE_Registry__load_class__paths', ['EE_Register_Model', 'add_class_folders']);
131
-            unset($setup_args['class_paths']);
132
-        }
133
-        foreach ($setup_args as $unknown_key => $unknown_config) {
134
-            self::deregister($addon_name);
135
-            throw new EE_Error(
136
-                sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
137
-            );
138
-        }
139
-        return true;
140
-    }
85
+		if (
86
+			(
87
+				isset($setup_args['model_paths']) && ! isset($setup_args['class_paths'])
88
+			)
89
+			|| (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
90
+		) {
91
+			throw new EE_Error(
92
+				sprintf(
93
+					__(
94
+						'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
95
+						'event_espresso'
96
+					),
97
+					implode(", ", array_keys($setup_args))
98
+				)
99
+			);
100
+		}
101
+		if (isset($setup_args['model_paths'])) {
102
+			// make sure they passed in an array
103
+			if (! is_array($setup_args['model_paths'])) {
104
+				$setup_args['model_paths'] = [$setup_args['model_paths']];
105
+			}
106
+			// we want to add this as a model folder
107
+			// and autoload them all
108
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_paths']);
109
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
110
+			$model_name_to_classname_map = [];
111
+			foreach (array_keys($class_to_filepath_map) as $classname) {
112
+				$model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
113
+			}
114
+			self::$_model_name_to_classname_map[ $addon_name ] = $model_name_to_classname_map;
115
+			add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
116
+			add_filter(
117
+				'FHEE__EE_System__parse_implemented_model_names',
118
+				['EE_Register_Model', 'add_addon_models']
119
+			);
120
+			add_filter('FHEE__EE_Registry__load_model__paths', ['EE_Register_Model', 'add_model_folders']);
121
+			unset($setup_args['model_paths']);
122
+		}
123
+		if (isset($setup_args['class_paths'])) {
124
+			// make sure they passed in an array
125
+			if (! is_array($setup_args['class_paths'])) {
126
+				$setup_args['class_paths'] = [$setup_args['class_paths']];
127
+			}
128
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
129
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
130
+			add_filter('FHEE__EE_Registry__load_class__paths', ['EE_Register_Model', 'add_class_folders']);
131
+			unset($setup_args['class_paths']);
132
+		}
133
+		foreach ($setup_args as $unknown_key => $unknown_config) {
134
+			self::deregister($addon_name);
135
+			throw new EE_Error(
136
+				sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
137
+			);
138
+		}
139
+		return true;
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * Filters the core list of models
145
-     *
146
-     * @param array $core_models
147
-     * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
148
-     */
149
-    public static function add_addon_models(array $core_models = []): array
150
-    {
151
-        $models = [];
152
-        foreach (self::$_model_name_to_classname_map as $model_map) {
153
-            $models[] = $model_map;
154
-        }
155
-        return array_merge($core_models, ...$models);
156
-    }
143
+	/**
144
+	 * Filters the core list of models
145
+	 *
146
+	 * @param array $core_models
147
+	 * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
148
+	 */
149
+	public static function add_addon_models(array $core_models = []): array
150
+	{
151
+		$models = [];
152
+		foreach (self::$_model_name_to_classname_map as $model_map) {
153
+			$models[] = $model_map;
154
+		}
155
+		return array_merge($core_models, ...$models);
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * Filters the list of model folders
161
-     *
162
-     * @param array $folders
163
-     * @return array of folder paths
164
-     */
165
-    public static function add_model_folders(array $folders = []): array
166
-    {
167
-        $model_folders = [];
168
-        foreach (self::$_model_registry as $setup_args) {
169
-            if (isset($setup_args['model_paths'])) {
170
-                $model_folders[] = (array) $setup_args['model_paths'];
171
-            }
172
-        }
173
-        return array_merge($folders, ...$model_folders);
174
-    }
159
+	/**
160
+	 * Filters the list of model folders
161
+	 *
162
+	 * @param array $folders
163
+	 * @return array of folder paths
164
+	 */
165
+	public static function add_model_folders(array $folders = []): array
166
+	{
167
+		$model_folders = [];
168
+		foreach (self::$_model_registry as $setup_args) {
169
+			if (isset($setup_args['model_paths'])) {
170
+				$model_folders[] = (array) $setup_args['model_paths'];
171
+			}
172
+		}
173
+		return array_merge($folders, ...$model_folders);
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * Filters the array of model class paths
179
-     *
180
-     * @param array $folders
181
-     * @return array of folder paths
182
-     */
183
-    public static function add_class_folders(array $folders = []): array
184
-    {
185
-        $class_folders = [];
186
-        foreach (self::$_model_registry as $setup_args) {
187
-            if (isset($setup_args['class_paths'])) {
188
-                $class_folders[] = (array) $setup_args['class_paths'];
189
-            }
190
-        }
191
-        return array_merge($folders, ...$class_folders);
192
-    }
177
+	/**
178
+	 * Filters the array of model class paths
179
+	 *
180
+	 * @param array $folders
181
+	 * @return array of folder paths
182
+	 */
183
+	public static function add_class_folders(array $folders = []): array
184
+	{
185
+		$class_folders = [];
186
+		foreach (self::$_model_registry as $setup_args) {
187
+			if (isset($setup_args['class_paths'])) {
188
+				$class_folders[] = (array) $setup_args['class_paths'];
189
+			}
190
+		}
191
+		return array_merge($folders, ...$class_folders);
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * deregister
197
-     *
198
-     * @param string $addon_name
199
-     */
200
-    public static function deregister(string $addon_name = '')
201
-    {
202
-        unset(self::$_model_registry[ $addon_name ], self::$_model_name_to_classname_map[ $addon_name ]);
203
-    }
195
+	/**
196
+	 * deregister
197
+	 *
198
+	 * @param string $addon_name
199
+	 */
200
+	public static function deregister(string $addon_name = '')
201
+	{
202
+		unset(self::$_model_registry[ $addon_name ], self::$_model_name_to_classname_map[ $addon_name ]);
203
+	}
204 204
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         }
60 60
 
61 61
         // make sure we don't register twice
62
-        if (isset(self::$_model_registry[ $addon_name ])) {
62
+        if (isset(self::$_model_registry[$addon_name])) {
63 63
             return true;
64 64
         }
65 65
 
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
                 '4.5'
81 81
             );
82 82
         }
83
-        self::$_model_registry[ $addon_name ] = $setup_args;
83
+        self::$_model_registry[$addon_name] = $setup_args;
84 84
 
85 85
         if (
86 86
             (
87 87
                 isset($setup_args['model_paths']) && ! isset($setup_args['class_paths'])
88 88
             )
89
-            || (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
89
+            || ( ! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
90 90
         ) {
91 91
             throw new EE_Error(
92 92
                 sprintf(
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         }
101 101
         if (isset($setup_args['model_paths'])) {
102 102
             // make sure they passed in an array
103
-            if (! is_array($setup_args['model_paths'])) {
103
+            if ( ! is_array($setup_args['model_paths'])) {
104 104
                 $setup_args['model_paths'] = [$setup_args['model_paths']];
105 105
             }
106 106
             // we want to add this as a model folder
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
110 110
             $model_name_to_classname_map = [];
111 111
             foreach (array_keys($class_to_filepath_map) as $classname) {
112
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
112
+                $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
113 113
             }
114
-            self::$_model_name_to_classname_map[ $addon_name ] = $model_name_to_classname_map;
114
+            self::$_model_name_to_classname_map[$addon_name] = $model_name_to_classname_map;
115 115
             add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
116 116
             add_filter(
117 117
                 'FHEE__EE_System__parse_implemented_model_names',
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         }
123 123
         if (isset($setup_args['class_paths'])) {
124 124
             // make sure they passed in an array
125
-            if (! is_array($setup_args['class_paths'])) {
125
+            if ( ! is_array($setup_args['class_paths'])) {
126 126
                 $setup_args['class_paths'] = [$setup_args['class_paths']];
127 127
             }
128 128
             $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
@@ -199,6 +199,6 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public static function deregister(string $addon_name = '')
201 201
     {
202
-        unset(self::$_model_registry[ $addon_name ], self::$_model_name_to_classname_map[ $addon_name ]);
202
+        unset(self::$_model_registry[$addon_name], self::$_model_name_to_classname_map[$addon_name]);
203 203
     }
204 204
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Shortcode.lib.php 1 patch
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 $addon_name    a unique identifier for this set of modules Required.
35
-     * @param array  $setup_args    an array of arguments provided for registering shortcodes Required.
36
-     * @type array shortcode_paths  an array of full server paths to folders containing any EES_Shortcodes
37
-     * @type array shortcode_fqcns  an array of fully qualified class names for any new shortcode classes to register.
38
-     *                              Shortcode classes should extend EspressoShortcode
39
-     *                              and be properly namespaced so they are autoloaded.
40
-     * @return bool
41
-     * @throws EE_Error
42
-     * @since    4.3.0
43
-     * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
44
-     */
45
-    public static function register(string $addon_name = '', array $setup_args = []): bool
46
-    {
47
-        // required fields MUST be present, so let's make sure they are.
48
-        if (
49
-            empty($addon_name)
50
-            || ! is_array($setup_args)
51
-            || (
52
-                empty($setup_args['shortcode_paths'])
53
-            )
54
-               && empty($setup_args['shortcode_fqcns'])
55
-        ) {
56
-            throw new EE_Error(
57
-                esc_html__(
58
-                    '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)',
59
-                    'event_espresso'
60
-                )
61
-            );
62
-        }
31
+	/**
32
+	 *    Method for registering new EE_Shortcodes
33
+	 *
34
+	 * @param string $addon_name    a unique identifier for this set of modules Required.
35
+	 * @param array  $setup_args    an array of arguments provided for registering shortcodes Required.
36
+	 * @type array shortcode_paths  an array of full server paths to folders containing any EES_Shortcodes
37
+	 * @type array shortcode_fqcns  an array of fully qualified class names for any new shortcode classes to register.
38
+	 *                              Shortcode classes should extend EspressoShortcode
39
+	 *                              and be properly namespaced so they are autoloaded.
40
+	 * @return bool
41
+	 * @throws EE_Error
42
+	 * @since    4.3.0
43
+	 * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
44
+	 */
45
+	public static function register(string $addon_name = '', array $setup_args = []): bool
46
+	{
47
+		// required fields MUST be present, so let's make sure they are.
48
+		if (
49
+			empty($addon_name)
50
+			|| ! is_array($setup_args)
51
+			|| (
52
+				empty($setup_args['shortcode_paths'])
53
+			)
54
+			   && empty($setup_args['shortcode_fqcns'])
55
+		) {
56
+			throw new EE_Error(
57
+				esc_html__(
58
+					'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)',
59
+					'event_espresso'
60
+				)
61
+			);
62
+		}
63 63
 
64
-        // make sure we don't register twice
65
-        if (isset(self::$_settings[ $addon_name ])) {
66
-            return true;
67
-        }
64
+		// make sure we don't register twice
65
+		if (isset(self::$_settings[ $addon_name ])) {
66
+			return true;
67
+		}
68 68
 
69
-        // make sure this was called in the right place!
70
-        if (
71
-            ! 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[ $addon_name ] = [
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
-        );
69
+		// make sure this was called in the right place!
70
+		if (
71
+			! 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[ $addon_name ] = [
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'...)
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'...)
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 $addon_name.
173
-     *
174
-     * @param string $addon_name the name for the shortcode that was previously registered
175
-     * @return void
176
-     * @since    4.3.0
177
-     */
178
-    public static function deregister(string $addon_name = '')
179
-    {
180
-        unset(self::$_settings[ $addon_name ]);
181
-    }
171
+	/**
172
+	 * This deregisters a shortcode that was previously registered with a specific $addon_name.
173
+	 *
174
+	 * @param string $addon_name the name for the shortcode that was previously registered
175
+	 * @return void
176
+	 * @since    4.3.0
177
+	 */
178
+	public static function deregister(string $addon_name = '')
179
+	{
180
+		unset(self::$_settings[ $addon_name ]);
181
+	}
182 182
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Template_Pack.lib.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -12,202 +12,202 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Holds values for registered template pack
17
-     *
18
-     * @since 4.5.0
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_registry = [];
23
-
24
-
25
-    /**
26
-     * Used to register a new template pack with the messages system.
27
-     *
28
-     * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
29
-     * change entire layouts for a set of message templates.  This method is used to register the new template pack and
30
-     * automatically have it loaded in the appropriate places.
31
-     *
32
-     * This registry also verifies that there isn't already a template pack registered with the same name and if there
33
-     * is then it will add an EE_Error notice.
34
-     *
35
-     * Note that this only handles registering the your Template Pack class with the message template pack system.
36
-     * However, there is also a naming schema you must follow for templates you are providing with your template pack.
37
-     *
38
-     * @param string $addon_name The internal reference used to refer to this template pack.  Note, this is first come,
39
-     *                           first serve.  If there is already a template pack registered with this name then the
40
-     *                           registry will assign a unique reference for it so it can still be activated (but this
41
-     *                           makes it harder to deregister as it will be unique per load - so its best to try to
42
-     *                           make this a unique string!)
43
-     * @param array  $setup_args array {
44
-     *                           An array of required values for registering the template pack.
45
-     * @type string  $path       The path for the new template pack class.
46
-     * @type string  $classname  The name of the new Template Pack Class.
47
-     *                           }
48
-     * @return bool
49
-     * @throws EE_Error
50
-     *
51
-     * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
52
-     *         supports.
53
-     *
54
-     *
55
-     * @since  4.5.0
56
-     * @see    EE_Messages_Template_Pack_Default for an example class
57
-     */
58
-    public static function register(string $addon_name = '', array $setup_args = []): bool
59
-    {
60
-
61
-        // check for required params
62
-        if (empty($addon_name) || empty($setup_args['path']) || empty($setup_args['classname'])) {
63
-            throw new EE_Error(
64
-                __(
65
-                    'In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ',
66
-                    'event_espresso'
67
-                )
68
-            );
69
-        }
70
-
71
-        // make sure we don't register twice
72
-        if (isset(self::$_registry[ $addon_name ])) {
73
-            return true;
74
-        }
75
-
76
-        // check that incoming $addon_name doesn't already exist. If it does then we'll create a unique reference for this template pack.
77
-        if (isset(self::$_registry[ $addon_name ])) {
78
-            $addon_name = uniqid() . '_' . $addon_name;
79
-        }
80
-
81
-
82
-        // make sure this was called in the right place!
83
-        if (
84
-            ! did_action('EE_Brewing_Regular___messages_caf')
85
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
86
-        ) {
87
-            EE_Error::doing_it_wrong(
88
-                __METHOD__,
89
-                sprintf(
90
-                    __(
91
-                        'A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
92
-                        'event_espresso'
93
-                    ),
94
-                    $addon_name
95
-                ),
96
-                '4.5.0'
97
-            );
98
-        }
99
-
100
-        if (self::_verify_class_not_exist($setup_args['classname'])) {
101
-            self::$_registry[ $addon_name ] = [
102
-                'path'      => (string) $setup_args['path'],
103
-                'classname' => (string) $setup_args['classname'],
104
-            ];
105
-        }
106
-
107
-        // hook into the system
108
-        add_filter(
109
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
110
-            ['EE_Register_Messages_Template_Pack', 'set_template_pack_path'],
111
-            10
112
-        );
113
-        add_filter(
114
-            'FHEE__EED_Messages__get_template_packs__template_packs',
115
-            ['EE_Register_Messages_Template_Pack', 'set_template_pack'],
116
-            10
117
-        );
118
-        return true;
119
-    }
120
-
121
-
122
-    /**
123
-     * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
124
-     * to the messages autoloader paths.
125
-     *
126
-     * @param array $paths Array of paths already registered with the messages autoloader
127
-     *
128
-     * @return array
129
-     * @since  4.5.0
130
-     *
131
-     */
132
-    public static function set_template_pack_path(array $paths): array
133
-    {
134
-        foreach (self::$_registry as $args) {
135
-            $paths[] = $args['path'];
136
-        }
137
-        return $paths;
138
-    }
139
-
140
-
141
-    /**
142
-     * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
143
-     * registered template pack to the template packs array when requested by client code.
144
-     *
145
-     * @param EE_Messages_Template_Pack[] $template_packs
146
-     * @return EE_Messages_Template_Pack[]
147
-     * @since 4.5.0
148
-     *
149
-     */
150
-    public static function set_template_pack(array $template_packs): array
151
-    {
152
-        foreach (self::$_registry as $args) {
153
-            // verify class_exists
154
-            if (! class_exists($args['classname'])) {
155
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
156
-            }
157
-
158
-            // check again!
159
-            if (class_exists($args['classname'])) {
160
-                $template_pack                           = new $args['classname']();
161
-                $template_packs[ $template_pack->dbref ] = $template_pack;
162
-            }
163
-        }
164
-
165
-        return $template_packs;
166
-    }
167
-
168
-
169
-    /**
170
-     * This verifies that the classes for each registered template pack are unique  names.
171
-     *
172
-     * @param string $classname The classname being checked
173
-     *
174
-     * @return bool
175
-     */
176
-    private static function _verify_class_not_exist(string $classname): bool
177
-    {
178
-        // loop through the existing registry and see if the classname is already present.
179
-        foreach (self::$_registry as $args) {
180
-            if ($args['classname'] == $classname) {
181
-                EE_Error::add_error(
182
-                    sprintf(
183
-                        __(
184
-                            'The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.',
185
-                            'event_espresso'
186
-                        ),
187
-                        $classname
188
-                    ),
189
-                    __FILE__,
190
-                    __LINE__,
191
-                    __FUNCTION__
192
-                );
193
-                return false;
194
-            }
195
-        }
196
-        return true;
197
-    }
198
-
199
-
200
-    /**
201
-     * This deregisters a variation set that was previously registered with the given slug.
202
-     *
203
-     * @param string $addon_name The name for the variation set that was previously registered.
204
-     *
205
-     * @return void
206
-     * @since 4.5.0
207
-     *
208
-     */
209
-    public static function deregister(string $addon_name = '')
210
-    {
211
-        unset(self::$_registry[ $addon_name ]);
212
-    }
15
+	/**
16
+	 * Holds values for registered template pack
17
+	 *
18
+	 * @since 4.5.0
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_registry = [];
23
+
24
+
25
+	/**
26
+	 * Used to register a new template pack with the messages system.
27
+	 *
28
+	 * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
29
+	 * change entire layouts for a set of message templates.  This method is used to register the new template pack and
30
+	 * automatically have it loaded in the appropriate places.
31
+	 *
32
+	 * This registry also verifies that there isn't already a template pack registered with the same name and if there
33
+	 * is then it will add an EE_Error notice.
34
+	 *
35
+	 * Note that this only handles registering the your Template Pack class with the message template pack system.
36
+	 * However, there is also a naming schema you must follow for templates you are providing with your template pack.
37
+	 *
38
+	 * @param string $addon_name The internal reference used to refer to this template pack.  Note, this is first come,
39
+	 *                           first serve.  If there is already a template pack registered with this name then the
40
+	 *                           registry will assign a unique reference for it so it can still be activated (but this
41
+	 *                           makes it harder to deregister as it will be unique per load - so its best to try to
42
+	 *                           make this a unique string!)
43
+	 * @param array  $setup_args array {
44
+	 *                           An array of required values for registering the template pack.
45
+	 * @type string  $path       The path for the new template pack class.
46
+	 * @type string  $classname  The name of the new Template Pack Class.
47
+	 *                           }
48
+	 * @return bool
49
+	 * @throws EE_Error
50
+	 *
51
+	 * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
52
+	 *         supports.
53
+	 *
54
+	 *
55
+	 * @since  4.5.0
56
+	 * @see    EE_Messages_Template_Pack_Default for an example class
57
+	 */
58
+	public static function register(string $addon_name = '', array $setup_args = []): bool
59
+	{
60
+
61
+		// check for required params
62
+		if (empty($addon_name) || empty($setup_args['path']) || empty($setup_args['classname'])) {
63
+			throw new EE_Error(
64
+				__(
65
+					'In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ',
66
+					'event_espresso'
67
+				)
68
+			);
69
+		}
70
+
71
+		// make sure we don't register twice
72
+		if (isset(self::$_registry[ $addon_name ])) {
73
+			return true;
74
+		}
75
+
76
+		// check that incoming $addon_name doesn't already exist. If it does then we'll create a unique reference for this template pack.
77
+		if (isset(self::$_registry[ $addon_name ])) {
78
+			$addon_name = uniqid() . '_' . $addon_name;
79
+		}
80
+
81
+
82
+		// make sure this was called in the right place!
83
+		if (
84
+			! did_action('EE_Brewing_Regular___messages_caf')
85
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
86
+		) {
87
+			EE_Error::doing_it_wrong(
88
+				__METHOD__,
89
+				sprintf(
90
+					__(
91
+						'A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
92
+						'event_espresso'
93
+					),
94
+					$addon_name
95
+				),
96
+				'4.5.0'
97
+			);
98
+		}
99
+
100
+		if (self::_verify_class_not_exist($setup_args['classname'])) {
101
+			self::$_registry[ $addon_name ] = [
102
+				'path'      => (string) $setup_args['path'],
103
+				'classname' => (string) $setup_args['classname'],
104
+			];
105
+		}
106
+
107
+		// hook into the system
108
+		add_filter(
109
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
110
+			['EE_Register_Messages_Template_Pack', 'set_template_pack_path'],
111
+			10
112
+		);
113
+		add_filter(
114
+			'FHEE__EED_Messages__get_template_packs__template_packs',
115
+			['EE_Register_Messages_Template_Pack', 'set_template_pack'],
116
+			10
117
+		);
118
+		return true;
119
+	}
120
+
121
+
122
+	/**
123
+	 * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
124
+	 * to the messages autoloader paths.
125
+	 *
126
+	 * @param array $paths Array of paths already registered with the messages autoloader
127
+	 *
128
+	 * @return array
129
+	 * @since  4.5.0
130
+	 *
131
+	 */
132
+	public static function set_template_pack_path(array $paths): array
133
+	{
134
+		foreach (self::$_registry as $args) {
135
+			$paths[] = $args['path'];
136
+		}
137
+		return $paths;
138
+	}
139
+
140
+
141
+	/**
142
+	 * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
143
+	 * registered template pack to the template packs array when requested by client code.
144
+	 *
145
+	 * @param EE_Messages_Template_Pack[] $template_packs
146
+	 * @return EE_Messages_Template_Pack[]
147
+	 * @since 4.5.0
148
+	 *
149
+	 */
150
+	public static function set_template_pack(array $template_packs): array
151
+	{
152
+		foreach (self::$_registry as $args) {
153
+			// verify class_exists
154
+			if (! class_exists($args['classname'])) {
155
+				require_once($args['path'] . '/' . $args['classname'] . '.class.php');
156
+			}
157
+
158
+			// check again!
159
+			if (class_exists($args['classname'])) {
160
+				$template_pack                           = new $args['classname']();
161
+				$template_packs[ $template_pack->dbref ] = $template_pack;
162
+			}
163
+		}
164
+
165
+		return $template_packs;
166
+	}
167
+
168
+
169
+	/**
170
+	 * This verifies that the classes for each registered template pack are unique  names.
171
+	 *
172
+	 * @param string $classname The classname being checked
173
+	 *
174
+	 * @return bool
175
+	 */
176
+	private static function _verify_class_not_exist(string $classname): bool
177
+	{
178
+		// loop through the existing registry and see if the classname is already present.
179
+		foreach (self::$_registry as $args) {
180
+			if ($args['classname'] == $classname) {
181
+				EE_Error::add_error(
182
+					sprintf(
183
+						__(
184
+							'The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.',
185
+							'event_espresso'
186
+						),
187
+						$classname
188
+					),
189
+					__FILE__,
190
+					__LINE__,
191
+					__FUNCTION__
192
+				);
193
+				return false;
194
+			}
195
+		}
196
+		return true;
197
+	}
198
+
199
+
200
+	/**
201
+	 * This deregisters a variation set that was previously registered with the given slug.
202
+	 *
203
+	 * @param string $addon_name The name for the variation set that was previously registered.
204
+	 *
205
+	 * @return void
206
+	 * @since 4.5.0
207
+	 *
208
+	 */
209
+	public static function deregister(string $addon_name = '')
210
+	{
211
+		unset(self::$_registry[ $addon_name ]);
212
+	}
213 213
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
         }
70 70
 
71 71
         // make sure we don't register twice
72
-        if (isset(self::$_registry[ $addon_name ])) {
72
+        if (isset(self::$_registry[$addon_name])) {
73 73
             return true;
74 74
         }
75 75
 
76 76
         // check that incoming $addon_name doesn't already exist. If it does then we'll create a unique reference for this template pack.
77
-        if (isset(self::$_registry[ $addon_name ])) {
78
-            $addon_name = uniqid() . '_' . $addon_name;
77
+        if (isset(self::$_registry[$addon_name])) {
78
+            $addon_name = uniqid().'_'.$addon_name;
79 79
         }
80 80
 
81 81
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         if (self::_verify_class_not_exist($setup_args['classname'])) {
101
-            self::$_registry[ $addon_name ] = [
101
+            self::$_registry[$addon_name] = [
102 102
                 'path'      => (string) $setup_args['path'],
103 103
                 'classname' => (string) $setup_args['classname'],
104 104
             ];
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     {
152 152
         foreach (self::$_registry as $args) {
153 153
             // verify class_exists
154
-            if (! class_exists($args['classname'])) {
155
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
154
+            if ( ! class_exists($args['classname'])) {
155
+                require_once($args['path'].'/'.$args['classname'].'.class.php');
156 156
             }
157 157
 
158 158
             // check again!
159 159
             if (class_exists($args['classname'])) {
160 160
                 $template_pack                           = new $args['classname']();
161
-                $template_packs[ $template_pack->dbref ] = $template_pack;
161
+                $template_packs[$template_pack->dbref] = $template_pack;
162 162
             }
163 163
         }
164 164
 
@@ -208,6 +208,6 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public static function deregister(string $addon_name = '')
210 210
     {
211
-        unset(self::$_registry[ $addon_name ]);
211
+        unset(self::$_registry[$addon_name]);
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Message_Type.lib.php 2 patches
Indentation   +445 added lines, -445 removed lines patch added patch discarded remove patch
@@ -12,475 +12,475 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Holds values for registered message types
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_ee_message_type_registry = [];
15
+	/**
16
+	 * Holds values for registered message types
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_ee_message_type_registry = [];
21 21
 
22 22
 
23
-    /**
24
-     * Method for registering new message types in the EE_messages system.
25
-     * Note:  All message types must have the following files in order to work:
26
-     * Template files for default templates getting setup.
27
-     * See /core/libraries/messages/defaults/default/ for examples
28
-     * (note that template files match a specific naming schema).
29
-     * These templates will need to be registered with the default template pack.
30
-     * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
31
-     *      for examples.  Note for any new message types, there will need to be a validator for each
32
-     *      messenger combo this message type can activate with.
33
-     * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
34
-     *      message type and its properties.
35
-     *
36
-     * @param string $addon_name    Whatever is defined for the $name property of
37
-     *                              the message type you are registering (eg.
38
-     *                              declined_registration). Required.
39
-     * @param array  $setup_args    An array of arguments provided for registering the message type.
40
-     * @throws EE_Error
41
-     *                              }
42
-     * @see      inline docs in the register method for what can be passed in as arguments.
43
-     * @since    4.3.0
44
-     */
45
-    public static function register(string $addon_name = '', array $setup_args = []): bool
46
-    {
47
-        // required fields MUST be present, so let's make sure they are.
48
-        if (
49
-            ! isset($addon_name)
50
-            || ! is_array($setup_args)
51
-            || empty($setup_args['mtfilename'])
52
-            || empty($setup_args['autoloadpaths'])
53
-        ) {
54
-            throw new EE_Error(
55
-                __(
56
-                    'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"',
57
-                    'event_espresso'
58
-                )
59
-            );
60
-        }
23
+	/**
24
+	 * Method for registering new message types in the EE_messages system.
25
+	 * Note:  All message types must have the following files in order to work:
26
+	 * Template files for default templates getting setup.
27
+	 * See /core/libraries/messages/defaults/default/ for examples
28
+	 * (note that template files match a specific naming schema).
29
+	 * These templates will need to be registered with the default template pack.
30
+	 * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
31
+	 *      for examples.  Note for any new message types, there will need to be a validator for each
32
+	 *      messenger combo this message type can activate with.
33
+	 * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
34
+	 *      message type and its properties.
35
+	 *
36
+	 * @param string $addon_name    Whatever is defined for the $name property of
37
+	 *                              the message type you are registering (eg.
38
+	 *                              declined_registration). Required.
39
+	 * @param array  $setup_args    An array of arguments provided for registering the message type.
40
+	 * @throws EE_Error
41
+	 *                              }
42
+	 * @see      inline docs in the register method for what can be passed in as arguments.
43
+	 * @since    4.3.0
44
+	 */
45
+	public static function register(string $addon_name = '', array $setup_args = []): bool
46
+	{
47
+		// required fields MUST be present, so let's make sure they are.
48
+		if (
49
+			! isset($addon_name)
50
+			|| ! is_array($setup_args)
51
+			|| empty($setup_args['mtfilename'])
52
+			|| empty($setup_args['autoloadpaths'])
53
+		) {
54
+			throw new EE_Error(
55
+				__(
56
+					'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"',
57
+					'event_espresso'
58
+				)
59
+			);
60
+		}
61 61
 
62
-        // make sure we don't register twice
63
-        if (isset(self::$_ee_message_type_registry[ $addon_name ])) {
64
-            return true;
65
-        }
62
+		// make sure we don't register twice
63
+		if (isset(self::$_ee_message_type_registry[ $addon_name ])) {
64
+			return true;
65
+		}
66 66
 
67
-        // make sure this was called in the right place!
68
-        if (
69
-            ! did_action('EE_Brewing_Regular___messages_caf')
70
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
71
-        ) {
72
-            EE_Error::doing_it_wrong(
73
-                __METHOD__,
74
-                sprintf(
75
-                    __(
76
-                        'A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.',
77
-                        'event_espresso'
78
-                    ),
79
-                    $addon_name
80
-                ),
81
-                '4.3.0'
82
-            );
83
-        }
84
-        // setup $__ee_message_type_registry array from incoming values.
85
-        self::$_ee_message_type_registry[ $addon_name ] = [
86
-            /**
87
-             * The file name for the message type being registered.
88
-             * Required.
89
-             *
90
-             * @type string
91
-             */
92
-            'mtfilename'                                       => (string) $setup_args['mtfilename'],
93
-            /**
94
-             * Autoload paths for classes used by the message type.
95
-             * Required.
96
-             *
97
-             * @type array
98
-             */
99
-            'autoloadpaths'                                    => (array) $setup_args['autoloadpaths'],
100
-            /**
101
-             * Messengers that the message type should be able to activate with.
102
-             * Use messenger slugs.
103
-             *
104
-             * @type array
105
-             */
106
-            'messengers_to_activate_with'                      => ! empty($setup_args['messengers_to_activate_with'])
107
-                ? (array) $setup_args['messengers_to_activate_with']
108
-                : [],
109
-            /**
110
-             * Messengers that the message type should validate with.
111
-             * Use messenger slugs.
112
-             *
113
-             * @type array
114
-             */
115
-            'messengers_to_validate_with'                      => ! empty($setup_args['messengers_to_validate_with'])
116
-                ? (array) $setup_args['messengers_to_validate_with']
117
-                : [],
118
-            /**
119
-             * Whether to force activate this message type the first time it is registered.
120
-             *
121
-             * @type bool   False means its not activated by default and left up to the end user to activate.
122
-             */
123
-            'force_activation'                                 => ! empty($setup_args['force_activation'])
124
-                                                                  && $setup_args['force_activation'],
125
-            /**
126
-             * What messengers this message type supports the default template pack for.
127
-             * Note: If you do not set this (or any of the following template pack/variation related arguments) to true,
128
-             * then it is expected that the message type being registered is doing its own custom default template
129
-             * pack/variation registration.
130
-             *
131
-             * If this is set and has values, then it is expected that the following arguments are also set in the incoming options
132
-             * $setup_arguments array as well:
133
-             * - 'base_path_for_default_templates'
134
-             *
135
-             * @type array   Expect an array of messengers this supports default template packs for.
136
-             */
137
-            'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with'])
138
-                ? (array) $setup_args['messengers_supporting_default_template_pack_with']
139
-                : [],
140
-            /**
141
-             * The base path where the default templates for this message type can be found.
142
-             *
143
-             * @type string
144
-             */
145
-            'base_path_for_default_templates'                  => $setup_args['base_path_for_default_templates'] ?? '',
146
-            /**
147
-             * The base path where the default variations for this message type can be found.
148
-             *
149
-             * @type string
150
-             */
151
-            'base_path_for_default_variation'                  => $setup_args['base_path_for_default_variation'] ?? '',
152
-            /**
153
-             * The base url for the default variations for this message type.
154
-             *
155
-             * @type string
156
-             */
157
-            'base_url_for_default_variation'                   => $setup_args['base_url_for_default_variation'] ?? '',
158
-        ];
159
-        // add filters but only if they haven't already been set (these filters only need to be registered ONCE because
160
-        // the callback handles all registered message types.
161
-        if (
162
-            false === has_filter(
163
-                'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
164
-                ['EE_Register_Message_Type', 'register_msgs_autoload_paths']
165
-            )
166
-        ) {
167
-            add_filter(
168
-                'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
169
-                ['EE_Register_Message_Type', 'register_msgs_autoload_paths'],
170
-                10
171
-            );
172
-            add_filter(
173
-                'FHEE__EE_messages__get_installed__messagetype_files',
174
-                ['EE_Register_Message_Type', 'register_messagetype_files'],
175
-                10,
176
-                1
177
-            );
178
-            add_filter(
179
-                'FHEE__EE_messenger__get_default_message_types__default_types',
180
-                ['EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'],
181
-                10,
182
-                2
183
-            );
184
-            add_filter(
185
-                'FHEE__EE_messenger__get_valid_message_types__valid_types',
186
-                ['EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'],
187
-                10,
188
-                2
189
-            );
190
-            // actions
191
-            add_action(
192
-                'AHEE__EE_Addon__initialize_default_data__begin',
193
-                ['EE_Register_Message_Type', 'set_defaults']
194
-            );
67
+		// make sure this was called in the right place!
68
+		if (
69
+			! did_action('EE_Brewing_Regular___messages_caf')
70
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
71
+		) {
72
+			EE_Error::doing_it_wrong(
73
+				__METHOD__,
74
+				sprintf(
75
+					__(
76
+						'A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.',
77
+						'event_espresso'
78
+					),
79
+					$addon_name
80
+				),
81
+				'4.3.0'
82
+			);
83
+		}
84
+		// setup $__ee_message_type_registry array from incoming values.
85
+		self::$_ee_message_type_registry[ $addon_name ] = [
86
+			/**
87
+			 * The file name for the message type being registered.
88
+			 * Required.
89
+			 *
90
+			 * @type string
91
+			 */
92
+			'mtfilename'                                       => (string) $setup_args['mtfilename'],
93
+			/**
94
+			 * Autoload paths for classes used by the message type.
95
+			 * Required.
96
+			 *
97
+			 * @type array
98
+			 */
99
+			'autoloadpaths'                                    => (array) $setup_args['autoloadpaths'],
100
+			/**
101
+			 * Messengers that the message type should be able to activate with.
102
+			 * Use messenger slugs.
103
+			 *
104
+			 * @type array
105
+			 */
106
+			'messengers_to_activate_with'                      => ! empty($setup_args['messengers_to_activate_with'])
107
+				? (array) $setup_args['messengers_to_activate_with']
108
+				: [],
109
+			/**
110
+			 * Messengers that the message type should validate with.
111
+			 * Use messenger slugs.
112
+			 *
113
+			 * @type array
114
+			 */
115
+			'messengers_to_validate_with'                      => ! empty($setup_args['messengers_to_validate_with'])
116
+				? (array) $setup_args['messengers_to_validate_with']
117
+				: [],
118
+			/**
119
+			 * Whether to force activate this message type the first time it is registered.
120
+			 *
121
+			 * @type bool   False means its not activated by default and left up to the end user to activate.
122
+			 */
123
+			'force_activation'                                 => ! empty($setup_args['force_activation'])
124
+																  && $setup_args['force_activation'],
125
+			/**
126
+			 * What messengers this message type supports the default template pack for.
127
+			 * Note: If you do not set this (or any of the following template pack/variation related arguments) to true,
128
+			 * then it is expected that the message type being registered is doing its own custom default template
129
+			 * pack/variation registration.
130
+			 *
131
+			 * If this is set and has values, then it is expected that the following arguments are also set in the incoming options
132
+			 * $setup_arguments array as well:
133
+			 * - 'base_path_for_default_templates'
134
+			 *
135
+			 * @type array   Expect an array of messengers this supports default template packs for.
136
+			 */
137
+			'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with'])
138
+				? (array) $setup_args['messengers_supporting_default_template_pack_with']
139
+				: [],
140
+			/**
141
+			 * The base path where the default templates for this message type can be found.
142
+			 *
143
+			 * @type string
144
+			 */
145
+			'base_path_for_default_templates'                  => $setup_args['base_path_for_default_templates'] ?? '',
146
+			/**
147
+			 * The base path where the default variations for this message type can be found.
148
+			 *
149
+			 * @type string
150
+			 */
151
+			'base_path_for_default_variation'                  => $setup_args['base_path_for_default_variation'] ?? '',
152
+			/**
153
+			 * The base url for the default variations for this message type.
154
+			 *
155
+			 * @type string
156
+			 */
157
+			'base_url_for_default_variation'                   => $setup_args['base_url_for_default_variation'] ?? '',
158
+		];
159
+		// add filters but only if they haven't already been set (these filters only need to be registered ONCE because
160
+		// the callback handles all registered message types.
161
+		if (
162
+			false === has_filter(
163
+				'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
164
+				['EE_Register_Message_Type', 'register_msgs_autoload_paths']
165
+			)
166
+		) {
167
+			add_filter(
168
+				'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
169
+				['EE_Register_Message_Type', 'register_msgs_autoload_paths'],
170
+				10
171
+			);
172
+			add_filter(
173
+				'FHEE__EE_messages__get_installed__messagetype_files',
174
+				['EE_Register_Message_Type', 'register_messagetype_files'],
175
+				10,
176
+				1
177
+			);
178
+			add_filter(
179
+				'FHEE__EE_messenger__get_default_message_types__default_types',
180
+				['EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'],
181
+				10,
182
+				2
183
+			);
184
+			add_filter(
185
+				'FHEE__EE_messenger__get_valid_message_types__valid_types',
186
+				['EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'],
187
+				10,
188
+				2
189
+			);
190
+			// actions
191
+			add_action(
192
+				'AHEE__EE_Addon__initialize_default_data__begin',
193
+				['EE_Register_Message_Type', 'set_defaults']
194
+			);
195 195
 
196
-            // default template packs and variations related
197
-            add_filter(
198
-                'FHEE__EE_Messages_Template_Pack_Default__get_supports',
199
-                ['EE_Register_Message_Type', 'register_default_template_pack_supports']
200
-            );
201
-            add_filter(
202
-                'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path',
203
-                ['EE_Register_Message_Type', 'register_base_template_path'],
204
-                10,
205
-                6
206
-            );
207
-            add_filter(
208
-                'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url',
209
-                ['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
210
-                10,
211
-                8
212
-            );
213
-            add_filter(
214
-                'FHEE__EE_Messages_Template_Pack__get_variation__base_path',
215
-                ['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
216
-                10,
217
-                8
218
-            );
219
-        }
220
-        return true;
221
-    }
196
+			// default template packs and variations related
197
+			add_filter(
198
+				'FHEE__EE_Messages_Template_Pack_Default__get_supports',
199
+				['EE_Register_Message_Type', 'register_default_template_pack_supports']
200
+			);
201
+			add_filter(
202
+				'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path',
203
+				['EE_Register_Message_Type', 'register_base_template_path'],
204
+				10,
205
+				6
206
+			);
207
+			add_filter(
208
+				'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url',
209
+				['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
210
+				10,
211
+				8
212
+			);
213
+			add_filter(
214
+				'FHEE__EE_Messages_Template_Pack__get_variation__base_path',
215
+				['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
216
+				10,
217
+				8
218
+			);
219
+		}
220
+		return true;
221
+	}
222 222
 
223 223
 
224
-    /**
225
-     * This just ensures that when an addon registers a message type that on initial activation/reactivation the
226
-     * defaults the addon sets are taken care of.
227
-     *
228
-     * @throws EE_Error
229
-     * @throws ReflectionException
230
-     */
231
-    public static function set_defaults()
232
-    {
233
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
234
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
224
+	/**
225
+	 * This just ensures that when an addon registers a message type that on initial activation/reactivation the
226
+	 * defaults the addon sets are taken care of.
227
+	 *
228
+	 * @throws EE_Error
229
+	 * @throws ReflectionException
230
+	 */
231
+	public static function set_defaults()
232
+	{
233
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
234
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
235 235
 
236
-        // for any message types with force activation, let's ensure they are activated
237
-        foreach (self::$_ee_message_type_registry as $addon_name => $settings) {
238
-            if ($settings['force_activation']) {
239
-                foreach ($settings['messengers_to_activate_with'] as $messenger) {
240
-                    // DO not force activation if this message type has already been activated in the system
241
-                    if (
242
-                        ! $message_resource_manager->has_message_type_been_activated_for_messenger(
243
-                            $addon_name,
244
-                            $messenger
245
-                        )
246
-                    ) {
247
-                        $message_resource_manager->ensure_message_type_is_active($addon_name, $messenger);
248
-                    }
249
-                }
250
-            }
251
-        }
252
-    }
236
+		// for any message types with force activation, let's ensure they are activated
237
+		foreach (self::$_ee_message_type_registry as $addon_name => $settings) {
238
+			if ($settings['force_activation']) {
239
+				foreach ($settings['messengers_to_activate_with'] as $messenger) {
240
+					// DO not force activation if this message type has already been activated in the system
241
+					if (
242
+						! $message_resource_manager->has_message_type_been_activated_for_messenger(
243
+							$addon_name,
244
+							$messenger
245
+						)
246
+					) {
247
+						$message_resource_manager->ensure_message_type_is_active($addon_name, $messenger);
248
+					}
249
+				}
250
+			}
251
+		}
252
+	}
253 253
 
254 254
 
255
-    /**
256
-     * This deregisters a message type that was previously registered with a specific message_type_name.
257
-     *
258
-     * @param string $addon_name the name for the message type that was previously registered
259
-     * @return void
260
-     * @throws EE_Error
261
-     * @throws ReflectionException
262
-     * @since    4.3.0
263
-     */
264
-    public static function deregister(string $addon_name = '')
265
-    {
266
-        if (! empty(self::$_ee_message_type_registry[ $addon_name ])) {
267
-            // let's make sure that we remove any place this message type was made active
268
-            /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
269
-            $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
270
-            // ensures that if this message type is registered again that it retains its previous active state vs
271
-            // remaining inactive.
272
-            $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers(
273
-                $addon_name,
274
-                true
275
-            );
276
-            $Message_Resource_Manager->deactivate_message_type($addon_name, false);
277
-        }
278
-        unset(self::$_ee_message_type_registry[ $addon_name ]);
279
-    }
255
+	/**
256
+	 * This deregisters a message type that was previously registered with a specific message_type_name.
257
+	 *
258
+	 * @param string $addon_name the name for the message type that was previously registered
259
+	 * @return void
260
+	 * @throws EE_Error
261
+	 * @throws ReflectionException
262
+	 * @since    4.3.0
263
+	 */
264
+	public static function deregister(string $addon_name = '')
265
+	{
266
+		if (! empty(self::$_ee_message_type_registry[ $addon_name ])) {
267
+			// let's make sure that we remove any place this message type was made active
268
+			/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
269
+			$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
270
+			// ensures that if this message type is registered again that it retains its previous active state vs
271
+			// remaining inactive.
272
+			$Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers(
273
+				$addon_name,
274
+				true
275
+			);
276
+			$Message_Resource_Manager->deactivate_message_type($addon_name, false);
277
+		}
278
+		unset(self::$_ee_message_type_registry[ $addon_name ]);
279
+	}
280 280
 
281 281
 
282
-    /**
283
-     * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
284
-     *
285
-     * @param array $messagetype_files The current array of message type file names
286
-     * @return  array                                 Array of message type file names
287
-     * @since   4.3.0
288
-     */
289
-    public static function register_messagetype_files(array $messagetype_files): array
290
-    {
291
-        if (empty(self::$_ee_message_type_registry)) {
292
-            return $messagetype_files;
293
-        }
294
-        foreach (self::$_ee_message_type_registry as $mt_reg) {
295
-            if (empty($mt_reg['mtfilename'])) {
296
-                continue;
297
-            }
298
-            $messagetype_files[] = $mt_reg['mtfilename'];
299
-        }
300
-        return $messagetype_files;
301
-    }
282
+	/**
283
+	 * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
284
+	 *
285
+	 * @param array $messagetype_files The current array of message type file names
286
+	 * @return  array                                 Array of message type file names
287
+	 * @since   4.3.0
288
+	 */
289
+	public static function register_messagetype_files(array $messagetype_files): array
290
+	{
291
+		if (empty(self::$_ee_message_type_registry)) {
292
+			return $messagetype_files;
293
+		}
294
+		foreach (self::$_ee_message_type_registry as $mt_reg) {
295
+			if (empty($mt_reg['mtfilename'])) {
296
+				continue;
297
+			}
298
+			$messagetype_files[] = $mt_reg['mtfilename'];
299
+		}
300
+		return $messagetype_files;
301
+	}
302 302
 
303 303
 
304
-    /**
305
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
306
-     *
307
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
308
-     * @return array
309
-     * @since    4.3.0
310
-     */
311
-    public static function register_msgs_autoload_paths(array $paths): array
312
-    {
313
-        $autoload_paths = [];
314
-        if (! empty(self::$_ee_message_type_registry)) {
315
-            foreach (self::$_ee_message_type_registry as $mt_reg) {
316
-                if (empty($mt_reg['autoloadpaths'])) {
317
-                    continue;
318
-                }
319
-                $autoload_paths[] = $mt_reg['autoloadpaths'];
320
-            }
321
-        }
322
-        return array_merge($paths, ...$autoload_paths);
323
-    }
304
+	/**
305
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
306
+	 *
307
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
308
+	 * @return array
309
+	 * @since    4.3.0
310
+	 */
311
+	public static function register_msgs_autoload_paths(array $paths): array
312
+	{
313
+		$autoload_paths = [];
314
+		if (! empty(self::$_ee_message_type_registry)) {
315
+			foreach (self::$_ee_message_type_registry as $mt_reg) {
316
+				if (empty($mt_reg['autoloadpaths'])) {
317
+					continue;
318
+				}
319
+				$autoload_paths[] = $mt_reg['autoloadpaths'];
320
+			}
321
+		}
322
+		return array_merge($paths, ...$autoload_paths);
323
+	}
324 324
 
325 325
 
326
-    /**
327
-     * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
328
-     *
329
-     * @param array        $default_types   array of message types activated with messenger (
330
-     *                                      corresponds to the $name property of message type)
331
-     * @param EE_messenger $messenger       The EE_messenger the filter is called from.
332
-     * @return array
333
-     * @since  4.3.0
334
-     */
335
-    public static function register_messengers_to_activate_mt_with(array $default_types, EE_messenger $messenger): array
336
-    {
337
-        if (empty(self::$_ee_message_type_registry)) {
338
-            return $default_types;
339
-        }
340
-        foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
341
-            if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) {
342
-                continue;
343
-            }
344
-            // loop through each of the messengers and if it matches the loaded class
345
-            // then we add this message type to the
346
-            foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
347
-                if ($messenger->name == $msgr) {
348
-                    $default_types[] = $addon_name;
349
-                }
350
-            }
351
-        }
326
+	/**
327
+	 * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
328
+	 *
329
+	 * @param array        $default_types   array of message types activated with messenger (
330
+	 *                                      corresponds to the $name property of message type)
331
+	 * @param EE_messenger $messenger       The EE_messenger the filter is called from.
332
+	 * @return array
333
+	 * @since  4.3.0
334
+	 */
335
+	public static function register_messengers_to_activate_mt_with(array $default_types, EE_messenger $messenger): array
336
+	{
337
+		if (empty(self::$_ee_message_type_registry)) {
338
+			return $default_types;
339
+		}
340
+		foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
341
+			if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) {
342
+				continue;
343
+			}
344
+			// loop through each of the messengers and if it matches the loaded class
345
+			// then we add this message type to the
346
+			foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
347
+				if ($messenger->name == $msgr) {
348
+					$default_types[] = $addon_name;
349
+				}
350
+			}
351
+		}
352 352
 
353
-        return $default_types;
354
-    }
353
+		return $default_types;
354
+	}
355 355
 
356 356
 
357
-    /**
358
-     * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
359
-     *
360
-     * @param array        $valid_types     array of message types valid with messenger (
361
-     *                                      corresponds to the $name property of message type)
362
-     * @param EE_messenger $messenger       The EE_messenger the filter is called from.
363
-     * @return  array
364
-     * @since   4.3.0
365
-     */
366
-    public static function register_messengers_to_validate_mt_with(array $valid_types, EE_messenger $messenger): array
367
-    {
368
-        if (empty(self::$_ee_message_type_registry)) {
369
-            return $valid_types;
370
-        }
371
-        foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
372
-            if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) {
373
-                continue;
374
-            }
375
-            // loop through each of the messengers and if it matches the loaded class
376
-            // then we add this message type to the
377
-            foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
378
-                if ($messenger->name == $msgr) {
379
-                    $valid_types[] = $addon_name;
380
-                }
381
-            }
382
-        }
357
+	/**
358
+	 * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
359
+	 *
360
+	 * @param array        $valid_types     array of message types valid with messenger (
361
+	 *                                      corresponds to the $name property of message type)
362
+	 * @param EE_messenger $messenger       The EE_messenger the filter is called from.
363
+	 * @return  array
364
+	 * @since   4.3.0
365
+	 */
366
+	public static function register_messengers_to_validate_mt_with(array $valid_types, EE_messenger $messenger): array
367
+	{
368
+		if (empty(self::$_ee_message_type_registry)) {
369
+			return $valid_types;
370
+		}
371
+		foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
372
+			if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) {
373
+				continue;
374
+			}
375
+			// loop through each of the messengers and if it matches the loaded class
376
+			// then we add this message type to the
377
+			foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
378
+				if ($messenger->name == $msgr) {
379
+					$valid_types[] = $addon_name;
380
+				}
381
+			}
382
+		}
383 383
 
384
-        return $valid_types;
385
-    }
384
+		return $valid_types;
385
+	}
386 386
 
387 387
 
388
-    /**
389
-     * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as
390
-     * supporting the default template pack
391
-     *
392
-     * @param array $supports
393
-     *
394
-     * @return array
395
-     */
396
-    public static function register_default_template_pack_supports(array $supports): array
397
-    {
398
-        foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
399
-            if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) {
400
-                continue;
401
-            }
402
-            foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
403
-                $supports[ $messenger_slug ][] = $addon_name;
404
-            }
405
-        }
406
-        return $supports;
407
-    }
388
+	/**
389
+	 * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as
390
+	 * supporting the default template pack
391
+	 *
392
+	 * @param array $supports
393
+	 *
394
+	 * @return array
395
+	 */
396
+	public static function register_default_template_pack_supports(array $supports): array
397
+	{
398
+		foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
399
+			if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) {
400
+				continue;
401
+			}
402
+			foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
403
+				$supports[ $messenger_slug ][] = $addon_name;
404
+			}
405
+		}
406
+		return $supports;
407
+	}
408 408
 
409 409
 
410
-    /**
411
-     * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path
412
-     *
413
-     * @param string                    $base_path The original base path for message templates
414
-     * @param EE_messenger              $messenger
415
-     * @param EE_message_type           $message_type
416
-     * @param string                    $field     The field requesting a template
417
-     * @param string                    $context   The context requesting a template
418
-     * @param EE_Messages_Template_Pack $template_pack
419
-     *
420
-     * @return string
421
-     */
422
-    public static function register_base_template_path(
423
-        string $base_path,
424
-        EE_messenger $messenger,
425
-        EE_message_type $message_type,
426
-        string $field,
427
-        string $context,
428
-        EE_Messages_Template_Pack $template_pack
429
-    ): string {
430
-        if (
431
-            ! $template_pack instanceof EE_Messages_Template_Pack_Default
432
-            || ! $message_type instanceof EE_message_type
433
-        ) {
434
-            return $base_path;
435
-        }
436
-        foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
437
-            if ($message_type->name === $addon_name && ! empty($mt_reg['base_path_for_default_templates'])) {
438
-                return $mt_reg['base_path_for_default_templates'];
439
-            }
440
-        }
441
-        return $base_path;
442
-    }
410
+	/**
411
+	 * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path
412
+	 *
413
+	 * @param string                    $base_path The original base path for message templates
414
+	 * @param EE_messenger              $messenger
415
+	 * @param EE_message_type           $message_type
416
+	 * @param string                    $field     The field requesting a template
417
+	 * @param string                    $context   The context requesting a template
418
+	 * @param EE_Messages_Template_Pack $template_pack
419
+	 *
420
+	 * @return string
421
+	 */
422
+	public static function register_base_template_path(
423
+		string $base_path,
424
+		EE_messenger $messenger,
425
+		EE_message_type $message_type,
426
+		string $field,
427
+		string $context,
428
+		EE_Messages_Template_Pack $template_pack
429
+	): string {
430
+		if (
431
+			! $template_pack instanceof EE_Messages_Template_Pack_Default
432
+			|| ! $message_type instanceof EE_message_type
433
+		) {
434
+			return $base_path;
435
+		}
436
+		foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
437
+			if ($message_type->name === $addon_name && ! empty($mt_reg['base_path_for_default_templates'])) {
438
+				return $mt_reg['base_path_for_default_templates'];
439
+			}
440
+		}
441
+		return $base_path;
442
+	}
443 443
 
444 444
 
445
-    /**
446
-     * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and
447
-     * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks
448
-     *
449
-     * @param string                    $base_path_or_url  The original incoming base url or path
450
-     * @param string                    $messenger_slug    The slug of the messenger the template is being generated
451
-     *                                                     for.
452
-     * @param string                    $message_type_slug The slug of the message type the template is being generated
453
-     *                                                     for.
454
-     * @param string                    $type              The "type" of css being requested.
455
-     * @param string                    $variation         The variation being requested.
456
-     * @param bool                      $url               whether a url or path is being requested.
457
-     * @param string                    $file_extension    What file extension is expected for the variation file.
458
-     * @param EE_Messages_Template_Pack $template_pack
459
-     *
460
-     * @return string
461
-     */
462
-    public static function register_variation_base_path_or_url(
463
-        string $base_path_or_url,
464
-        string $messenger_slug,
465
-        string $message_type_slug,
466
-        string $type,
467
-        string $variation,
468
-        bool $url,
469
-        string $file_extension,
470
-        EE_Messages_Template_Pack $template_pack
471
-    ): string {
472
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
473
-            return $base_path_or_url;
474
-        }
475
-        foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
476
-            if ($addon_name === $message_type_slug) {
477
-                if ($url && ! empty($mt_reg['base_url_for_default_variation'])) {
478
-                    return $mt_reg['base_url_for_default_variation'];
479
-                } elseif (! $url && ! empty($mt_reg['base_path_for_default_variation'])) {
480
-                    return $mt_reg['base_path_for_default_variation'];
481
-                }
482
-            }
483
-        }
484
-        return $base_path_or_url;
485
-    }
445
+	/**
446
+	 * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and
447
+	 * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks
448
+	 *
449
+	 * @param string                    $base_path_or_url  The original incoming base url or path
450
+	 * @param string                    $messenger_slug    The slug of the messenger the template is being generated
451
+	 *                                                     for.
452
+	 * @param string                    $message_type_slug The slug of the message type the template is being generated
453
+	 *                                                     for.
454
+	 * @param string                    $type              The "type" of css being requested.
455
+	 * @param string                    $variation         The variation being requested.
456
+	 * @param bool                      $url               whether a url or path is being requested.
457
+	 * @param string                    $file_extension    What file extension is expected for the variation file.
458
+	 * @param EE_Messages_Template_Pack $template_pack
459
+	 *
460
+	 * @return string
461
+	 */
462
+	public static function register_variation_base_path_or_url(
463
+		string $base_path_or_url,
464
+		string $messenger_slug,
465
+		string $message_type_slug,
466
+		string $type,
467
+		string $variation,
468
+		bool $url,
469
+		string $file_extension,
470
+		EE_Messages_Template_Pack $template_pack
471
+	): string {
472
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
473
+			return $base_path_or_url;
474
+		}
475
+		foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
476
+			if ($addon_name === $message_type_slug) {
477
+				if ($url && ! empty($mt_reg['base_url_for_default_variation'])) {
478
+					return $mt_reg['base_url_for_default_variation'];
479
+				} elseif (! $url && ! empty($mt_reg['base_path_for_default_variation'])) {
480
+					return $mt_reg['base_path_for_default_variation'];
481
+				}
482
+			}
483
+		}
484
+		return $base_path_or_url;
485
+	}
486 486
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         }
61 61
 
62 62
         // make sure we don't register twice
63
-        if (isset(self::$_ee_message_type_registry[ $addon_name ])) {
63
+        if (isset(self::$_ee_message_type_registry[$addon_name])) {
64 64
             return true;
65 65
         }
66 66
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             );
83 83
         }
84 84
         // setup $__ee_message_type_registry array from incoming values.
85
-        self::$_ee_message_type_registry[ $addon_name ] = [
85
+        self::$_ee_message_type_registry[$addon_name] = [
86 86
             /**
87 87
              * The file name for the message type being registered.
88 88
              * Required.
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public static function deregister(string $addon_name = '')
265 265
     {
266
-        if (! empty(self::$_ee_message_type_registry[ $addon_name ])) {
266
+        if ( ! empty(self::$_ee_message_type_registry[$addon_name])) {
267 267
             // let's make sure that we remove any place this message type was made active
268 268
             /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
269 269
             $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             );
276 276
             $Message_Resource_Manager->deactivate_message_type($addon_name, false);
277 277
         }
278
-        unset(self::$_ee_message_type_registry[ $addon_name ]);
278
+        unset(self::$_ee_message_type_registry[$addon_name]);
279 279
     }
280 280
 
281 281
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
     public static function register_msgs_autoload_paths(array $paths): array
312 312
     {
313 313
         $autoload_paths = [];
314
-        if (! empty(self::$_ee_message_type_registry)) {
314
+        if ( ! empty(self::$_ee_message_type_registry)) {
315 315
             foreach (self::$_ee_message_type_registry as $mt_reg) {
316 316
                 if (empty($mt_reg['autoloadpaths'])) {
317 317
                     continue;
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
                 continue;
401 401
             }
402 402
             foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
403
-                $supports[ $messenger_slug ][] = $addon_name;
403
+                $supports[$messenger_slug][] = $addon_name;
404 404
             }
405 405
         }
406 406
         return $supports;
@@ -469,14 +469,14 @@  discard block
 block discarded – undo
469 469
         string $file_extension,
470 470
         EE_Messages_Template_Pack $template_pack
471 471
     ): string {
472
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
472
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
473 473
             return $base_path_or_url;
474 474
         }
475 475
         foreach (self::$_ee_message_type_registry as $addon_name => $mt_reg) {
476 476
             if ($addon_name === $message_type_slug) {
477 477
                 if ($url && ! empty($mt_reg['base_url_for_default_variation'])) {
478 478
                     return $mt_reg['base_url_for_default_variation'];
479
-                } elseif (! $url && ! empty($mt_reg['base_path_for_default_variation'])) {
479
+                } elseif ( ! $url && ! empty($mt_reg['base_path_for_default_variation'])) {
480 480
                     return $mt_reg['base_path_for_default_variation'];
481 481
                 }
482 482
             }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Model_Extensions.lib.php 2 patches
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -11,136 +11,136 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Register_Model_Extensions implements EEI_Plugin_API
13 13
 {
14
-    protected static $_registry;
14
+	protected static $_registry;
15 15
 
16
-    protected static $_extensions = [];
16
+	protected static $_extensions = [];
17 17
 
18 18
 
19
-    /**
20
-     * register method for setting up model extensions
21
-     *
22
-     * @param string $addon_name            unique id for the extensions being setup
23
-     * @param array  $setup_args            {
24
-     * @return bool
25
-     * @throws EE_Error
26
-     * @type  array  $model_extension_paths array of folders containing DB model extensions, where each file follows
27
-     *                                      the models naming convention, which is:
28
-     *                                      EEME_{your_plugin_slug}_model_name_extended}.model_ext.php.
29
-     *                                      Where {your_plugin_slug} is really anything you want (but something having
30
-     *                                      to do with your addon, like 'Calendar' or '3D_View') and
31
-     *                                      model_name_extended} is the model extended.
32
-     *                                      The class contained in teh file should extend
33
-     *                                      EEME_Base_{model_name_extended}.model_ext.php.
34
-     *                                      Where {your_plugin_slug} is really anything you want (but something
35
-     *                                      having to do with your addon, like 'Calendar' or '3D_View') and
36
-     *                                      {model_name_extended} is the model extended. The class contained in teh
37
-     *                                      file should extend EEME_Base
38
-     * @type array   $class_extension_paths array of folders containing DB class extensions, where each file follows
39
-     *                                      the model class extension naming convention, which is:
40
-     *                                      EEE_{your_plugin_slug}_model_name_extended}.class_ext.php.
41
-     *                                      Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc,
42
-     *                                      and model_name_extended} is the name of the model extended, eg
43
-     *                                      'Attendee','Event',etc.
44
-     *                                      The class contained in the file should extend EEE_Base_Class
45
-     *                                      ._{model_name_extended}.class_ext.php.
46
-     *                                      Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc,
47
-     *                                      and {model_name_extended} is the name of the model extended, eg
48
-     *                                      'Attendee','Event',etc. The class contained in the file should extend
49
-     *                                      EEE_Base_Class.
50
-     *                                      }
51
-     *
52
-     */
53
-    public static function register(string $addon_name = '', array $setup_args = []): bool
54
-    {
55
-        // required fields MUST be present, so let's make sure they are.
56
-        if (
57
-            empty($addon_name)
58
-            || ! is_array($setup_args)
59
-            || (
60
-                empty($setup_args['model_extension_paths'])
61
-                && empty($setup_args['class_extension_paths'])
62
-            )
63
-        ) {
64
-            throw new EE_Error(
65
-                __(
66
-                    '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)',
67
-                    'event_espresso'
68
-                )
69
-            );
70
-        }
19
+	/**
20
+	 * register method for setting up model extensions
21
+	 *
22
+	 * @param string $addon_name            unique id for the extensions being setup
23
+	 * @param array  $setup_args            {
24
+	 * @return bool
25
+	 * @throws EE_Error
26
+	 * @type  array  $model_extension_paths array of folders containing DB model extensions, where each file follows
27
+	 *                                      the models naming convention, which is:
28
+	 *                                      EEME_{your_plugin_slug}_model_name_extended}.model_ext.php.
29
+	 *                                      Where {your_plugin_slug} is really anything you want (but something having
30
+	 *                                      to do with your addon, like 'Calendar' or '3D_View') and
31
+	 *                                      model_name_extended} is the model extended.
32
+	 *                                      The class contained in teh file should extend
33
+	 *                                      EEME_Base_{model_name_extended}.model_ext.php.
34
+	 *                                      Where {your_plugin_slug} is really anything you want (but something
35
+	 *                                      having to do with your addon, like 'Calendar' or '3D_View') and
36
+	 *                                      {model_name_extended} is the model extended. The class contained in teh
37
+	 *                                      file should extend EEME_Base
38
+	 * @type array   $class_extension_paths array of folders containing DB class extensions, where each file follows
39
+	 *                                      the model class extension naming convention, which is:
40
+	 *                                      EEE_{your_plugin_slug}_model_name_extended}.class_ext.php.
41
+	 *                                      Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc,
42
+	 *                                      and model_name_extended} is the name of the model extended, eg
43
+	 *                                      'Attendee','Event',etc.
44
+	 *                                      The class contained in the file should extend EEE_Base_Class
45
+	 *                                      ._{model_name_extended}.class_ext.php.
46
+	 *                                      Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc,
47
+	 *                                      and {model_name_extended} is the name of the model extended, eg
48
+	 *                                      'Attendee','Event',etc. The class contained in the file should extend
49
+	 *                                      EEE_Base_Class.
50
+	 *                                      }
51
+	 *
52
+	 */
53
+	public static function register(string $addon_name = '', array $setup_args = []): bool
54
+	{
55
+		// required fields MUST be present, so let's make sure they are.
56
+		if (
57
+			empty($addon_name)
58
+			|| ! is_array($setup_args)
59
+			|| (
60
+				empty($setup_args['model_extension_paths'])
61
+				&& empty($setup_args['class_extension_paths'])
62
+			)
63
+		) {
64
+			throw new EE_Error(
65
+				__(
66
+					'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)',
67
+					'event_espresso'
68
+				)
69
+			);
70
+		}
71 71
 
72
-        // make sure we don't register twice
73
-        if (isset(self::$_registry[ $addon_name ])) {
74
-            return true;
75
-        }
76
-        // check correct loading
77
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
78
-            EE_Error::doing_it_wrong(
79
-                __METHOD__,
80
-                sprintf(
81
-                    __(
82
-                        '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',
83
-                        'event_espresso'
84
-                    ),
85
-                    $addon_name,
86
-                    '<br />',
87
-                    did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done',
88
-                    did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done'
89
-                ),
90
-                '4.3'
91
-            );
92
-        }
72
+		// make sure we don't register twice
73
+		if (isset(self::$_registry[ $addon_name ])) {
74
+			return true;
75
+		}
76
+		// check correct loading
77
+		if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
78
+			EE_Error::doing_it_wrong(
79
+				__METHOD__,
80
+				sprintf(
81
+					__(
82
+						'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',
83
+						'event_espresso'
84
+					),
85
+					$addon_name,
86
+					'<br />',
87
+					did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done',
88
+					did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done'
89
+				),
90
+				'4.3'
91
+			);
92
+		}
93 93
 
94
-        self::$_registry[ $addon_name ]   = $setup_args;
95
-        self::$_extensions[ $addon_name ] = [];
94
+		self::$_registry[ $addon_name ]   = $setup_args;
95
+		self::$_extensions[ $addon_name ] = [];
96 96
 
97
-        if (isset($setup_args['model_extension_paths'])) {
98
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
99
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']);
100
-            // remove all files that are not PHP
101
-            foreach ($class_to_filepath_map as $class => $path) {
102
-                if (substr($path, strlen($path) - 3) !== 'php') {
103
-                    unset($class_to_filepath_map[ $class ]);
104
-                }
105
-            }
106
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
107
-            foreach (array_keys($class_to_filepath_map) as $classname) {
108
-                self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname();
109
-            }
110
-            unset($setup_args['model_extension_paths']);
111
-        }
112
-        if (isset($setup_args['class_extension_paths'])) {
113
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
114
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']);
115
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
116
-            foreach (array_keys($class_to_filepath_map) as $classname) {
117
-                self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname();
118
-            }
119
-            unset($setup_args['class_extension_paths']);
120
-        }
121
-        foreach ($setup_args as $unknown_key => $unknown_config) {
122
-            throw new EE_Error(
123
-                sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
124
-            );
125
-        }
126
-        return true;
127
-    }
97
+		if (isset($setup_args['model_extension_paths'])) {
98
+			require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
99
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']);
100
+			// remove all files that are not PHP
101
+			foreach ($class_to_filepath_map as $class => $path) {
102
+				if (substr($path, strlen($path) - 3) !== 'php') {
103
+					unset($class_to_filepath_map[ $class ]);
104
+				}
105
+			}
106
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
107
+			foreach (array_keys($class_to_filepath_map) as $classname) {
108
+				self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname();
109
+			}
110
+			unset($setup_args['model_extension_paths']);
111
+		}
112
+		if (isset($setup_args['class_extension_paths'])) {
113
+			require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
114
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']);
115
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
116
+			foreach (array_keys($class_to_filepath_map) as $classname) {
117
+				self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname();
118
+			}
119
+			unset($setup_args['class_extension_paths']);
120
+		}
121
+		foreach ($setup_args as $unknown_key => $unknown_config) {
122
+			throw new EE_Error(
123
+				sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
124
+			);
125
+		}
126
+		return true;
127
+	}
128 128
 
129 129
 
130
-    /**
131
-     * deregister
132
-     *
133
-     * @param string $addon_name
134
-     */
135
-    public static function deregister(string $addon_name = '')
136
-    {
137
-        if (isset(self::$_registry[ $addon_name ])) {
138
-            unset(self::$_registry[ $addon_name ]);
139
-            foreach (self::$_extensions[ $addon_name ] as $extension_of_type) {
140
-                foreach ($extension_of_type as $extension) {
141
-                    $extension->deregister();
142
-                }
143
-            }
144
-        }
145
-    }
130
+	/**
131
+	 * deregister
132
+	 *
133
+	 * @param string $addon_name
134
+	 */
135
+	public static function deregister(string $addon_name = '')
136
+	{
137
+		if (isset(self::$_registry[ $addon_name ])) {
138
+			unset(self::$_registry[ $addon_name ]);
139
+			foreach (self::$_extensions[ $addon_name ] as $extension_of_type) {
140
+				foreach ($extension_of_type as $extension) {
141
+					$extension->deregister();
142
+				}
143
+			}
144
+		}
145
+	}
146 146
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         // make sure we don't register twice
73
-        if (isset(self::$_registry[ $addon_name ])) {
73
+        if (isset(self::$_registry[$addon_name])) {
74 74
             return true;
75 75
         }
76 76
         // check correct loading
77
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
77
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
78 78
             EE_Error::doing_it_wrong(
79 79
                 __METHOD__,
80 80
                 sprintf(
@@ -91,30 +91,30 @@  discard block
 block discarded – undo
91 91
             );
92 92
         }
93 93
 
94
-        self::$_registry[ $addon_name ]   = $setup_args;
95
-        self::$_extensions[ $addon_name ] = [];
94
+        self::$_registry[$addon_name]   = $setup_args;
95
+        self::$_extensions[$addon_name] = [];
96 96
 
97 97
         if (isset($setup_args['model_extension_paths'])) {
98
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php');
98
+            require_once(EE_LIBRARIES.'plugin_api/db/EEME_Base.lib.php');
99 99
             $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']);
100 100
             // remove all files that are not PHP
101 101
             foreach ($class_to_filepath_map as $class => $path) {
102 102
                 if (substr($path, strlen($path) - 3) !== 'php') {
103
-                    unset($class_to_filepath_map[ $class ]);
103
+                    unset($class_to_filepath_map[$class]);
104 104
                 }
105 105
             }
106 106
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
107 107
             foreach (array_keys($class_to_filepath_map) as $classname) {
108
-                self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname();
108
+                self::$_extensions[$addon_name]['models'][$classname] = new $classname();
109 109
             }
110 110
             unset($setup_args['model_extension_paths']);
111 111
         }
112 112
         if (isset($setup_args['class_extension_paths'])) {
113
-            require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php');
113
+            require_once(EE_LIBRARIES.'plugin_api/db/EEE_Base_Class.lib.php');
114 114
             $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']);
115 115
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
116 116
             foreach (array_keys($class_to_filepath_map) as $classname) {
117
-                self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname();
117
+                self::$_extensions[$addon_name]['classes'][$classname] = new $classname();
118 118
             }
119 119
             unset($setup_args['class_extension_paths']);
120 120
         }
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public static function deregister(string $addon_name = '')
136 136
     {
137
-        if (isset(self::$_registry[ $addon_name ])) {
138
-            unset(self::$_registry[ $addon_name ]);
139
-            foreach (self::$_extensions[ $addon_name ] as $extension_of_type) {
137
+        if (isset(self::$_registry[$addon_name])) {
138
+            unset(self::$_registry[$addon_name]);
139
+            foreach (self::$_extensions[$addon_name] as $extension_of_type) {
140 140
                 foreach ($extension_of_type as $extension) {
141 141
                     $extension->deregister();
142 142
                 }
Please login to merge, or discard this patch.
core/domain/services/admin/events/editor/FormBuilder.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -25,87 +25,87 @@
 block discarded – undo
25 25
 {
26 26
 
27 27
 
28
-    /**
29
-     * @param int $eventId
30
-     * @return array
31
-     * @throws EE_Error
32
-     * @throws ReflectionException
33
-     */
34
-    public function getData(int $eventId): array
35
-    {
36
-        /** @var EE_Event $event */
37
-        $event = EEM_Event::instance()->get_one_by_ID($eventId);
38
-        $topLevelSectionId = $event->registrationFormUuid();
28
+	/**
29
+	 * @param int $eventId
30
+	 * @return array
31
+	 * @throws EE_Error
32
+	 * @throws ReflectionException
33
+	 */
34
+	public function getData(int $eventId): array
35
+	{
36
+		/** @var EE_Event $event */
37
+		$event = EEM_Event::instance()->get_one_by_ID($eventId);
38
+		$topLevelSectionId = $event->registrationFormUuid();
39 39
 
40
-        /** @var EE_Form_Section[] $form_sections */
41
-        $form_sections = EEM_Form_Section::instance()->get_all([
42
-            [
43
-                'OR' => [
44
-                    'FSC_UUID'      => $topLevelSectionId, // top level form
45
-                    'FSC_belongsTo' => $topLevelSectionId, // child form sections
46
-                    'FSC_status'    => FormStatus::SHARED, // shared form sections
47
-                ]
48
-                ],
49
-            'order_by' => ['FSC_order' => 'ASC'],
50
-        ]);
40
+		/** @var EE_Form_Section[] $form_sections */
41
+		$form_sections = EEM_Form_Section::instance()->get_all([
42
+			[
43
+				'OR' => [
44
+					'FSC_UUID'      => $topLevelSectionId, // top level form
45
+					'FSC_belongsTo' => $topLevelSectionId, // child form sections
46
+					'FSC_status'    => FormStatus::SHARED, // shared form sections
47
+				]
48
+				],
49
+			'order_by' => ['FSC_order' => 'ASC'],
50
+		]);
51 51
 
52
-        $sections = [];
53
-        foreach ($form_sections as $section) {
54
-            if ($section instanceof EE_Form_Section) {
55
-                $UUID = $section->UUID();
52
+		$sections = [];
53
+		foreach ($form_sections as $section) {
54
+			if ($section instanceof EE_Form_Section) {
55
+				$UUID = $section->UUID();
56 56
 
57
-                // Avoid duplicates, if any
58
-                $sections[ $UUID ] = [
59
-                    'id'         => $UUID,
60
-                    'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
61
-                    'attributes' => $section->attributes()->toJson(),
62
-                    'belongsTo'  => $section->belongsTo(),
63
-                    'isActive'   => $section->isActive(),
64
-                    'isArchived' => $section->isArchived(),
65
-                    'isDefault'  => $section->isDefault(),
66
-                    'isShared'   => $section->isShared(),
67
-                    'isTrashed'  => $section->isTrashed(),
68
-                    'label'      => $section->label()->toJson(),
69
-                    'order'      => $section->order(),
70
-                    'status'     => GQLUtils::formatEnumKey($section->status()),
71
-                ];
72
-            }
73
-        }
57
+				// Avoid duplicates, if any
58
+				$sections[ $UUID ] = [
59
+					'id'         => $UUID,
60
+					'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
61
+					'attributes' => $section->attributes()->toJson(),
62
+					'belongsTo'  => $section->belongsTo(),
63
+					'isActive'   => $section->isActive(),
64
+					'isArchived' => $section->isArchived(),
65
+					'isDefault'  => $section->isDefault(),
66
+					'isShared'   => $section->isShared(),
67
+					'isTrashed'  => $section->isTrashed(),
68
+					'label'      => $section->label()->toJson(),
69
+					'order'      => $section->order(),
70
+					'status'     => GQLUtils::formatEnumKey($section->status()),
71
+				];
72
+			}
73
+		}
74 74
 
75
-        /** @var EE_Form_Element[] $form_elements */
76
-        $form_elements = EEM_Form_Element::instance()->get_all([
77
-            [
78
-                'FSC_UUID' => ['IN', array_keys($sections)]
79
-            ]
80
-        ]);
75
+		/** @var EE_Form_Element[] $form_elements */
76
+		$form_elements = EEM_Form_Element::instance()->get_all([
77
+			[
78
+				'FSC_UUID' => ['IN', array_keys($sections)]
79
+			]
80
+		]);
81 81
 
82
-        $elements = [];
83
-        foreach ($form_elements as $element) {
84
-            if ($element instanceof EE_Form_Element) {
85
-                $UUID = $element->UUID();
82
+		$elements = [];
83
+		foreach ($form_elements as $element) {
84
+			if ($element instanceof EE_Form_Element) {
85
+				$UUID = $element->UUID();
86 86
 
87
-            // Avoid duplicates
88
-                $elements[ $UUID ] = [
89
-                'id'         => $UUID,
90
-                'adminOnly'  => $element->adminOnly(),
91
-                'attributes' => $element->attributes()->toJson(),
92
-                'belongsTo'  => $element->belongsTo(),
93
-                'helpText'   => $element->helpText()->toJson(),
94
-                'label'      => $element->label()->toJson(),
95
-                'mapsTo'     => $element->mapsTo(),
96
-                'options'    => $element->options()->toJson(),
97
-                'order'      => $element->order(),
98
-                'required'   => $element->required()->toJson(),
99
-                'status'     => GQLUtils::formatEnumKey($element->status()),
100
-                'type'       => GQLUtils::formatEnumKey($element->type()),
101
-                ];
102
-            }
103
-        }
87
+			// Avoid duplicates
88
+				$elements[ $UUID ] = [
89
+				'id'         => $UUID,
90
+				'adminOnly'  => $element->adminOnly(),
91
+				'attributes' => $element->attributes()->toJson(),
92
+				'belongsTo'  => $element->belongsTo(),
93
+				'helpText'   => $element->helpText()->toJson(),
94
+				'label'      => $element->label()->toJson(),
95
+				'mapsTo'     => $element->mapsTo(),
96
+				'options'    => $element->options()->toJson(),
97
+				'order'      => $element->order(),
98
+				'required'   => $element->required()->toJson(),
99
+				'status'     => GQLUtils::formatEnumKey($element->status()),
100
+				'type'       => GQLUtils::formatEnumKey($element->type()),
101
+				];
102
+			}
103
+		}
104 104
 
105
-        return [
106
-            'elements'          => array_values($elements),
107
-            'sections'          => array_values($sections),
108
-            'topLevelSectionId' => $event->registrationFormUuid()
109
-        ];
110
-    }
105
+		return [
106
+			'elements'          => array_values($elements),
107
+			'sections'          => array_values($sections),
108
+			'topLevelSectionId' => $event->registrationFormUuid()
109
+		];
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 $UUID = $section->UUID();
56 56
 
57 57
                 // Avoid duplicates, if any
58
-                $sections[ $UUID ] = [
58
+                $sections[$UUID] = [
59 59
                     'id'         => $UUID,
60 60
                     'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
61 61
                     'attributes' => $section->attributes()->toJson(),
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 $UUID = $element->UUID();
86 86
 
87 87
             // Avoid duplicates
88
-                $elements[ $UUID ] = [
88
+                $elements[$UUID] = [
89 89
                 'id'         => $UUID,
90 90
                 'adminOnly'  => $element->adminOnly(),
91 91
                 'attributes' => $element->attributes()->toJson(),
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Text.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,61 +4,61 @@
 block discarded – undo
4 4
 
5 5
 class Text
6 6
 {
7
-    /**
8
-     * indicates that the HTML input type is 'email'
9
-     */
10
-    public const TYPE_EMAIL = 'email';
7
+	/**
8
+	 * indicates that the HTML input type is 'email'
9
+	 */
10
+	public const TYPE_EMAIL = 'email';
11 11
 
12
-    /**
13
-     * indicates that the input is used to confirm an email address
14
-     */
15
-    public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation';
12
+	/**
13
+	 * indicates that the input is used to confirm an email address
14
+	 */
15
+	public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation';
16 16
 
17
-    /**
18
-     * indicates that the HTML input type is 'text'
19
-     */
20
-    public const TYPE_TEXT = 'text';
17
+	/**
18
+	 * indicates that the HTML input type is 'text'
19
+	 */
20
+	public const TYPE_TEXT = 'text';
21 21
 
22
-    /**
23
-     * indicates that the input is a TEXTAREA that only allows plain text
24
-     */
25
-    public const TYPE_TEXTAREA = 'textarea';
22
+	/**
23
+	 * indicates that the input is a TEXTAREA that only allows plain text
24
+	 */
25
+	public const TYPE_TEXTAREA = 'textarea';
26 26
 
27
-    /**
28
-     * indicates that the input is a TEXTAREA that allows simple html
29
-     */
30
-    public const TYPE_TEXTAREA_HTML = 'textarea-html';
27
+	/**
28
+	 * indicates that the input is a TEXTAREA that allows simple html
29
+	 */
30
+	public const TYPE_TEXTAREA_HTML = 'textarea-html';
31 31
 
32 32
 
33
-    /**
34
-     * @var array
35
-     */
36
-    private $valid_type_options;
33
+	/**
34
+	 * @var array
35
+	 */
36
+	private $valid_type_options;
37 37
 
38 38
 
39
-    public function __construct()
40
-    {
41
-        $this->valid_type_options = apply_filters(
42
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options',
43
-            [
44
-                Text::TYPE_EMAIL              => esc_html__('Email', 'event_espresso'),
45
-                Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'),
46
-                Text::TYPE_TEXT               => esc_html__('Plain Text', 'event_espresso'),
47
-                Text::TYPE_TEXTAREA           => esc_html__('Plain Textarea', 'event_espresso'),
48
-                Text::TYPE_TEXTAREA_HTML      => esc_html__('Simple HTML Textarea', 'event_espresso'),
49
-            ]
50
-        );
51
-    }
39
+	public function __construct()
40
+	{
41
+		$this->valid_type_options = apply_filters(
42
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options',
43
+			[
44
+				Text::TYPE_EMAIL              => esc_html__('Email', 'event_espresso'),
45
+				Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'),
46
+				Text::TYPE_TEXT               => esc_html__('Plain Text', 'event_espresso'),
47
+				Text::TYPE_TEXTAREA           => esc_html__('Plain Textarea', 'event_espresso'),
48
+				Text::TYPE_TEXTAREA_HTML      => esc_html__('Simple HTML Textarea', 'event_espresso'),
49
+			]
50
+		);
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @param bool $constants_only
56
-     * @return array
57
-     */
58
-    public function validTypeOptions(bool $constants_only = false): array
59
-    {
60
-        return $constants_only
61
-            ? array_keys($this->valid_type_options)
62
-            : $this->valid_type_options;
63
-    }
54
+	/**
55
+	 * @param bool $constants_only
56
+	 * @return array
57
+	 */
58
+	public function validTypeOptions(bool $constants_only = false): array
59
+	{
60
+		return $constants_only
61
+			? array_keys($this->valid_type_options)
62
+			: $this->valid_type_options;
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Input.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -5,90 +5,90 @@
 block discarded – undo
5 5
 class Input
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the HTML input type is 'checkbox'
10
-     */
11
-    public const TYPE_CHECKBOX = 'checkbox';
12
-
13
-    /**
14
-     * indicates that the HTML input type is 'multi checkbox'
15
-     */
16
-    public const TYPE_CHECKBOX_MULTI = 'checkbox-multi';
17
-
18
-    /**
19
-     * indicates that the HTML input type is 'color'
20
-     */
21
-    public const TYPE_COLOR = 'color';
22
-
23
-    /**
24
-     * indicates that the HTML input type is 'file'
25
-     */
26
-    public const TYPE_FILE = 'file';
27
-
28
-    /**
29
-     * indicates that the HTML input type is 'hidden'
30
-     */
31
-    public const TYPE_HIDDEN = 'hidden';
32
-
33
-    /**
34
-     * indicates that the HTML input type is 'image'
35
-     */
36
-    public const TYPE_IMAGE = 'image';
37
-
38
-    /**
39
-     * indicates that the HTML input type is 'password'
40
-     */
41
-    public const TYPE_PASSWORD = 'password';
42
-
43
-    /**
44
-     * indicates that the input is used to confirm a password
45
-     */
46
-    public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation';
47
-
48
-    /**
49
-     * indicates that the HTML input type is 'radio'
50
-     */
51
-    public const TYPE_RADIO = 'radio';
52
-
53
-    /**
54
-     * indicates that the HTML input type is 'url'
55
-     */
56
-    public const TYPE_URL = 'url';
57
-
58
-    /**
59
-     * @var array
60
-     */
61
-    private $valid_type_options;
62
-
63
-
64
-    public function __construct()
65
-    {
66
-        $this->valid_type_options = apply_filters(
67
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options',
68
-            [
69
-                Input::TYPE_CHECKBOX              => esc_html__('Checkbox', 'event_espresso'),
70
-                Input::TYPE_CHECKBOX_MULTI        => esc_html__('Multi Checkbox', 'event_espresso'),
71
-                Input::TYPE_COLOR                 => esc_html__('Color Picker', 'event_espresso'),
72
-                Input::TYPE_FILE                  => esc_html__('File Upload', 'event_espresso'),
73
-                Input::TYPE_HIDDEN                => esc_html__('Hidden', 'event_espresso'),
74
-                Input::TYPE_IMAGE                 => esc_html__('Image Upload', 'event_espresso'),
75
-                Input::TYPE_PASSWORD              => esc_html__('Password', 'event_espresso'),
76
-                Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'),
77
-                Input::TYPE_RADIO                 => esc_html__('Radio Button', 'event_espresso'),
78
-                Input::TYPE_URL                   => esc_html__('URL', 'event_espresso'),
79
-            ]
80
-        );
81
-    }
82
-
83
-
84
-    /**
85
-     * @param bool $constants_only
86
-     * @return array
87
-     */
88
-    public function validTypeOptions(bool $constants_only = false): array
89
-    {
90
-        return $constants_only
91
-            ? array_keys($this->valid_type_options)
92
-            : $this->valid_type_options;
93
-    }
8
+	/**
9
+	 * indicates that the HTML input type is 'checkbox'
10
+	 */
11
+	public const TYPE_CHECKBOX = 'checkbox';
12
+
13
+	/**
14
+	 * indicates that the HTML input type is 'multi checkbox'
15
+	 */
16
+	public const TYPE_CHECKBOX_MULTI = 'checkbox-multi';
17
+
18
+	/**
19
+	 * indicates that the HTML input type is 'color'
20
+	 */
21
+	public const TYPE_COLOR = 'color';
22
+
23
+	/**
24
+	 * indicates that the HTML input type is 'file'
25
+	 */
26
+	public const TYPE_FILE = 'file';
27
+
28
+	/**
29
+	 * indicates that the HTML input type is 'hidden'
30
+	 */
31
+	public const TYPE_HIDDEN = 'hidden';
32
+
33
+	/**
34
+	 * indicates that the HTML input type is 'image'
35
+	 */
36
+	public const TYPE_IMAGE = 'image';
37
+
38
+	/**
39
+	 * indicates that the HTML input type is 'password'
40
+	 */
41
+	public const TYPE_PASSWORD = 'password';
42
+
43
+	/**
44
+	 * indicates that the input is used to confirm a password
45
+	 */
46
+	public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation';
47
+
48
+	/**
49
+	 * indicates that the HTML input type is 'radio'
50
+	 */
51
+	public const TYPE_RADIO = 'radio';
52
+
53
+	/**
54
+	 * indicates that the HTML input type is 'url'
55
+	 */
56
+	public const TYPE_URL = 'url';
57
+
58
+	/**
59
+	 * @var array
60
+	 */
61
+	private $valid_type_options;
62
+
63
+
64
+	public function __construct()
65
+	{
66
+		$this->valid_type_options = apply_filters(
67
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options',
68
+			[
69
+				Input::TYPE_CHECKBOX              => esc_html__('Checkbox', 'event_espresso'),
70
+				Input::TYPE_CHECKBOX_MULTI        => esc_html__('Multi Checkbox', 'event_espresso'),
71
+				Input::TYPE_COLOR                 => esc_html__('Color Picker', 'event_espresso'),
72
+				Input::TYPE_FILE                  => esc_html__('File Upload', 'event_espresso'),
73
+				Input::TYPE_HIDDEN                => esc_html__('Hidden', 'event_espresso'),
74
+				Input::TYPE_IMAGE                 => esc_html__('Image Upload', 'event_espresso'),
75
+				Input::TYPE_PASSWORD              => esc_html__('Password', 'event_espresso'),
76
+				Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'),
77
+				Input::TYPE_RADIO                 => esc_html__('Radio Button', 'event_espresso'),
78
+				Input::TYPE_URL                   => esc_html__('URL', 'event_espresso'),
79
+			]
80
+		);
81
+	}
82
+
83
+
84
+	/**
85
+	 * @param bool $constants_only
86
+	 * @return array
87
+	 */
88
+	public function validTypeOptions(bool $constants_only = false): array
89
+	{
90
+		return $constants_only
91
+			? array_keys($this->valid_type_options)
92
+			: $this->valid_type_options;
93
+	}
94 94
 }
Please login to merge, or discard this patch.