Completed
Branch EDTR/master (8c09db)
by
unknown
09:27 queued 29s
created
core/libraries/plugin_api/db/EEE_Base_Class.lib.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -32,126 +32,126 @@
 block discarded – undo
32 32
 class EEE_Base_Class
33 33
 {
34 34
 
35
-    const extending_method_prefix = 'ext_';
36
-    const dynamic_callback_method_prefix = 'dynamic_callback_method_';
37
-    /**
38
-     * The model name that is extended (not classname)
39
-     *
40
-     * @var string
41
-     */
42
-    protected $_model_name_extended = null;
43
-    /**
44
-     * The model this extends
45
-     *
46
-     * @var EE_Base_Class
47
-     */
48
-    protected $_ = null;
35
+	const extending_method_prefix = 'ext_';
36
+	const dynamic_callback_method_prefix = 'dynamic_callback_method_';
37
+	/**
38
+	 * The model name that is extended (not classname)
39
+	 *
40
+	 * @var string
41
+	 */
42
+	protected $_model_name_extended = null;
43
+	/**
44
+	 * The model this extends
45
+	 *
46
+	 * @var EE_Base_Class
47
+	 */
48
+	protected $_ = null;
49 49
 
50
-    public function __construct()
51
-    {
52
-        if (! $this->_model_name_extended) {
53
-            throw new EE_Error(
54
-                sprintf(
55
-                    __(
56
-                        "When declaring a class extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
57
-                        "event_espresso"
58
-                    )
59
-                )
60
-            );
61
-        }
62
-        if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
63
-            throw new EE_Error(
64
-                sprintf(
65
-                    __(
66
-                        "Hooked in model object extension '%s' too late! The model object %s has already been used!",
67
-                        "event_espresso"
68
-                    ),
69
-                    get_class($this),
70
-                    $this->_model_name_extended
71
-                )
72
-            );
73
-        }
74
-        $this->_register_extending_methods();
75
-    }
50
+	public function __construct()
51
+	{
52
+		if (! $this->_model_name_extended) {
53
+			throw new EE_Error(
54
+				sprintf(
55
+					__(
56
+						"When declaring a class extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
57
+						"event_espresso"
58
+					)
59
+				)
60
+			);
61
+		}
62
+		if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
63
+			throw new EE_Error(
64
+				sprintf(
65
+					__(
66
+						"Hooked in model object extension '%s' too late! The model object %s has already been used!",
67
+						"event_espresso"
68
+					),
69
+					get_class($this),
70
+					$this->_model_name_extended
71
+				)
72
+			);
73
+		}
74
+		$this->_register_extending_methods();
75
+	}
76 76
 
77
-    /**
78
-     * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
79
-     * model extended. (Internally uses filters, and the __call magic method)
80
-     */
81
-    protected function _register_extending_methods()
82
-    {
83
-        $all_methods = get_class_methods(get_class($this));
84
-        foreach ($all_methods as $method_name) {
85
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
86
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
87
-                $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88
-                add_filter(
89
-                    $callback_name,
90
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
91
-                    10,
92
-                    10
93
-                );
94
-            }
95
-        }
96
-    }
77
+	/**
78
+	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
79
+	 * model extended. (Internally uses filters, and the __call magic method)
80
+	 */
81
+	protected function _register_extending_methods()
82
+	{
83
+		$all_methods = get_class_methods(get_class($this));
84
+		foreach ($all_methods as $method_name) {
85
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
86
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
87
+				$callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88
+				add_filter(
89
+					$callback_name,
90
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
91
+					10,
92
+					10
93
+				);
94
+			}
95
+		}
96
+	}
97 97
 
98
-    /**
99
-     * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
100
-     * model extended. (Internally uses filters, and the __call magic method)
101
-     */
102
-    public function deregister()
103
-    {
104
-        $all_methods = get_class_methods(get_class($this));
105
-        foreach ($all_methods as $method_name) {
106
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
107
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
108
-                $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109
-                remove_filter(
110
-                    $callback_name,
111
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
112
-                    10
113
-                );
114
-            }
115
-        }
116
-    }
98
+	/**
99
+	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
100
+	 * model extended. (Internally uses filters, and the __call magic method)
101
+	 */
102
+	public function deregister()
103
+	{
104
+		$all_methods = get_class_methods(get_class($this));
105
+		foreach ($all_methods as $method_name) {
106
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
107
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
108
+				$callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109
+				remove_filter(
110
+					$callback_name,
111
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
112
+					10
113
+				);
114
+			}
115
+		}
116
+	}
117 117
 
118 118
 
119
-    public function __call($callback_method_name, $args)
120
-    {
121
-        if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
122
-            // it's a dynamic callback for a method name
123
-            $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
124
-            $original_return_val = $args[0];
125
-            $model_called = $args[1];
126
-            // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
127
-            $this->_ = $model_called;
128
-            // phpcs:enable
129
-            $args_provided_to_method_on_model = $args[2];
130
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
131
-            if (method_exists($this, $extending_method)) {
132
-                return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133
-            } else {
134
-                throw new EE_Error(
135
-                    sprintf(
136
-                        __(
137
-                            "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
138
-                            "event_espresso"
139
-                        ),
140
-                        $this->_model_name_extended,
141
-                        get_class($this),
142
-                        $extending_method,
143
-                        $extending_method
144
-                    )
145
-                );
146
-            }
147
-        } else {
148
-            throw new EE_Error(
149
-                sprintf(
150
-                    __("There is no method named '%s' on '%s'", "event_espresso"),
151
-                    $callback_method_name,
152
-                    get_class($this)
153
-                )
154
-            );
155
-        }
156
-    }
119
+	public function __call($callback_method_name, $args)
120
+	{
121
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
122
+			// it's a dynamic callback for a method name
123
+			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
124
+			$original_return_val = $args[0];
125
+			$model_called = $args[1];
126
+			// phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
127
+			$this->_ = $model_called;
128
+			// phpcs:enable
129
+			$args_provided_to_method_on_model = $args[2];
130
+			$extending_method = self::extending_method_prefix . $method_called_on_model;
131
+			if (method_exists($this, $extending_method)) {
132
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133
+			} else {
134
+				throw new EE_Error(
135
+					sprintf(
136
+						__(
137
+							"An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
138
+							"event_espresso"
139
+						),
140
+						$this->_model_name_extended,
141
+						get_class($this),
142
+						$extending_method,
143
+						$extending_method
144
+					)
145
+				);
146
+			}
147
+		} else {
148
+			throw new EE_Error(
149
+				sprintf(
150
+					__("There is no method named '%s' on '%s'", "event_espresso"),
151
+					$callback_method_name,
152
+					get_class($this)
153
+				)
154
+			);
155
+		}
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function __construct()
51 51
     {
52
-        if (! $this->_model_name_extended) {
52
+        if ( ! $this->_model_name_extended) {
53 53
             throw new EE_Error(
54 54
                 sprintf(
55 55
                     __(
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                 )
60 60
             );
61 61
         }
62
-        if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
62
+        if (did_action('AHEE__EE_'.$this->_model_name_extended.'__construct__end')) {
63 63
             throw new EE_Error(
64 64
                 sprintf(
65 65
                     __(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88 88
                 add_filter(
89 89
                     $callback_name,
90
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
90
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
91 91
                     10,
92 92
                     10
93 93
                 );
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109 109
                 remove_filter(
110 110
                     $callback_name,
111
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
111
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
112 112
                     10
113 113
                 );
114 114
             }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             $this->_ = $model_called;
128 128
             // phpcs:enable
129 129
             $args_provided_to_method_on_model = $args[2];
130
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
130
+            $extending_method = self::extending_method_prefix.$method_called_on_model;
131 131
             if (method_exists($this, $extending_method)) {
132 132
                 return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133 133
             } else {
Please login to merge, or discard this patch.
core/libraries/plugin_api/db/EEME_Base.lib.php 2 patches
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -44,211 +44,211 @@
 block discarded – undo
44 44
 abstract class EEME_Base
45 45
 {
46 46
 
47
-    const extending_method_prefix = 'ext_';
48
-    const dynamic_callback_method_prefix = 'dynamic_callback_method_';
49
-
50
-    protected $_extra_tables = array();
51
-    protected $_extra_fields = array();
52
-    protected $_extra_relations = array();
53
-
54
-    /**
55
-     * The model name that is extended (not classname)
56
-     *
57
-     * @var string
58
-     */
59
-    protected $_model_name_extended = null;
60
-
61
-    /**
62
-     * The model this extends
63
-     *
64
-     * @var EEM_Base
65
-     */
66
-    protected $_ = null;
67
-
68
-
69
-    /**
70
-     * @throws \EE_Error
71
-     */
72
-    public function __construct()
73
-    {
74
-        if (! $this->_model_name_extended) {
75
-            throw new EE_Error(
76
-                __(
77
-                    "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
78
-                    "event_espresso"
79
-                )
80
-            );
81
-        }
82
-        $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
83
-        if (did_action($construct_end_action)) {
84
-            throw new EE_Error(
85
-                sprintf(
86
-                    __(
87
-                        "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired",
88
-                        "event_espresso"
89
-                    ),
90
-                    get_class($this),
91
-                    $this->_model_name_extended,
92
-                    $construct_end_action
93
-                )
94
-            );
95
-        }
96
-        add_filter(
97
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
98
-            array($this, 'add_extra_tables_on_filter')
99
-        );
100
-        add_filter(
101
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
102
-            array($this, 'add_extra_fields_on_filter')
103
-        );
104
-        add_filter(
105
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
106
-            array($this, 'add_extra_relations_on_filter')
107
-        );
108
-        $this->_register_extending_methods();
109
-    }
110
-
111
-
112
-    /**
113
-     * @param array $existing_tables
114
-     * @return array
115
-     */
116
-    public function add_extra_tables_on_filter($existing_tables)
117
-    {
118
-        return array_merge((array) $existing_tables, $this->_extra_tables);
119
-    }
120
-
121
-
122
-    /**
123
-     * @param array $existing_fields
124
-     * @return array
125
-     */
126
-    public function add_extra_fields_on_filter($existing_fields)
127
-    {
128
-        if ($this->_extra_fields) {
129
-            foreach ($this->_extra_fields as $table_alias => $fields) {
130
-                if (! isset($existing_fields[ $table_alias ])) {
131
-                    $existing_fields[ $table_alias ] = array();
132
-                }
133
-                $existing_fields[ $table_alias ] = array_merge(
134
-                    (array) $existing_fields[ $table_alias ],
135
-                    $this->_extra_fields[ $table_alias ]
136
-                );
137
-            }
138
-        }
139
-        return $existing_fields;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param array $existing_relations
145
-     * @return array
146
-     */
147
-    public function add_extra_relations_on_filter($existing_relations)
148
-    {
149
-        return array_merge((array) $existing_relations, $this->_extra_relations);
150
-    }
151
-
152
-
153
-    /**
154
-     * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
155
-     * model extended. (Internally uses filters, and the __call magic method)
156
-     */
157
-    protected function _register_extending_methods()
158
-    {
159
-        $all_methods = get_class_methods(get_class($this));
160
-        foreach ($all_methods as $method_name) {
161
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
162
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
163
-                $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
164
-                add_filter(
165
-                    $callback_name,
166
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
167
-                    10,
168
-                    10
169
-                );
170
-            }
171
-        }
172
-    }
173
-
174
-    /**
175
-     * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
176
-     * model extended. (Internally uses filters, and the __call magic method)
177
-     */
178
-    public function deregister()
179
-    {
180
-        remove_filter(
181
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
182
-            array($this, 'add_extra_tables_on_filter')
183
-        );
184
-        remove_filter(
185
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
186
-            array($this, 'add_extra_fields_on_filter')
187
-        );
188
-        remove_filter(
189
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
190
-            array($this, 'add_extra_relations_on_filter')
191
-        );
192
-        $all_methods = get_class_methods(get_class($this));
193
-        foreach ($all_methods as $method_name) {
194
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
195
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
196
-                $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
197
-                remove_filter(
198
-                    $callback_name,
199
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
200
-                    10
201
-                );
202
-            }
203
-        }
204
-        /** @var EEM_Base $model_to_reset */
205
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
206
-        if (class_exists($model_to_reset)) {
207
-            $model_to_reset::reset();
208
-        }
209
-    }
210
-
211
-
212
-    /**
213
-     * @param string $callback_method_name
214
-     * @param array  $args
215
-     * @return mixed
216
-     * @throws EE_Error
217
-     */
218
-    public function __call($callback_method_name, $args)
219
-    {
220
-        if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
221
-            // it's a dynamic callback for a method name
222
-            $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
223
-            list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
224
-            // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
225
-            $this->_ = $model_called;
226
-            // phpcs:enable
227
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
228
-            if (method_exists($this, $extending_method)) {
229
-                return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
230
-            } else {
231
-                throw new EE_Error(
232
-                    sprintf(
233
-                        __(
234
-                            "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
235
-                            "event_espresso"
236
-                        ),
237
-                        $this->_model_name_extended,
238
-                        get_class($this),
239
-                        $extending_method,
240
-                        $extending_method
241
-                    )
242
-                );
243
-            }
244
-        } else {
245
-            throw new EE_Error(
246
-                sprintf(
247
-                    __("There is no method named '%s' on '%s'", "event_espresso"),
248
-                    $callback_method_name,
249
-                    get_class($this)
250
-                )
251
-            );
252
-        }
253
-    }
47
+	const extending_method_prefix = 'ext_';
48
+	const dynamic_callback_method_prefix = 'dynamic_callback_method_';
49
+
50
+	protected $_extra_tables = array();
51
+	protected $_extra_fields = array();
52
+	protected $_extra_relations = array();
53
+
54
+	/**
55
+	 * The model name that is extended (not classname)
56
+	 *
57
+	 * @var string
58
+	 */
59
+	protected $_model_name_extended = null;
60
+
61
+	/**
62
+	 * The model this extends
63
+	 *
64
+	 * @var EEM_Base
65
+	 */
66
+	protected $_ = null;
67
+
68
+
69
+	/**
70
+	 * @throws \EE_Error
71
+	 */
72
+	public function __construct()
73
+	{
74
+		if (! $this->_model_name_extended) {
75
+			throw new EE_Error(
76
+				__(
77
+					"When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
78
+					"event_espresso"
79
+				)
80
+			);
81
+		}
82
+		$construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
83
+		if (did_action($construct_end_action)) {
84
+			throw new EE_Error(
85
+				sprintf(
86
+					__(
87
+						"Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired",
88
+						"event_espresso"
89
+					),
90
+					get_class($this),
91
+					$this->_model_name_extended,
92
+					$construct_end_action
93
+				)
94
+			);
95
+		}
96
+		add_filter(
97
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
98
+			array($this, 'add_extra_tables_on_filter')
99
+		);
100
+		add_filter(
101
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
102
+			array($this, 'add_extra_fields_on_filter')
103
+		);
104
+		add_filter(
105
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
106
+			array($this, 'add_extra_relations_on_filter')
107
+		);
108
+		$this->_register_extending_methods();
109
+	}
110
+
111
+
112
+	/**
113
+	 * @param array $existing_tables
114
+	 * @return array
115
+	 */
116
+	public function add_extra_tables_on_filter($existing_tables)
117
+	{
118
+		return array_merge((array) $existing_tables, $this->_extra_tables);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param array $existing_fields
124
+	 * @return array
125
+	 */
126
+	public function add_extra_fields_on_filter($existing_fields)
127
+	{
128
+		if ($this->_extra_fields) {
129
+			foreach ($this->_extra_fields as $table_alias => $fields) {
130
+				if (! isset($existing_fields[ $table_alias ])) {
131
+					$existing_fields[ $table_alias ] = array();
132
+				}
133
+				$existing_fields[ $table_alias ] = array_merge(
134
+					(array) $existing_fields[ $table_alias ],
135
+					$this->_extra_fields[ $table_alias ]
136
+				);
137
+			}
138
+		}
139
+		return $existing_fields;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param array $existing_relations
145
+	 * @return array
146
+	 */
147
+	public function add_extra_relations_on_filter($existing_relations)
148
+	{
149
+		return array_merge((array) $existing_relations, $this->_extra_relations);
150
+	}
151
+
152
+
153
+	/**
154
+	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
155
+	 * model extended. (Internally uses filters, and the __call magic method)
156
+	 */
157
+	protected function _register_extending_methods()
158
+	{
159
+		$all_methods = get_class_methods(get_class($this));
160
+		foreach ($all_methods as $method_name) {
161
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
162
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
163
+				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
164
+				add_filter(
165
+					$callback_name,
166
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
167
+					10,
168
+					10
169
+				);
170
+			}
171
+		}
172
+	}
173
+
174
+	/**
175
+	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
176
+	 * model extended. (Internally uses filters, and the __call magic method)
177
+	 */
178
+	public function deregister()
179
+	{
180
+		remove_filter(
181
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
182
+			array($this, 'add_extra_tables_on_filter')
183
+		);
184
+		remove_filter(
185
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
186
+			array($this, 'add_extra_fields_on_filter')
187
+		);
188
+		remove_filter(
189
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
190
+			array($this, 'add_extra_relations_on_filter')
191
+		);
192
+		$all_methods = get_class_methods(get_class($this));
193
+		foreach ($all_methods as $method_name) {
194
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
195
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
196
+				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
197
+				remove_filter(
198
+					$callback_name,
199
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
200
+					10
201
+				);
202
+			}
203
+		}
204
+		/** @var EEM_Base $model_to_reset */
205
+		$model_to_reset = 'EEM_' . $this->_model_name_extended;
206
+		if (class_exists($model_to_reset)) {
207
+			$model_to_reset::reset();
208
+		}
209
+	}
210
+
211
+
212
+	/**
213
+	 * @param string $callback_method_name
214
+	 * @param array  $args
215
+	 * @return mixed
216
+	 * @throws EE_Error
217
+	 */
218
+	public function __call($callback_method_name, $args)
219
+	{
220
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
221
+			// it's a dynamic callback for a method name
222
+			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
223
+			list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
224
+			// phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
225
+			$this->_ = $model_called;
226
+			// phpcs:enable
227
+			$extending_method = self::extending_method_prefix . $method_called_on_model;
228
+			if (method_exists($this, $extending_method)) {
229
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
230
+			} else {
231
+				throw new EE_Error(
232
+					sprintf(
233
+						__(
234
+							"An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
235
+							"event_espresso"
236
+						),
237
+						$this->_model_name_extended,
238
+						get_class($this),
239
+						$extending_method,
240
+						$extending_method
241
+					)
242
+				);
243
+			}
244
+		} else {
245
+			throw new EE_Error(
246
+				sprintf(
247
+					__("There is no method named '%s' on '%s'", "event_espresso"),
248
+					$callback_method_name,
249
+					get_class($this)
250
+				)
251
+			);
252
+		}
253
+	}
254 254
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function __construct()
73 73
     {
74
-        if (! $this->_model_name_extended) {
74
+        if ( ! $this->_model_name_extended) {
75 75
             throw new EE_Error(
76 76
                 __(
77 77
                     "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 )
80 80
             );
81 81
         }
82
-        $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
82
+        $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
83 83
         if (did_action($construct_end_action)) {
84 84
             throw new EE_Error(
85 85
                 sprintf(
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
             );
95 95
         }
96 96
         add_filter(
97
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
97
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',
98 98
             array($this, 'add_extra_tables_on_filter')
99 99
         );
100 100
         add_filter(
101
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
101
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',
102 102
             array($this, 'add_extra_fields_on_filter')
103 103
         );
104 104
         add_filter(
105
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
105
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',
106 106
             array($this, 'add_extra_relations_on_filter')
107 107
         );
108 108
         $this->_register_extending_methods();
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
     {
128 128
         if ($this->_extra_fields) {
129 129
             foreach ($this->_extra_fields as $table_alias => $fields) {
130
-                if (! isset($existing_fields[ $table_alias ])) {
131
-                    $existing_fields[ $table_alias ] = array();
130
+                if ( ! isset($existing_fields[$table_alias])) {
131
+                    $existing_fields[$table_alias] = array();
132 132
                 }
133
-                $existing_fields[ $table_alias ] = array_merge(
134
-                    (array) $existing_fields[ $table_alias ],
135
-                    $this->_extra_fields[ $table_alias ]
133
+                $existing_fields[$table_alias] = array_merge(
134
+                    (array) $existing_fields[$table_alias],
135
+                    $this->_extra_fields[$table_alias]
136 136
                 );
137 137
             }
138 138
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
                 $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
164 164
                 add_filter(
165 165
                     $callback_name,
166
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
166
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
167 167
                     10,
168 168
                     10
169 169
                 );
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
     public function deregister()
179 179
     {
180 180
         remove_filter(
181
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
181
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',
182 182
             array($this, 'add_extra_tables_on_filter')
183 183
         );
184 184
         remove_filter(
185
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
185
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',
186 186
             array($this, 'add_extra_fields_on_filter')
187 187
         );
188 188
         remove_filter(
189
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
189
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',
190 190
             array($this, 'add_extra_relations_on_filter')
191 191
         );
192 192
         $all_methods = get_class_methods(get_class($this));
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
                 $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
197 197
                 remove_filter(
198 198
                     $callback_name,
199
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
199
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
200 200
                     10
201 201
                 );
202 202
             }
203 203
         }
204 204
         /** @var EEM_Base $model_to_reset */
205
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
205
+        $model_to_reset = 'EEM_'.$this->_model_name_extended;
206 206
         if (class_exists($model_to_reset)) {
207 207
             $model_to_reset::reset();
208 208
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
225 225
             $this->_ = $model_called;
226 226
             // phpcs:enable
227
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
227
+            $extending_method = self::extending_method_prefix.$method_called_on_model;
228 228
             if (method_exists($this, $extending_method)) {
229 229
                 return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
230 230
             } else {
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Model.lib.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -11,183 +11,183 @@
 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 $model_id unique id for it
31
-     * @param array  $config {
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 EEM_{model_name}.
34
-     *       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 file should extend
43
-     *       EE_Base_Class
44
-     *
45
-     * }
46
-     * @throws EE_Error
47
-     */
48
-    public static function register($model_id = null, $config = array())
49
-    {
50
-        // required fields MUST be present, so let's make sure they are.
51
-        if (empty($model_id) || ! is_array($config) || empty($config['model_paths'])) {
52
-            throw new EE_Error(
53
-                __(
54
-                    '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)',
55
-                    'event_espresso'
56
-                )
57
-            );
58
-        }
29
+	/**
30
+	 * @param string $model_id unique id for it
31
+	 * @param array  $config {
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 EEM_{model_name}.
34
+	 *       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 file should extend
43
+	 *       EE_Base_Class
44
+	 *
45
+	 * }
46
+	 * @throws EE_Error
47
+	 */
48
+	public static function register($model_id = null, $config = array())
49
+	{
50
+		// required fields MUST be present, so let's make sure they are.
51
+		if (empty($model_id) || ! is_array($config) || empty($config['model_paths'])) {
52
+			throw new EE_Error(
53
+				__(
54
+					'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)',
55
+					'event_espresso'
56
+				)
57
+			);
58
+		}
59 59
 
60
-        // make sure we don't register twice
61
-        if (isset(self::$_model_registry[ $model_id ])) {
62
-            return;
63
-        }
60
+		// make sure we don't register twice
61
+		if (isset(self::$_model_registry[ $model_id ])) {
62
+			return;
63
+		}
64 64
 
65
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
66
-            || did_action('FHEE__EE_System__parse_model_names')
67
-            || did_action('FHEE__EE_System__parse_implemented_model_names')) {
68
-            EE_Error::doing_it_wrong(
69
-                __METHOD__,
70
-                sprintf(
71
-                    __(
72
-                        '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.',
73
-                        'event_espresso'
74
-                    ),
75
-                    $model_id
76
-                ),
77
-                '4.5'
78
-            );
79
-        }
80
-        self::$_model_registry[ $model_id ] = $config;
65
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
66
+			|| did_action('FHEE__EE_System__parse_model_names')
67
+			|| did_action('FHEE__EE_System__parse_implemented_model_names')) {
68
+			EE_Error::doing_it_wrong(
69
+				__METHOD__,
70
+				sprintf(
71
+					__(
72
+						'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.',
73
+						'event_espresso'
74
+					),
75
+					$model_id
76
+				),
77
+				'4.5'
78
+			);
79
+		}
80
+		self::$_model_registry[ $model_id ] = $config;
81 81
 
82
-        if ((isset($config['model_paths']) && ! isset($config['class_paths'])) ||
83
-            (! isset($config['model_paths']) && isset($config['class_paths']))) {
84
-            throw new EE_Error(
85
-                sprintf(
86
-                    __(
87
-                        'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
88
-                        'event_espresso'
89
-                    ),
90
-                    implode(", ", array_keys($config))
91
-                )
92
-            );
93
-        }
94
-        if (isset($config['model_paths'])) {
95
-            // make sure they passed in an array
96
-            if (! is_array($config['model_paths'])) {
97
-                $config['model_paths'] = array($config['model_paths']);
98
-            }
99
-            // we want to add this as a model folder
100
-            // and autoload them all
101
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_paths']);
102
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
103
-            $model_name_to_classname_map = array();
104
-            foreach (array_keys($class_to_filepath_map) as $classname) {
105
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
106
-            }
107
-            self::$_model_name_to_classname_map[ $model_id ] = $model_name_to_classname_map;
108
-            add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
109
-            add_filter(
110
-                'FHEE__EE_System__parse_implemented_model_names',
111
-                array('EE_Register_Model', 'add_addon_models')
112
-            );
113
-            add_filter('FHEE__EE_Registry__load_model__paths', array('EE_Register_Model', 'add_model_folders'));
114
-            unset($config['model_paths']);
115
-        }
116
-        if (isset($config['class_paths'])) {
117
-            // make sure they passed in an array
118
-            if (! is_array($config['class_paths'])) {
119
-                $config['class_paths'] = array($config['class_paths']);
120
-            }
121
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
122
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
123
-            add_filter('FHEE__EE_Registry__load_class__paths', array('EE_Register_Model', 'add_class_folders'));
124
-            unset($config['class_paths']);
125
-        }
126
-        foreach ($config as $unknown_key => $unknown_config) {
127
-            self::deregister($model_id);
128
-            throw new EE_Error(
129
-                sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
130
-            );
131
-        }
132
-    }
82
+		if ((isset($config['model_paths']) && ! isset($config['class_paths'])) ||
83
+			(! isset($config['model_paths']) && isset($config['class_paths']))) {
84
+			throw new EE_Error(
85
+				sprintf(
86
+					__(
87
+						'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
88
+						'event_espresso'
89
+					),
90
+					implode(", ", array_keys($config))
91
+				)
92
+			);
93
+		}
94
+		if (isset($config['model_paths'])) {
95
+			// make sure they passed in an array
96
+			if (! is_array($config['model_paths'])) {
97
+				$config['model_paths'] = array($config['model_paths']);
98
+			}
99
+			// we want to add this as a model folder
100
+			// and autoload them all
101
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_paths']);
102
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
103
+			$model_name_to_classname_map = array();
104
+			foreach (array_keys($class_to_filepath_map) as $classname) {
105
+				$model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
106
+			}
107
+			self::$_model_name_to_classname_map[ $model_id ] = $model_name_to_classname_map;
108
+			add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
109
+			add_filter(
110
+				'FHEE__EE_System__parse_implemented_model_names',
111
+				array('EE_Register_Model', 'add_addon_models')
112
+			);
113
+			add_filter('FHEE__EE_Registry__load_model__paths', array('EE_Register_Model', 'add_model_folders'));
114
+			unset($config['model_paths']);
115
+		}
116
+		if (isset($config['class_paths'])) {
117
+			// make sure they passed in an array
118
+			if (! is_array($config['class_paths'])) {
119
+				$config['class_paths'] = array($config['class_paths']);
120
+			}
121
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
122
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
123
+			add_filter('FHEE__EE_Registry__load_class__paths', array('EE_Register_Model', 'add_class_folders'));
124
+			unset($config['class_paths']);
125
+		}
126
+		foreach ($config as $unknown_key => $unknown_config) {
127
+			self::deregister($model_id);
128
+			throw new EE_Error(
129
+				sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
130
+			);
131
+		}
132
+	}
133 133
 
134
-    /**
135
-     * Filters the core list of models
136
-     *
137
-     * @param array $core_models
138
-     * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
139
-     */
140
-    public static function add_addon_models($core_models = array())
141
-    {
142
-        foreach (self::$_model_name_to_classname_map as $model_name_to_class_map) {
143
-            $core_models = array_merge($core_models, $model_name_to_class_map);
144
-        }
145
-        return $core_models;
146
-    }
134
+	/**
135
+	 * Filters the core list of models
136
+	 *
137
+	 * @param array $core_models
138
+	 * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
139
+	 */
140
+	public static function add_addon_models($core_models = array())
141
+	{
142
+		foreach (self::$_model_name_to_classname_map as $model_name_to_class_map) {
143
+			$core_models = array_merge($core_models, $model_name_to_class_map);
144
+		}
145
+		return $core_models;
146
+	}
147 147
 
148
-    /**
149
-     * Filters the list of model folders
150
-     *
151
-     * @param array $folders
152
-     * @return array of folder paths
153
-     */
154
-    public static function add_model_folders($folders = array())
155
-    {
156
-        foreach (self::$_model_registry as $config) {
157
-            if (isset($config['model_paths'])) {
158
-                $folders = array_merge($folders, $config['model_paths']);
159
-            }
160
-        }
161
-        return $folders;
162
-    }
148
+	/**
149
+	 * Filters the list of model folders
150
+	 *
151
+	 * @param array $folders
152
+	 * @return array of folder paths
153
+	 */
154
+	public static function add_model_folders($folders = array())
155
+	{
156
+		foreach (self::$_model_registry as $config) {
157
+			if (isset($config['model_paths'])) {
158
+				$folders = array_merge($folders, $config['model_paths']);
159
+			}
160
+		}
161
+		return $folders;
162
+	}
163 163
 
164
-    /**
165
-     * Filters the array of model class paths
166
-     *
167
-     * @param array $folders
168
-     * @return array of folder paths
169
-     */
170
-    public static function add_class_folders($folders = array())
171
-    {
172
-        foreach (self::$_model_registry as $config) {
173
-            if (isset($config['class_paths'])) {
174
-                $folders = array_merge($folders, $config['class_paths']);
175
-            }
176
-        }
177
-        return $folders;
178
-    }
164
+	/**
165
+	 * Filters the array of model class paths
166
+	 *
167
+	 * @param array $folders
168
+	 * @return array of folder paths
169
+	 */
170
+	public static function add_class_folders($folders = array())
171
+	{
172
+		foreach (self::$_model_registry as $config) {
173
+			if (isset($config['class_paths'])) {
174
+				$folders = array_merge($folders, $config['class_paths']);
175
+			}
176
+		}
177
+		return $folders;
178
+	}
179 179
 
180 180
 
181
-    /**
182
-     * deregister
183
-     *
184
-     * @param string $model_id
185
-     */
186
-    public static function deregister($model_id = null)
187
-    {
188
-        if (isset(self::$_model_registry[ $model_id ])) {
189
-            unset(self::$_model_registry[ $model_id ]);
190
-            unset(self::$_model_name_to_classname_map[ $model_id ]);
191
-        }
192
-    }
181
+	/**
182
+	 * deregister
183
+	 *
184
+	 * @param string $model_id
185
+	 */
186
+	public static function deregister($model_id = null)
187
+	{
188
+		if (isset(self::$_model_registry[ $model_id ])) {
189
+			unset(self::$_model_registry[ $model_id ]);
190
+			unset(self::$_model_name_to_classname_map[ $model_id ]);
191
+		}
192
+	}
193 193
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
         }
59 59
 
60 60
         // make sure we don't register twice
61
-        if (isset(self::$_model_registry[ $model_id ])) {
61
+        if (isset(self::$_model_registry[$model_id])) {
62 62
             return;
63 63
         }
64 64
 
65
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
65
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
66 66
             || did_action('FHEE__EE_System__parse_model_names')
67 67
             || did_action('FHEE__EE_System__parse_implemented_model_names')) {
68 68
             EE_Error::doing_it_wrong(
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
                 '4.5'
78 78
             );
79 79
         }
80
-        self::$_model_registry[ $model_id ] = $config;
80
+        self::$_model_registry[$model_id] = $config;
81 81
 
82 82
         if ((isset($config['model_paths']) && ! isset($config['class_paths'])) ||
83
-            (! isset($config['model_paths']) && isset($config['class_paths']))) {
83
+            ( ! isset($config['model_paths']) && isset($config['class_paths']))) {
84 84
             throw new EE_Error(
85 85
                 sprintf(
86 86
                     __(
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         }
94 94
         if (isset($config['model_paths'])) {
95 95
             // make sure they passed in an array
96
-            if (! is_array($config['model_paths'])) {
96
+            if ( ! is_array($config['model_paths'])) {
97 97
                 $config['model_paths'] = array($config['model_paths']);
98 98
             }
99 99
             // we want to add this as a model folder
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
103 103
             $model_name_to_classname_map = array();
104 104
             foreach (array_keys($class_to_filepath_map) as $classname) {
105
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
105
+                $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
106 106
             }
107
-            self::$_model_name_to_classname_map[ $model_id ] = $model_name_to_classname_map;
107
+            self::$_model_name_to_classname_map[$model_id] = $model_name_to_classname_map;
108 108
             add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
109 109
             add_filter(
110 110
                 'FHEE__EE_System__parse_implemented_model_names',
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         }
116 116
         if (isset($config['class_paths'])) {
117 117
             // make sure they passed in an array
118
-            if (! is_array($config['class_paths'])) {
118
+            if ( ! is_array($config['class_paths'])) {
119 119
                 $config['class_paths'] = array($config['class_paths']);
120 120
             }
121 121
             $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public static function deregister($model_id = null)
187 187
     {
188
-        if (isset(self::$_model_registry[ $model_id ])) {
189
-            unset(self::$_model_registry[ $model_id ]);
190
-            unset(self::$_model_name_to_classname_map[ $model_id ]);
188
+        if (isset(self::$_model_registry[$model_id])) {
189
+            unset(self::$_model_registry[$model_id]);
190
+            unset(self::$_model_name_to_classname_map[$model_id]);
191 191
         }
192 192
     }
193 193
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Admin_Page.lib.php 2 patches
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,139 +12,139 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Holds registered EE_Admin_Pages
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_ee_admin_page_registry = array();
21
-
22
-
23
-    /**
24
-     * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE
25
-     * Admin Page loader system).
26
-     *
27
-     * @since 4.3.0
28
-     *
29
-     * @param  string $page_basename This string represents the basename of the Admin Page init.
30
-     *                                                                The init file must use this basename in its name
31
-     *                                                                and class (i.e.
32
-     *                                                                {page_basename}_Admin_Page_Init.core.php).
33
-     * @param  array  $config {              An array of configuration options that will be used in different
34
-     *                        circumstances
35
-     *
36
-     * @type  string  $page_path This is the path where the registered admin pages reside ( used to setup autoloaders).
37
-     *
38
-     *    }
39
-     * @return void
40
-     */
41
-    public static function register($page_basename = null, $config = array())
42
-    {
43
-
44
-        // check that an admin_page has not already been registered with that name
45
-        if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
46
-            throw new EE_Error(
47
-                sprintf(
48
-                    __(
49
-                        'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.',
50
-                        'event_espresso'
51
-                    ),
52
-                    $page_basename
53
-                )
54
-            );
55
-        }
56
-
57
-        // required fields MUST be present, so let's make sure they are.
58
-        if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) {
59
-            throw new EE_Error(
60
-                __(
61
-                    'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)',
62
-                    'event_espresso'
63
-                )
64
-            );
65
-        }
66
-
67
-        // make sure we don't register twice
68
-        if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
69
-            return;
70
-        }
71
-
72
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
73
-            EE_Error::doing_it_wrong(
74
-                __METHOD__,
75
-                sprintf(
76
-                    __(
77
-                        'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.',
78
-                        'event_espresso'
79
-                    ),
80
-                    $page_basename
81
-                ),
82
-                '4.3'
83
-            );
84
-        }
85
-
86
-        // add incoming stuff to our registry property
87
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
88
-            'page_path' => $config['page_path'],
89
-            'config'    => $config,
90
-        );
91
-
92
-        // add filters
93
-
94
-        add_filter(
95
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
96
-            array('EE_Register_Admin_Page', 'set_page_basename'),
97
-            10
98
-        );
99
-        add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10);
100
-    }
101
-
102
-
103
-    /**
104
-     * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
105
-     * page being deregistered is loaded.
106
-     *
107
-     * @since    4.3.0
108
-     *
109
-     * @param  string $page_basename Use whatever string was used to register the admin page.
110
-     * @return  void
111
-     */
112
-    public static function deregister($page_basename = null)
113
-    {
114
-        if (! empty(self::$_ee_admin_page_registry[ $page_basename ])) {
115
-            unset(self::$_ee_admin_page_registry[ $page_basename ]);
116
-        }
117
-    }
118
-
119
-
120
-    /**
121
-     * set_page_basename
122
-     *
123
-     * @param $installed_refs
124
-     * @return mixed
125
-     */
126
-    public static function set_page_basename($installed_refs)
127
-    {
128
-        if (! empty(self::$_ee_admin_page_registry)) {
129
-            foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
-                $installed_refs[ $basename ] = $args['page_path'];
131
-            }
132
-        }
133
-        return $installed_refs;
134
-    }
135
-
136
-
137
-    /**
138
-     * set_page_path
139
-     *
140
-     * @param $paths
141
-     * @return mixed
142
-     */
143
-    public static function set_page_path($paths)
144
-    {
145
-        foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
-            $paths[ $basename ] = $args['page_path'];
147
-        }
148
-        return $paths;
149
-    }
15
+	/**
16
+	 * Holds registered EE_Admin_Pages
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_ee_admin_page_registry = array();
21
+
22
+
23
+	/**
24
+	 * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE
25
+	 * Admin Page loader system).
26
+	 *
27
+	 * @since 4.3.0
28
+	 *
29
+	 * @param  string $page_basename This string represents the basename of the Admin Page init.
30
+	 *                                                                The init file must use this basename in its name
31
+	 *                                                                and class (i.e.
32
+	 *                                                                {page_basename}_Admin_Page_Init.core.php).
33
+	 * @param  array  $config {              An array of configuration options that will be used in different
34
+	 *                        circumstances
35
+	 *
36
+	 * @type  string  $page_path This is the path where the registered admin pages reside ( used to setup autoloaders).
37
+	 *
38
+	 *    }
39
+	 * @return void
40
+	 */
41
+	public static function register($page_basename = null, $config = array())
42
+	{
43
+
44
+		// check that an admin_page has not already been registered with that name
45
+		if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
46
+			throw new EE_Error(
47
+				sprintf(
48
+					__(
49
+						'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.',
50
+						'event_espresso'
51
+					),
52
+					$page_basename
53
+				)
54
+			);
55
+		}
56
+
57
+		// required fields MUST be present, so let's make sure they are.
58
+		if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) {
59
+			throw new EE_Error(
60
+				__(
61
+					'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)',
62
+					'event_espresso'
63
+				)
64
+			);
65
+		}
66
+
67
+		// make sure we don't register twice
68
+		if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
69
+			return;
70
+		}
71
+
72
+		if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
73
+			EE_Error::doing_it_wrong(
74
+				__METHOD__,
75
+				sprintf(
76
+					__(
77
+						'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.',
78
+						'event_espresso'
79
+					),
80
+					$page_basename
81
+				),
82
+				'4.3'
83
+			);
84
+		}
85
+
86
+		// add incoming stuff to our registry property
87
+		self::$_ee_admin_page_registry[ $page_basename ] = array(
88
+			'page_path' => $config['page_path'],
89
+			'config'    => $config,
90
+		);
91
+
92
+		// add filters
93
+
94
+		add_filter(
95
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
96
+			array('EE_Register_Admin_Page', 'set_page_basename'),
97
+			10
98
+		);
99
+		add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10);
100
+	}
101
+
102
+
103
+	/**
104
+	 * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
105
+	 * page being deregistered is loaded.
106
+	 *
107
+	 * @since    4.3.0
108
+	 *
109
+	 * @param  string $page_basename Use whatever string was used to register the admin page.
110
+	 * @return  void
111
+	 */
112
+	public static function deregister($page_basename = null)
113
+	{
114
+		if (! empty(self::$_ee_admin_page_registry[ $page_basename ])) {
115
+			unset(self::$_ee_admin_page_registry[ $page_basename ]);
116
+		}
117
+	}
118
+
119
+
120
+	/**
121
+	 * set_page_basename
122
+	 *
123
+	 * @param $installed_refs
124
+	 * @return mixed
125
+	 */
126
+	public static function set_page_basename($installed_refs)
127
+	{
128
+		if (! empty(self::$_ee_admin_page_registry)) {
129
+			foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
+				$installed_refs[ $basename ] = $args['page_path'];
131
+			}
132
+		}
133
+		return $installed_refs;
134
+	}
135
+
136
+
137
+	/**
138
+	 * set_page_path
139
+	 *
140
+	 * @param $paths
141
+	 * @return mixed
142
+	 */
143
+	public static function set_page_path($paths)
144
+	{
145
+		foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
+			$paths[ $basename ] = $args['page_path'];
147
+		}
148
+		return $paths;
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     {
43 43
 
44 44
         // check that an admin_page has not already been registered with that name
45
-        if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
45
+        if (isset(self::$_ee_admin_page_registry[$page_basename])) {
46 46
             throw new EE_Error(
47 47
                 sprintf(
48 48
                     __(
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         // make sure we don't register twice
68
-        if (isset(self::$_ee_admin_page_registry[ $page_basename ])) {
68
+        if (isset(self::$_ee_admin_page_registry[$page_basename])) {
69 69
             return;
70 70
         }
71 71
 
72
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
72
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
73 73
             EE_Error::doing_it_wrong(
74 74
                 __METHOD__,
75 75
                 sprintf(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         }
85 85
 
86 86
         // add incoming stuff to our registry property
87
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
87
+        self::$_ee_admin_page_registry[$page_basename] = array(
88 88
             'page_path' => $config['page_path'],
89 89
             'config'    => $config,
90 90
         );
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public static function deregister($page_basename = null)
113 113
     {
114
-        if (! empty(self::$_ee_admin_page_registry[ $page_basename ])) {
115
-            unset(self::$_ee_admin_page_registry[ $page_basename ]);
114
+        if ( ! empty(self::$_ee_admin_page_registry[$page_basename])) {
115
+            unset(self::$_ee_admin_page_registry[$page_basename]);
116 116
         }
117 117
     }
118 118
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public static function set_page_basename($installed_refs)
127 127
     {
128
-        if (! empty(self::$_ee_admin_page_registry)) {
128
+        if ( ! empty(self::$_ee_admin_page_registry)) {
129 129
             foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
-                $installed_refs[ $basename ] = $args['page_path'];
130
+                $installed_refs[$basename] = $args['page_path'];
131 131
             }
132 132
         }
133 133
         return $installed_refs;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     public static function set_page_path($paths)
144 144
     {
145 145
         foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
-            $paths[ $basename ] = $args['page_path'];
146
+            $paths[$basename] = $args['page_path'];
147 147
         }
148 148
         return $paths;
149 149
     }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EEI_Plugin_API.lib.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@
 block discarded – undo
20 20
 interface EEI_Plugin_API
21 21
 {
22 22
 
23
-    /**
24
-     * Used to register a component with EE.
25
-     *
26
-     * @since    4.3.0
27
-     * @param string $ID         a unique name or ID for the component being registered
28
-     * @param array  $setup_args an array of key value pairs of info for registering the component
29
-     * @return void
30
-     */
31
-    public static function register($ID = null, $setup_args = array());
23
+	/**
24
+	 * Used to register a component with EE.
25
+	 *
26
+	 * @since    4.3.0
27
+	 * @param string $ID         a unique name or ID for the component being registered
28
+	 * @param array  $setup_args an array of key value pairs of info for registering the component
29
+	 * @return void
30
+	 */
31
+	public static function register($ID = null, $setup_args = array());
32 32
 
33 33
 
34
-    /**
35
-     * Used to deregister a component with EE.
36
-     *
37
-     * @since 4.3.0
38
-     * @param string $ID a unique name or ID for the component being registered
39
-     * @return void
40
-     */
41
-    public static function deregister($ID = null);
34
+	/**
35
+	 * Used to deregister a component with EE.
36
+	 *
37
+	 * @since 4.3.0
38
+	 * @param string $ID a unique name or ID for the component being registered
39
+	 * @return void
40
+	 */
41
+	public static function deregister($ID = null);
42 42
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Shortcode_Library.lib.php 2 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -12,186 +12,186 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * holds values for registered messages shortcode libraries
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_ee_messages_shortcode_registry = array();
21
-
22
-
23
-    /**
24
-     * Helper method for registring a new shortcodes library class for the messages system.
25
-     *
26
-     * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
27
-     * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
28
-     *
29
-     * @since    4.3.0
30
-     *
31
-     * @param  array $setup_args                    {
32
-     *                                              An array of arguments provided for registering the new messages
33
-     *                                              shortcode library.
34
-     *
35
-     * @type string  $name                          What is the name of this shortcode library
36
-     *                                                                              (e.g. 'question_list');
37
-     * @type array   $autoloadpaths                 An array of paths to add to the messages
38
-     *                                                                              autoloader for the new shortcode
39
-     *                                                                              library class file.
40
-     * @type string  $msgr_validator_callback       Callback for a method that will register the
41
-     *                                                                              library with the messenger
42
-     *                                                                              _validator_config. Optional.
43
-     * @type string  $msgr_template_fields_callback Callback for changing adding the
44
-     *                                                                              _template_fields property for
45
-     *                                                                              messenger. For example, the
46
-     *                                                                              shortcode library may add a new
47
-     *                                                                              field to the message templates.
48
-     *                                                                              Optional.
49
-     * @type string  $valid_shortcodes_callback     Callback for message types
50
-     *                                                                              _valid_shortcodes array setup.
51
-     *                                                                              Optional.
52
-     * @type array   $list_type_shortcodes          If there are any specific shortcodes with this
53
-     *                                                                             message shortcode library that
54
-     *                                                                             should be considered "list type"
55
-     *                                                                             then include them in an array.  List
56
-     *                                                                             Type shortcodes are shortcodes that
57
-     *                                                                             have a corresponding field that
58
-     *                                                                             indicates how they are parsed.
59
-     *                                                                             Optional.
60
-     * }
61
-     * @return void
62
-     */
63
-    public static function register($name = null, $setup_args = array())
64
-    {
65
-
66
-        // required fields MUST be present, so let's make sure they are.
67
-        if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
68
-            throw new EE_Error(
69
-                __(
70
-                    'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
71
-                    'event_espresso'
72
-                )
73
-            );
74
-        }
75
-
76
-        // make sure we don't register twice
77
-        if (isset(self::$_ee_messages_shortcode_registry[ $name ])) {
78
-            return;
79
-        }
80
-
81
-        // make sure this was called in the right place!
82
-        if (! did_action('EE_Brewing_Regular___messages_caf')
83
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
84
-        ) {
85
-            EE_Error::doing_it_wrong(
86
-                __METHOD__,
87
-                sprintf(
88
-                    __(
89
-                        'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
90
-                        'event_espresso'
91
-                    ),
92
-                    $name
93
-                ),
94
-                '4.3.0'
95
-            );
96
-        }
97
-
98
-        $name = (string) $name;
99
-        self::$_ee_messages_shortcode_registry[ $name ] = array(
100
-            'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
101
-            'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
102
-                ? (array) $setup_args['list_type_shortcodes'] : array(),
103
-        );
104
-
105
-        // add filters
106
-        add_filter(
107
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
108
-            array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'),
109
-            10
110
-        );
111
-
112
-        // add below filters if the required callback is provided.
113
-        if (! empty($setup_args['msgr_validator_callback'])) {
114
-            add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
115
-        }
116
-
117
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
118
-            add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
119
-        }
120
-
121
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
122
-            add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
123
-        }
124
-
125
-        if (! empty($setup_args['list_type_shortcodes'])) {
126
-            add_filter(
127
-                'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
128
-                array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'),
129
-                10
130
-            );
131
-        }
132
-    }
133
-
134
-
135
-    /**
136
-     * This deregisters any messages shortcode library previously registered with the given name.
137
-     *
138
-     * @since    4.3.0
139
-     * @param  string $name name used to register the shortcode library.
140
-     * @return  void
141
-     */
142
-    public static function deregister($name = null)
143
-    {
144
-        if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) {
145
-            unset(self::$_ee_messages_shortcode_registry[ $name ]);
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
152
-     *
153
-     * @since    4.3.0
154
-     *
155
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
156
-     * @return array
157
-     */
158
-    public static function register_msgs_autoload_paths($paths)
159
-    {
160
-
161
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
162
-            foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
163
-                if (empty($st_reg['autoloadpaths'])) {
164
-                    continue;
165
-                }
166
-                $paths = array_merge($paths, $st_reg['autoloadpaths']);
167
-            }
168
-        }
169
-
170
-        return $paths;
171
-    }
172
-
173
-
174
-    /**
175
-     * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
176
-     * filter which is used to add additional list type shortcodes.
177
-     *
178
-     * @since 4.3.0
179
-     *
180
-     * @param  array $original_shortcodes
181
-     * @return  array                                   Modifications to original shortcodes.
182
-     */
183
-    public static function register_list_type_shortcodes($original_shortcodes)
184
-    {
185
-        if (empty(self::$_ee_messages_shortcode_registry)) {
186
-            return $original_shortcodes;
187
-        }
188
-
189
-        foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
190
-            if (! empty($sc_reg['list_type_shortcodes'])) {
191
-                $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
192
-            }
193
-        }
194
-
195
-        return $original_shortcodes;
196
-    }
15
+	/**
16
+	 * holds values for registered messages shortcode libraries
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_ee_messages_shortcode_registry = array();
21
+
22
+
23
+	/**
24
+	 * Helper method for registring a new shortcodes library class for the messages system.
25
+	 *
26
+	 * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
27
+	 * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
28
+	 *
29
+	 * @since    4.3.0
30
+	 *
31
+	 * @param  array $setup_args                    {
32
+	 *                                              An array of arguments provided for registering the new messages
33
+	 *                                              shortcode library.
34
+	 *
35
+	 * @type string  $name                          What is the name of this shortcode library
36
+	 *                                                                              (e.g. 'question_list');
37
+	 * @type array   $autoloadpaths                 An array of paths to add to the messages
38
+	 *                                                                              autoloader for the new shortcode
39
+	 *                                                                              library class file.
40
+	 * @type string  $msgr_validator_callback       Callback for a method that will register the
41
+	 *                                                                              library with the messenger
42
+	 *                                                                              _validator_config. Optional.
43
+	 * @type string  $msgr_template_fields_callback Callback for changing adding the
44
+	 *                                                                              _template_fields property for
45
+	 *                                                                              messenger. For example, the
46
+	 *                                                                              shortcode library may add a new
47
+	 *                                                                              field to the message templates.
48
+	 *                                                                              Optional.
49
+	 * @type string  $valid_shortcodes_callback     Callback for message types
50
+	 *                                                                              _valid_shortcodes array setup.
51
+	 *                                                                              Optional.
52
+	 * @type array   $list_type_shortcodes          If there are any specific shortcodes with this
53
+	 *                                                                             message shortcode library that
54
+	 *                                                                             should be considered "list type"
55
+	 *                                                                             then include them in an array.  List
56
+	 *                                                                             Type shortcodes are shortcodes that
57
+	 *                                                                             have a corresponding field that
58
+	 *                                                                             indicates how they are parsed.
59
+	 *                                                                             Optional.
60
+	 * }
61
+	 * @return void
62
+	 */
63
+	public static function register($name = null, $setup_args = array())
64
+	{
65
+
66
+		// required fields MUST be present, so let's make sure they are.
67
+		if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
68
+			throw new EE_Error(
69
+				__(
70
+					'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
71
+					'event_espresso'
72
+				)
73
+			);
74
+		}
75
+
76
+		// make sure we don't register twice
77
+		if (isset(self::$_ee_messages_shortcode_registry[ $name ])) {
78
+			return;
79
+		}
80
+
81
+		// make sure this was called in the right place!
82
+		if (! did_action('EE_Brewing_Regular___messages_caf')
83
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
84
+		) {
85
+			EE_Error::doing_it_wrong(
86
+				__METHOD__,
87
+				sprintf(
88
+					__(
89
+						'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
90
+						'event_espresso'
91
+					),
92
+					$name
93
+				),
94
+				'4.3.0'
95
+			);
96
+		}
97
+
98
+		$name = (string) $name;
99
+		self::$_ee_messages_shortcode_registry[ $name ] = array(
100
+			'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
101
+			'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
102
+				? (array) $setup_args['list_type_shortcodes'] : array(),
103
+		);
104
+
105
+		// add filters
106
+		add_filter(
107
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
108
+			array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'),
109
+			10
110
+		);
111
+
112
+		// add below filters if the required callback is provided.
113
+		if (! empty($setup_args['msgr_validator_callback'])) {
114
+			add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
115
+		}
116
+
117
+		if (! empty($setup_args['msgr_template_fields_callback'])) {
118
+			add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
119
+		}
120
+
121
+		if (! empty($setup_args['valid_shortcodes_callback'])) {
122
+			add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
123
+		}
124
+
125
+		if (! empty($setup_args['list_type_shortcodes'])) {
126
+			add_filter(
127
+				'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
128
+				array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'),
129
+				10
130
+			);
131
+		}
132
+	}
133
+
134
+
135
+	/**
136
+	 * This deregisters any messages shortcode library previously registered with the given name.
137
+	 *
138
+	 * @since    4.3.0
139
+	 * @param  string $name name used to register the shortcode library.
140
+	 * @return  void
141
+	 */
142
+	public static function deregister($name = null)
143
+	{
144
+		if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) {
145
+			unset(self::$_ee_messages_shortcode_registry[ $name ]);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
152
+	 *
153
+	 * @since    4.3.0
154
+	 *
155
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
156
+	 * @return array
157
+	 */
158
+	public static function register_msgs_autoload_paths($paths)
159
+	{
160
+
161
+		if (! empty(self::$_ee_messages_shortcode_registry)) {
162
+			foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
163
+				if (empty($st_reg['autoloadpaths'])) {
164
+					continue;
165
+				}
166
+				$paths = array_merge($paths, $st_reg['autoloadpaths']);
167
+			}
168
+		}
169
+
170
+		return $paths;
171
+	}
172
+
173
+
174
+	/**
175
+	 * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
176
+	 * filter which is used to add additional list type shortcodes.
177
+	 *
178
+	 * @since 4.3.0
179
+	 *
180
+	 * @param  array $original_shortcodes
181
+	 * @return  array                                   Modifications to original shortcodes.
182
+	 */
183
+	public static function register_list_type_shortcodes($original_shortcodes)
184
+	{
185
+		if (empty(self::$_ee_messages_shortcode_registry)) {
186
+			return $original_shortcodes;
187
+		}
188
+
189
+		foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
190
+			if (! empty($sc_reg['list_type_shortcodes'])) {
191
+				$original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
192
+			}
193
+		}
194
+
195
+		return $original_shortcodes;
196
+	}
197 197
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
         }
75 75
 
76 76
         // make sure we don't register twice
77
-        if (isset(self::$_ee_messages_shortcode_registry[ $name ])) {
77
+        if (isset(self::$_ee_messages_shortcode_registry[$name])) {
78 78
             return;
79 79
         }
80 80
 
81 81
         // make sure this was called in the right place!
82
-        if (! did_action('EE_Brewing_Regular___messages_caf')
82
+        if ( ! did_action('EE_Brewing_Regular___messages_caf')
83 83
             || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
84 84
         ) {
85 85
             EE_Error::doing_it_wrong(
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         }
97 97
 
98 98
         $name = (string) $name;
99
-        self::$_ee_messages_shortcode_registry[ $name ] = array(
99
+        self::$_ee_messages_shortcode_registry[$name] = array(
100 100
             'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
101 101
             'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
102 102
                 ? (array) $setup_args['list_type_shortcodes'] : array(),
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
         );
111 111
 
112 112
         // add below filters if the required callback is provided.
113
-        if (! empty($setup_args['msgr_validator_callback'])) {
113
+        if ( ! empty($setup_args['msgr_validator_callback'])) {
114 114
             add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
115 115
         }
116 116
 
117
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
117
+        if ( ! empty($setup_args['msgr_template_fields_callback'])) {
118 118
             add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
119 119
         }
120 120
 
121
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
121
+        if ( ! empty($setup_args['valid_shortcodes_callback'])) {
122 122
             add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
123 123
         }
124 124
 
125
-        if (! empty($setup_args['list_type_shortcodes'])) {
125
+        if ( ! empty($setup_args['list_type_shortcodes'])) {
126 126
             add_filter(
127 127
                 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
128 128
                 array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'),
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public static function deregister($name = null)
143 143
     {
144
-        if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) {
145
-            unset(self::$_ee_messages_shortcode_registry[ $name ]);
144
+        if ( ! empty(self::$_ee_messages_shortcode_registry[$name])) {
145
+            unset(self::$_ee_messages_shortcode_registry[$name]);
146 146
         }
147 147
     }
148 148
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     public static function register_msgs_autoload_paths($paths)
159 159
     {
160 160
 
161
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
161
+        if ( ! empty(self::$_ee_messages_shortcode_registry)) {
162 162
             foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
163 163
                 if (empty($st_reg['autoloadpaths'])) {
164 164
                     continue;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         }
188 188
 
189 189
         foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
190
-            if (! empty($sc_reg['list_type_shortcodes'])) {
190
+            if ( ! empty($sc_reg['list_type_shortcodes'])) {
191 191
                 $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
192 192
             }
193 193
         }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Widget.lib.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -14,99 +14,99 @@
 block discarded – undo
14 14
 class EE_Register_Widget implements EEI_Plugin_API
15 15
 {
16 16
 
17
-    /**
18
-     * Holds values for registered widgets
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_settings = array();
17
+	/**
18
+	 * Holds values for registered widgets
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_settings = array();
23 23
 
24 24
 
25
-    /**
26
-     *    Method for registering new EED_Widgets
27
-     *
28
-     * @since    4.3.0
29
-     * @param string $widget_id a unique identifier for this set of widgets
30
-     * @param  array $setup_args an array of arguments provided for registering widgets
31
-     * @type array widget_paths        an array of full server paths to folders containing any EED_Widgets, or to the
32
-     *       EED_Widget files themselves
33
-     * @throws EE_Error
34
-     * @return void
35
-     */
36
-    public static function register($widget_id = null, $setup_args = array())
37
-    {
25
+	/**
26
+	 *    Method for registering new EED_Widgets
27
+	 *
28
+	 * @since    4.3.0
29
+	 * @param string $widget_id a unique identifier for this set of widgets
30
+	 * @param  array $setup_args an array of arguments provided for registering widgets
31
+	 * @type array widget_paths        an array of full server paths to folders containing any EED_Widgets, or to the
32
+	 *       EED_Widget files themselves
33
+	 * @throws EE_Error
34
+	 * @return void
35
+	 */
36
+	public static function register($widget_id = null, $setup_args = array())
37
+	{
38 38
 
39
-        // required fields MUST be present, so let's make sure they are.
40
-        if (empty($widget_id) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) {
41
-            throw new EE_Error(
42
-                __(
43
-                    'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)',
44
-                    'event_espresso'
45
-                )
46
-            );
47
-        }
39
+		// required fields MUST be present, so let's make sure they are.
40
+		if (empty($widget_id) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) {
41
+			throw new EE_Error(
42
+				__(
43
+					'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)',
44
+					'event_espresso'
45
+				)
46
+			);
47
+		}
48 48
 
49
-        // make sure we don't register twice
50
-        if (isset(self::$_settings[ $widget_id ])) {
51
-            return;
52
-        }
49
+		// make sure we don't register twice
50
+		if (isset(self::$_settings[ $widget_id ])) {
51
+			return;
52
+		}
53 53
 
54 54
 
55
-        // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
57
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
-        ) {
59
-            EE_Error::doing_it_wrong(
60
-                __METHOD__,
61
-                __(
62
-                    'An attempt to register widgets 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 widgets.',
63
-                    'event_espresso'
64
-                ),
65
-                '4.3.0'
66
-            );
67
-        }
68
-        // setup $_settings array from incoming values.
69
-        self::$_settings[ $widget_id ] = array(
70
-            // array of full server paths to any EED_Widgets used by the widget
71
-            'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(),
72
-        );
73
-        // add to list of widgets to be registered
74
-        add_filter(
75
-            'FHEE__EE_Config__register_widgets__widgets_to_register',
76
-            array('EE_Register_Widget', 'add_widgets')
77
-        );
78
-    }
55
+		// make sure this was called in the right place!
56
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
57
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
+		) {
59
+			EE_Error::doing_it_wrong(
60
+				__METHOD__,
61
+				__(
62
+					'An attempt to register widgets 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 widgets.',
63
+					'event_espresso'
64
+				),
65
+				'4.3.0'
66
+			);
67
+		}
68
+		// setup $_settings array from incoming values.
69
+		self::$_settings[ $widget_id ] = array(
70
+			// array of full server paths to any EED_Widgets used by the widget
71
+			'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(),
72
+		);
73
+		// add to list of widgets to be registered
74
+		add_filter(
75
+			'FHEE__EE_Config__register_widgets__widgets_to_register',
76
+			array('EE_Register_Widget', 'add_widgets')
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Filters the list of widgets to add ours.
83
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
84
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey',...)
85
-     *
86
-     * @param array $widgets_to_register array of paths to all widgets that require registering
87
-     * @return array
88
-     */
89
-    public static function add_widgets($widgets_to_register = array())
90
-    {
91
-        foreach (self::$_settings as $settings) {
92
-            $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']);
93
-        }
94
-        return $widgets_to_register;
95
-    }
81
+	/**
82
+	 * Filters the list of widgets to add ours.
83
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
84
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey',...)
85
+	 *
86
+	 * @param array $widgets_to_register array of paths to all widgets that require registering
87
+	 * @return array
88
+	 */
89
+	public static function add_widgets($widgets_to_register = array())
90
+	{
91
+		foreach (self::$_settings as $settings) {
92
+			$widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']);
93
+		}
94
+		return $widgets_to_register;
95
+	}
96 96
 
97 97
 
98
-    /**
99
-     * This deregisters a widget that was previously registered with a specific $widget_id.
100
-     *
101
-     * @since    4.3.0
102
-     *
103
-     * @param string $widget_id the name for the widget that was previously registered
104
-     * @return void
105
-     */
106
-    public static function deregister($widget_id = null)
107
-    {
108
-        if (isset(self::$_settings[ $widget_id ])) {
109
-            unset(self::$_settings[ $widget_id ]);
110
-        }
111
-    }
98
+	/**
99
+	 * This deregisters a widget that was previously registered with a specific $widget_id.
100
+	 *
101
+	 * @since    4.3.0
102
+	 *
103
+	 * @param string $widget_id the name for the widget that was previously registered
104
+	 * @return void
105
+	 */
106
+	public static function deregister($widget_id = null)
107
+	{
108
+		if (isset(self::$_settings[ $widget_id ])) {
109
+			unset(self::$_settings[ $widget_id ]);
110
+		}
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
         }
48 48
 
49 49
         // make sure we don't register twice
50
-        if (isset(self::$_settings[ $widget_id ])) {
50
+        if (isset(self::$_settings[$widget_id])) {
51 51
             return;
52 52
         }
53 53
 
54 54
 
55 55
         // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
56
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
57 57
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58 58
         ) {
59 59
             EE_Error::doing_it_wrong(
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             );
67 67
         }
68 68
         // setup $_settings array from incoming values.
69
-        self::$_settings[ $widget_id ] = array(
69
+        self::$_settings[$widget_id] = array(
70 70
             // array of full server paths to any EED_Widgets used by the widget
71 71
             'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(),
72 72
         );
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function deregister($widget_id = null)
107 107
     {
108
-        if (isset(self::$_settings[ $widget_id ])) {
109
-            unset(self::$_settings[ $widget_id ]);
108
+        if (isset(self::$_settings[$widget_id])) {
109
+            unset(self::$_settings[$widget_id]);
110 110
         }
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Module.lib.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -14,99 +14,99 @@
 block discarded – undo
14 14
 class EE_Register_Module implements EEI_Plugin_API
15 15
 {
16 16
 
17
-    /**
18
-     * Holds values for registered modules
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_settings = array();
17
+	/**
18
+	 * Holds values for registered modules
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_settings = array();
23 23
 
24 24
 
25
-    /**
26
-     *    Method for registering new EED_Modules
27
-     *
28
-     * @since    4.3.0
29
-     * @param string $module_id a unique identifier for this set of modules Required.
30
-     * @param  array $setup_args an array of full server paths to folders containing any EED_Modules, or to the
31
-     *                           EED_Module files themselves Required.
32
-     * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
33
-     *          EED_Module files themselves
34
-     * @throws EE_Error
35
-     * @return void
36
-     */
37
-    public static function register($module_id = null, $setup_args = array())
38
-    {
25
+	/**
26
+	 *    Method for registering new EED_Modules
27
+	 *
28
+	 * @since    4.3.0
29
+	 * @param string $module_id a unique identifier for this set of modules Required.
30
+	 * @param  array $setup_args an array of full server paths to folders containing any EED_Modules, or to the
31
+	 *                           EED_Module files themselves Required.
32
+	 * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
33
+	 *          EED_Module files themselves
34
+	 * @throws EE_Error
35
+	 * @return void
36
+	 */
37
+	public static function register($module_id = null, $setup_args = array())
38
+	{
39 39
 
40
-        // required fields MUST be present, so let's make sure they are.
41
-        if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
42
-            throw new EE_Error(
43
-                __(
44
-                    'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
45
-                    'event_espresso'
46
-                )
47
-            );
48
-        }
40
+		// required fields MUST be present, so let's make sure they are.
41
+		if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
42
+			throw new EE_Error(
43
+				__(
44
+					'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
45
+					'event_espresso'
46
+				)
47
+			);
48
+		}
49 49
 
50
-        // make sure we don't register twice
51
-        if (isset(self::$_settings[ $module_id ])) {
52
-            return;
53
-        }
50
+		// make sure we don't register twice
51
+		if (isset(self::$_settings[ $module_id ])) {
52
+			return;
53
+		}
54 54
 
55
-        // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
57
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
-        ) {
59
-            EE_Error::doing_it_wrong(
60
-                __METHOD__,
61
-                __(
62
-                    'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
63
-                    'event_espresso'
64
-                ),
65
-                '4.3.0'
66
-            );
67
-        }
68
-        // setup $_settings array from incoming values.
69
-        self::$_settings[ $module_id ] = array(
70
-            // array of full server paths to any EED_Modules used by the module
71
-            'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(),
72
-        );
73
-        // add to list of modules to be registered
74
-        add_filter(
75
-            'FHEE__EE_Config__register_modules__modules_to_register',
76
-            array('EE_Register_Module', 'add_modules')
77
-        );
78
-    }
55
+		// make sure this was called in the right place!
56
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
57
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58
+		) {
59
+			EE_Error::doing_it_wrong(
60
+				__METHOD__,
61
+				__(
62
+					'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
63
+					'event_espresso'
64
+				),
65
+				'4.3.0'
66
+			);
67
+		}
68
+		// setup $_settings array from incoming values.
69
+		self::$_settings[ $module_id ] = array(
70
+			// array of full server paths to any EED_Modules used by the module
71
+			'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(),
72
+		);
73
+		// add to list of modules to be registered
74
+		add_filter(
75
+			'FHEE__EE_Config__register_modules__modules_to_register',
76
+			array('EE_Register_Module', 'add_modules')
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Filters the list of modules to add ours.
83
-     * and they're just full filepaths to FOLDERS containing a module class file. Eg.
84
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
85
-     *
86
-     * @param array $modules_to_register array of paths to all modules that require registering
87
-     * @return array
88
-     */
89
-    public static function add_modules($modules_to_register)
90
-    {
91
-        foreach (self::$_settings as $settings) {
92
-            $modules_to_register = array_merge($modules_to_register, $settings['module_paths']);
93
-        }
94
-        return $modules_to_register;
95
-    }
81
+	/**
82
+	 * Filters the list of modules to add ours.
83
+	 * and they're just full filepaths to FOLDERS containing a module class file. Eg.
84
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
85
+	 *
86
+	 * @param array $modules_to_register array of paths to all modules that require registering
87
+	 * @return array
88
+	 */
89
+	public static function add_modules($modules_to_register)
90
+	{
91
+		foreach (self::$_settings as $settings) {
92
+			$modules_to_register = array_merge($modules_to_register, $settings['module_paths']);
93
+		}
94
+		return $modules_to_register;
95
+	}
96 96
 
97 97
 
98
-    /**
99
-     * This deregisters a module that was previously registered with a specific $module_id.
100
-     *
101
-     * @since    4.3.0
102
-     *
103
-     * @param string $module_id the name for the module that was previously registered
104
-     * @return void
105
-     */
106
-    public static function deregister($module_id = null)
107
-    {
108
-        if (isset(self::$_settings[ $module_id ])) {
109
-            unset(self::$_settings[ $module_id ]);
110
-        }
111
-    }
98
+	/**
99
+	 * This deregisters a module that was previously registered with a specific $module_id.
100
+	 *
101
+	 * @since    4.3.0
102
+	 *
103
+	 * @param string $module_id the name for the module that was previously registered
104
+	 * @return void
105
+	 */
106
+	public static function deregister($module_id = null)
107
+	{
108
+		if (isset(self::$_settings[ $module_id ])) {
109
+			unset(self::$_settings[ $module_id ]);
110
+		}
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         // make sure we don't register twice
51
-        if (isset(self::$_settings[ $module_id ])) {
51
+        if (isset(self::$_settings[$module_id])) {
52 52
             return;
53 53
         }
54 54
 
55 55
         // make sure this was called in the right place!
56
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
56
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
57 57
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
58 58
         ) {
59 59
             EE_Error::doing_it_wrong(
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             );
67 67
         }
68 68
         // setup $_settings array from incoming values.
69
-        self::$_settings[ $module_id ] = array(
69
+        self::$_settings[$module_id] = array(
70 70
             // array of full server paths to any EED_Modules used by the module
71 71
             'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(),
72 72
         );
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function deregister($module_id = null)
107 107
     {
108
-        if (isset(self::$_settings[ $module_id ])) {
109
-            unset(self::$_settings[ $module_id ]);
108
+        if (isset(self::$_settings[$module_id])) {
109
+            unset(self::$_settings[$module_id]);
110 110
         }
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Shortcode.lib.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -18,162 +18,162 @@
 block discarded – undo
18 18
 class EE_Register_Shortcode implements EEI_Plugin_API
19 19
 {
20 20
 
21
-    /**
22
-     * Holds values for registered shortcodes
23
-     *
24
-     * @var array
25
-     */
26
-    protected static $_settings = array();
21
+	/**
22
+	 * Holds values for registered shortcodes
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected static $_settings = array();
27 27
 
28 28
 
29
-    /**
30
-     *    Method for registering new EE_Shortcodes
31
-     *
32
-     * @since    4.3.0
33
-     * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
34
-     * @param string $shortcode_id                      a unique identifier for this set of modules Required.
35
-     * @param  array $setup_args                        an array of arguments provided for registering shortcodes
36
-     *                                                  Required.
37
-     * @type array shortcode_paths        an array of full server paths to folders containing any
38
-     *                                                  EES_Shortcodes
39
-     * @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
40
-     *                                                  classes to register.  Shortcode classes should extend
41
-     *                                                  EspressoShortcode and be properly namespaced so they are
42
-     *                                                  autoloaded.
43
-     * @throws EE_Error
44
-     * @return void
45
-     */
46
-    public static function register($shortcode_id = null, $setup_args = array())
47
-    {
48
-        // required fields MUST be present, so let's make sure they are.
49
-        if (empty($shortcode_id)
50
-            || ! is_array($setup_args)
51
-            || (
52
-               empty($setup_args['shortcode_paths']))
53
-               && empty($setup_args['shortcode_fqcns'])
54
-        ) {
55
-            throw new EE_Error(
56
-                esc_html__(
57
-                    '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)',
58
-                    'event_espresso'
59
-                )
60
-            );
61
-        }
29
+	/**
30
+	 *    Method for registering new EE_Shortcodes
31
+	 *
32
+	 * @since    4.3.0
33
+	 * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
34
+	 * @param string $shortcode_id                      a unique identifier for this set of modules Required.
35
+	 * @param  array $setup_args                        an array of arguments provided for registering shortcodes
36
+	 *                                                  Required.
37
+	 * @type array shortcode_paths        an array of full server paths to folders containing any
38
+	 *                                                  EES_Shortcodes
39
+	 * @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
40
+	 *                                                  classes to register.  Shortcode classes should extend
41
+	 *                                                  EspressoShortcode and be properly namespaced so they are
42
+	 *                                                  autoloaded.
43
+	 * @throws EE_Error
44
+	 * @return void
45
+	 */
46
+	public static function register($shortcode_id = null, $setup_args = array())
47
+	{
48
+		// required fields MUST be present, so let's make sure they are.
49
+		if (empty($shortcode_id)
50
+			|| ! is_array($setup_args)
51
+			|| (
52
+			   empty($setup_args['shortcode_paths']))
53
+			   && empty($setup_args['shortcode_fqcns'])
54
+		) {
55
+			throw new EE_Error(
56
+				esc_html__(
57
+					'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)',
58
+					'event_espresso'
59
+				)
60
+			);
61
+		}
62 62
 
63
-        // make sure we don't register twice
64
-        if (isset(self::$_settings[ $shortcode_id ])) {
65
-            return;
66
-        }
63
+		// make sure we don't register twice
64
+		if (isset(self::$_settings[ $shortcode_id ])) {
65
+			return;
66
+		}
67 67
 
68
-        // make sure this was called in the right place!
69
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
70
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
71
-        ) {
72
-            EE_Error::doing_it_wrong(
73
-                __METHOD__,
74
-                esc_html__(
75
-                    '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.',
76
-                    'event_espresso'
77
-                ),
78
-                '4.3.0'
79
-            );
80
-        }
81
-        // setup $_settings array from incoming values.
82
-        self::$_settings[ $shortcode_id ] = array(
83
-            // array of full server paths to any EES_Shortcodes used by the shortcode
84
-            'shortcode_paths' => isset($setup_args['shortcode_paths'])
85
-                ? (array) $setup_args['shortcode_paths']
86
-                : array(),
87
-            'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
88
-                ? (array) $setup_args['shortcode_fqcns']
89
-                : array(),
90
-        );
91
-        // add to list of shortcodes to be registered
92
-        add_filter(
93
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
94
-            array('EE_Register_Shortcode', 'add_shortcodes')
95
-        );
68
+		// make sure this was called in the right place!
69
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
70
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
71
+		) {
72
+			EE_Error::doing_it_wrong(
73
+				__METHOD__,
74
+				esc_html__(
75
+					'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.',
76
+					'event_espresso'
77
+				),
78
+				'4.3.0'
79
+			);
80
+		}
81
+		// setup $_settings array from incoming values.
82
+		self::$_settings[ $shortcode_id ] = array(
83
+			// array of full server paths to any EES_Shortcodes used by the shortcode
84
+			'shortcode_paths' => isset($setup_args['shortcode_paths'])
85
+				? (array) $setup_args['shortcode_paths']
86
+				: array(),
87
+			'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
88
+				? (array) $setup_args['shortcode_fqcns']
89
+				: array(),
90
+		);
91
+		// add to list of shortcodes to be registered
92
+		add_filter(
93
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
94
+			array('EE_Register_Shortcode', 'add_shortcodes')
95
+		);
96 96
 
97
-        add_filter(
98
-            'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
99
-            array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection')
100
-        );
101
-    }
97
+		add_filter(
98
+			'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
99
+			array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection')
100
+		);
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * Filters the list of shortcodes to add ours.
106
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
107
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
108
-     *
109
-     * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
110
-     * @return array
111
-     */
112
-    public static function add_shortcodes($shortcodes_to_register)
113
-    {
114
-        foreach (self::$_settings as $settings) {
115
-            $shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
116
-        }
117
-        return $shortcodes_to_register;
118
-    }
104
+	/**
105
+	 * Filters the list of shortcodes to add ours.
106
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
107
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
108
+	 *
109
+	 * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
110
+	 * @return array
111
+	 */
112
+	public static function add_shortcodes($shortcodes_to_register)
113
+	{
114
+		foreach (self::$_settings as $settings) {
115
+			$shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
116
+		}
117
+		return $shortcodes_to_register;
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Hooks into
123
-     * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
124
-     * registers any provided shortcode fully qualified class names.
125
-     *
126
-     * @param CollectionInterface $shortcodes_collection
127
-     * @return CollectionInterface
128
-     * @throws InvalidArgumentException
129
-     * @throws InvalidClassException
130
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
131
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
132
-     */
133
-    public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
134
-    {
135
-        foreach (self::$_settings as $settings) {
136
-            if (! empty($settings['shortcode_fqcns'])) {
137
-                foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
138
-                    if (! class_exists($shortcode_fqcn)) {
139
-                        throw new InvalidClassException(
140
-                            sprintf(
141
-                                esc_html__(
142
-                                    'Are you sure %s is the right fully qualified class name for the shortcode class?',
143
-                                    'event_espresso'
144
-                                ),
145
-                                $shortcode_fqcn
146
-                            )
147
-                        );
148
-                    }
149
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150
-                        // register dependencies
151
-                        EE_Dependency_Map::register_dependencies(
152
-                            $shortcode_fqcn,
153
-                            array(
154
-                                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
155
-                            )
156
-                        );
157
-                    }
158
-                    $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
159
-                }
160
-            }
161
-        }
162
-        return $shortcodes_collection;
163
-    }
121
+	/**
122
+	 * Hooks into
123
+	 * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
124
+	 * registers any provided shortcode fully qualified class names.
125
+	 *
126
+	 * @param CollectionInterface $shortcodes_collection
127
+	 * @return CollectionInterface
128
+	 * @throws InvalidArgumentException
129
+	 * @throws InvalidClassException
130
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
131
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
132
+	 */
133
+	public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
134
+	{
135
+		foreach (self::$_settings as $settings) {
136
+			if (! empty($settings['shortcode_fqcns'])) {
137
+				foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
138
+					if (! class_exists($shortcode_fqcn)) {
139
+						throw new InvalidClassException(
140
+							sprintf(
141
+								esc_html__(
142
+									'Are you sure %s is the right fully qualified class name for the shortcode class?',
143
+									'event_espresso'
144
+								),
145
+								$shortcode_fqcn
146
+							)
147
+						);
148
+					}
149
+					if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150
+						// register dependencies
151
+						EE_Dependency_Map::register_dependencies(
152
+							$shortcode_fqcn,
153
+							array(
154
+								'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
155
+							)
156
+						);
157
+					}
158
+					$shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
159
+				}
160
+			}
161
+		}
162
+		return $shortcodes_collection;
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
168
-     *
169
-     * @since    4.3.0
170
-     * @param string $shortcode_id the name for the shortcode that was previously registered
171
-     * @return void
172
-     */
173
-    public static function deregister($shortcode_id = null)
174
-    {
175
-        if (isset(self::$_settings[ $shortcode_id ])) {
176
-            unset(self::$_settings[ $shortcode_id ]);
177
-        }
178
-    }
166
+	/**
167
+	 * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
168
+	 *
169
+	 * @since    4.3.0
170
+	 * @param string $shortcode_id the name for the shortcode that was previously registered
171
+	 * @return void
172
+	 */
173
+	public static function deregister($shortcode_id = null)
174
+	{
175
+		if (isset(self::$_settings[ $shortcode_id ])) {
176
+			unset(self::$_settings[ $shortcode_id ]);
177
+		}
178
+	}
179 179
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
         }
62 62
 
63 63
         // make sure we don't register twice
64
-        if (isset(self::$_settings[ $shortcode_id ])) {
64
+        if (isset(self::$_settings[$shortcode_id])) {
65 65
             return;
66 66
         }
67 67
 
68 68
         // make sure this was called in the right place!
69
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
69
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
70 70
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
71 71
         ) {
72 72
             EE_Error::doing_it_wrong(
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             );
80 80
         }
81 81
         // setup $_settings array from incoming values.
82
-        self::$_settings[ $shortcode_id ] = array(
82
+        self::$_settings[$shortcode_id] = array(
83 83
             // array of full server paths to any EES_Shortcodes used by the shortcode
84 84
             'shortcode_paths' => isset($setup_args['shortcode_paths'])
85 85
                 ? (array) $setup_args['shortcode_paths']
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
     public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
134 134
     {
135 135
         foreach (self::$_settings as $settings) {
136
-            if (! empty($settings['shortcode_fqcns'])) {
136
+            if ( ! empty($settings['shortcode_fqcns'])) {
137 137
                 foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
138
-                    if (! class_exists($shortcode_fqcn)) {
138
+                    if ( ! class_exists($shortcode_fqcn)) {
139 139
                         throw new InvalidClassException(
140 140
                             sprintf(
141 141
                                 esc_html__(
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                             )
147 147
                         );
148 148
                     }
149
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
149
+                    if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150 150
                         // register dependencies
151 151
                         EE_Dependency_Map::register_dependencies(
152 152
                             $shortcode_fqcn,
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public static function deregister($shortcode_id = null)
174 174
     {
175
-        if (isset(self::$_settings[ $shortcode_id ])) {
176
-            unset(self::$_settings[ $shortcode_id ]);
175
+        if (isset(self::$_settings[$shortcode_id])) {
176
+            unset(self::$_settings[$shortcode_id]);
177 177
         }
178 178
     }
179 179
 }
Please login to merge, or discard this patch.