Completed
Pull Request — master (#1010)
by
unknown
73:59 queued 64:45
created
core/services/options/JsonWpOptionSerializableInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
  */
18 18
 interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable
19 19
 {
20
-    /**
21
-     * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
-     * determine what option name to use.
23
-     * @since $VID:$
24
-     * @return string
25
-     */
26
-    public function getWpOptionName();
20
+	/**
21
+	 * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
+	 * determine what option name to use.
23
+	 * @since $VID:$
24
+	 * @return string
25
+	 */
26
+	public function getWpOptionName();
27 27
 }
28 28
 // End of file JsonWpOptionSerializableInterface.php
29 29
 // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php
Please login to merge, or discard this patch.
core/services/request/files/FileSubmissionInterface.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 interface FileSubmissionInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function getName();
22
-
23
-    /**
24
-     * @return string
25
-     */
26
-    public function getType();
27
-
28
-    /**
29
-     * @return int
30
-     */
31
-    public function getSize();
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    public function getTmpFile();
37
-
38
-    /**
39
-     * @since $VID:$
40
-     * @return string
41
-     */
42
-    public function __toString();
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function getErrorCode();
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function getName();
22
+
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function getType();
27
+
28
+	/**
29
+	 * @return int
30
+	 */
31
+	public function getSize();
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function getTmpFile();
37
+
38
+	/**
39
+	 * @since $VID:$
40
+	 * @return string
41
+	 */
42
+	public function __toString();
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function getErrorCode();
48 48
 }
49 49
 // End of file FileSubmissionInterface.php
50 50
 // Location: EventEspresso\core\services\request\files/FileSubmissionInterface.php
Please login to merge, or discard this patch.
strategies/display/EE_File_Input_Display_Strategy.strategy.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
  */
11 11
 class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy
12 12
 {
13
-    /**
14
-     * The html "type" attribute value. default is "text"
15
-     * @var string
16
-     */
17
-    protected $allowed_extensions;
13
+	/**
14
+	 * The html "type" attribute value. default is "text"
15
+	 * @var string
16
+	 */
17
+	protected $allowed_extensions;
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * @param string $allowed_extensions
23
-     */
24
-    public function __construct($type = 'file', $allowed_extensions = [])
25
-    {
26
-        $this->allowed_extensions = $allowed_extensions;
27
-        parent::__construct($type);
28
-    }
21
+	/**
22
+	 * @param string $allowed_extensions
23
+	 */
24
+	public function __construct($type = 'file', $allowed_extensions = [])
25
+	{
26
+		$this->allowed_extensions = $allowed_extensions;
27
+		parent::__construct($type);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
strategies/display/EE_Text_Input_Display_Strategy.strategy.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base
15 15
 {
16
-    /**
17
-     * The html "type" attribute value. default is "text"
18
-     * @var string
19
-     */
20
-    protected $_type;
16
+	/**
17
+	 * The html "type" attribute value. default is "text"
18
+	 * @var string
19
+	 */
20
+	protected $_type;
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * @param string $allowed_extensions
26
-     */
27
-    public function __construct($allowed_extensions = 'text')
28
-    {
29
-        $this->_type = $allowed_extensions;
30
-        parent::__construct();
31
-    }
24
+	/**
25
+	 * @param string $allowed_extensions
26
+	 */
27
+	public function __construct($allowed_extensions = 'text')
28
+	{
29
+		$this->_type = $allowed_extensions;
30
+		parent::__construct();
31
+	}
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * Gets the html "type" attribute's value
37
-     * @return string
38
-     */
39
-    public function get_type()
40
-    {
41
-        if ($this->_type === 'email'
42
-            && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false)
43
-        ) {
44
-            return 'text';
45
-        }
46
-        return $this->_type;
47
-    }
35
+	/**
36
+	 * Gets the html "type" attribute's value
37
+	 * @return string
38
+	 */
39
+	public function get_type()
40
+	{
41
+		if ($this->_type === 'email'
42
+			&& ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false)
43
+		) {
44
+			return 'text';
45
+		}
46
+		return $this->_type;
47
+	}
48 48
 
49 49
 
50 50
 
51
-    /**
52
-     *
53
-     * @return string of html to display the field
54
-     */
55
-    public function display()
56
-    {
57
-        $input = '<input type="'. $this->get_type() .'"';
58
-        $input .= ' name="' . $this->_input->html_name() . '"';
59
-        $input .= ' id="' . $this->_input->html_id() . '"';
60
-        $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
61
-        $input .= ' class="' . $class . '"';
62
-        // add html5 required
63
-        $input .= $this->_input->required() ? ' required' : '';
64
-        $input .= ' value="' . $this->_input->raw_value_in_form() . '"';
65
-        $input .= ' style="' . $this->_input->html_style() . '"';
66
-        $input .= $this->_input->other_html_attributes();
67
-        $input .= '/>';
68
-        return $input;
69
-    }
51
+	/**
52
+	 *
53
+	 * @return string of html to display the field
54
+	 */
55
+	public function display()
56
+	{
57
+		$input = '<input type="'. $this->get_type() .'"';
58
+		$input .= ' name="' . $this->_input->html_name() . '"';
59
+		$input .= ' id="' . $this->_input->html_id() . '"';
60
+		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
61
+		$input .= ' class="' . $class . '"';
62
+		// add html5 required
63
+		$input .= $this->_input->required() ? ' required' : '';
64
+		$input .= ' value="' . $this->_input->raw_value_in_form() . '"';
65
+		$input .= ' style="' . $this->_input->html_style() . '"';
66
+		$input .= $this->_input->other_html_attributes();
67
+		$input .= '/>';
68
+		return $input;
69
+	}
70 70
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1083 added lines, -1083 removed lines patch added patch discarded remove patch
@@ -20,1087 +20,1087 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
604
-                array(),
605
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
606
-            ),
607
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
608
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
609
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
610
-            ),
611
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
612
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
613
-            ),
614
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
615
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
618
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
619
-            ),
620
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
621
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
-            ),
623
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
624
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
-            ),
626
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
627
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
630
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
-            ),
632
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
633
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
634
-            ),
635
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
636
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
637
-            ),
638
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
639
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
640
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
641
-            ),
642
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
643
-                null,
644
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
647
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'LEGACY_MODELS'                                                                                               => array(
650
-                null,
651
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
652
-            ),
653
-            'EE_Module_Request_Router'                                                                                    => array(
654
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
655
-            ),
656
-            'EE_Registration_Processor'                                                                                   => array(
657
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
658
-            ),
659
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
660
-                null,
661
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
662
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
665
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
666
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
667
-            ),
668
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
669
-                null,
670
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
671
-            ),
672
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
673
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
674
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
675
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
678
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
679
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
680
-            ),
681
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
682
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
683
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
684
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
685
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
686
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
687
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
688
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
689
-            ),
690
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
691
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
692
-            ),
693
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
694
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
695
-            ),
696
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
697
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
698
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
699
-            ),
700
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
701
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
702
-            ),
703
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
704
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
705
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
706
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
707
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
708
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
709
-            ),
710
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
711
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
712
-            ),
713
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
714
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
715
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
-            ),
717
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
718
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
719
-            ),
720
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
721
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
722
-            ),
723
-            'EE_CPT_Strategy'                                                                                             => array(
724
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
726
-            ),
727
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
728
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
729
-            ),
730
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
731
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
732
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
733
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
735
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
736
-            ),
737
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
738
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
740
-            ),
741
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
742
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
743
-            ),
744
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
745
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
746
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
747
-            ),
748
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
749
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
750
-            ),
751
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
752
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
753
-            ),
754
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
755
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
756
-            ),
757
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
758
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
759
-            ),
760
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
761
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
762
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
763
-            ),
764
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
765
-                null,
766
-                null,
767
-                null,
768
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
769
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
771
-            ),
772
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
773
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
774
-                'EE_Config' => EE_Dependency_Map::load_from_cache
775
-            ),
776
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
777
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
778
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
779
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
780
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
781
-            ),
782
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
783
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
788
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
789
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
790
-            ),
791
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
792
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
793
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
794
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
797
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
798
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
799
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
802
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
804
-            ),
805
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
806
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
808
-            ),
809
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
810
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
811
-            ),
812
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
813
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
814
-            ),
815
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
816
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
817
-            ),
818
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
819
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
820
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
821
-            ),
822
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
823
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
824
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
825
-            ),
826
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
827
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
828
-            ),
829
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
830
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
831
-            ),
832
-            'EE_URL_Validation_Strategy' => array(
833
-                null,
834
-                null,
835
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
836
-            ),
837
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
838
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
839
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
840
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
841
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
842
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
843
-            ),
844
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
845
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
846
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
847
-            ),
848
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
849
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
850
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
851
-            ),
852
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
853
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
854
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
855
-            ),
856
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
857
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
858
-            ),
859
-        );
860
-    }
861
-
862
-
863
-    /**
864
-     * Registers how core classes are loaded.
865
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
866
-     *        'EE_Request_Handler' => 'load_core'
867
-     *        'EE_Messages_Queue'  => 'load_lib'
868
-     *        'EEH_Debug_Tools'    => 'load_helper'
869
-     * or, if greater control is required, by providing a custom closure. For example:
870
-     *        'Some_Class' => function () {
871
-     *            return new Some_Class();
872
-     *        },
873
-     * This is required for instantiating dependencies
874
-     * where an interface has been type hinted in a class constructor. For example:
875
-     *        'Required_Interface' => function () {
876
-     *            return new A_Class_That_Implements_Required_Interface();
877
-     *        },
878
-     */
879
-    protected function _register_core_class_loaders()
880
-    {
881
-        $this->_class_loaders = array(
882
-            // load_core
883
-            'EE_Dependency_Map'                            => function () {
884
-                return $this;
885
-            },
886
-            'EE_Capabilities'                              => 'load_core',
887
-            'EE_Encryption'                                => 'load_core',
888
-            'EE_Front_Controller'                          => 'load_core',
889
-            'EE_Module_Request_Router'                     => 'load_core',
890
-            'EE_Registry'                                  => 'load_core',
891
-            'EE_Request'                                   => function () {
892
-                return $this->legacy_request;
893
-            },
894
-            'EventEspresso\core\services\request\Request'  => function () {
895
-                return $this->request;
896
-            },
897
-            'EventEspresso\core\services\request\Response' => function () {
898
-                return $this->response;
899
-            },
900
-            'EE_Base'                                      => 'load_core',
901
-            'EE_Request_Handler'                           => 'load_core',
902
-            'EE_Session'                                   => 'load_core',
903
-            'EE_Cron_Tasks'                                => 'load_core',
904
-            'EE_System'                                    => 'load_core',
905
-            'EE_Maintenance_Mode'                          => 'load_core',
906
-            'EE_Register_CPTs'                             => 'load_core',
907
-            'EE_Admin'                                     => 'load_core',
908
-            'EE_CPT_Strategy'                              => 'load_core',
909
-            // load_lib
910
-            'EE_Message_Resource_Manager'                  => 'load_lib',
911
-            'EE_Message_Type_Collection'                   => 'load_lib',
912
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
913
-            'EE_Messenger_Collection'                      => 'load_lib',
914
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
915
-            'EE_Messages_Processor'                        => 'load_lib',
916
-            'EE_Message_Repository'                        => 'load_lib',
917
-            'EE_Messages_Queue'                            => 'load_lib',
918
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
919
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
920
-            'EE_Payment_Method_Manager'                    => 'load_lib',
921
-            'EE_Messages_Generator'                        => function () {
922
-                return EE_Registry::instance()->load_lib(
923
-                    'Messages_Generator',
924
-                    array(),
925
-                    false,
926
-                    false
927
-                );
928
-            },
929
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
930
-                return EE_Registry::instance()->load_lib(
931
-                    'Messages_Template_Defaults',
932
-                    $arguments,
933
-                    false,
934
-                    false
935
-                );
936
-            },
937
-            // load_helper
938
-            'EEH_Parse_Shortcodes'                         => function () {
939
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
940
-                    return new EEH_Parse_Shortcodes();
941
-                }
942
-                return null;
943
-            },
944
-            'EE_Template_Config'                           => function () {
945
-                return EE_Config::instance()->template_settings;
946
-            },
947
-            'EE_Currency_Config'                           => function () {
948
-                return EE_Config::instance()->currency;
949
-            },
950
-            'EE_Registration_Config'                       => function () {
951
-                return EE_Config::instance()->registration;
952
-            },
953
-            'EE_Core_Config'                               => function () {
954
-                return EE_Config::instance()->core;
955
-            },
956
-            'EventEspresso\core\services\loaders\Loader'   => function () {
957
-                return LoaderFactory::getLoader();
958
-            },
959
-            'EE_Network_Config'                            => function () {
960
-                return EE_Network_Config::instance();
961
-            },
962
-            'EE_Config'                                    => function () {
963
-                return EE_Config::instance();
964
-            },
965
-            'EventEspresso\core\domain\Domain'             => function () {
966
-                return DomainFactory::getEventEspressoCoreDomain();
967
-            },
968
-            'EE_Admin_Config'                              => function () {
969
-                return EE_Config::instance()->admin;
970
-            },
971
-            'EE_Organization_Config'                       => function () {
972
-                return EE_Config::instance()->organization;
973
-            },
974
-            'EE_Network_Core_Config'                       => function () {
975
-                return EE_Network_Config::instance()->core;
976
-            },
977
-            'EE_Environment_Config'                        => function () {
978
-                return EE_Config::instance()->environment;
979
-            },
980
-        );
981
-    }
982
-
983
-
984
-    /**
985
-     * can be used for supplying alternate names for classes,
986
-     * or for connecting interface names to instantiable classes
987
-     */
988
-    protected function _register_core_aliases()
989
-    {
990
-        $aliases = array(
991
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
992
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
993
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
994
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
995
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
996
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
997
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
998
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
999
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1000
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1001
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1002
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1003
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1004
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1005
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1006
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1007
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1008
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1009
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1010
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1011
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1012
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1013
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1014
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1015
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1016
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1017
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1018
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1019
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1020
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1021
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1022
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1023
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1024
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1025
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1026
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1027
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1028
-        );
1029
-        foreach ($aliases as $alias => $fqn) {
1030
-            if (is_array($fqn)) {
1031
-                foreach ($fqn as $class => $for_class) {
1032
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1033
-                }
1034
-                continue;
1035
-            }
1036
-            $this->class_cache->addAlias($fqn, $alias);
1037
-        }
1038
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1039
-            $this->class_cache->addAlias(
1040
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1041
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1042
-            );
1043
-        }
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1049
-     * request Primarily used by unit tests.
1050
-     */
1051
-    public function reset()
1052
-    {
1053
-        $this->_register_core_class_loaders();
1054
-        $this->_register_core_dependencies();
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * PLZ NOTE: a better name for this method would be is_alias()
1060
-     * because it returns TRUE if the provided fully qualified name IS an alias
1061
-     * WHY?
1062
-     * Because if a class is type hinting for a concretion,
1063
-     * then why would we need to find another class to supply it?
1064
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1065
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1066
-     * Don't go looking for some substitute.
1067
-     * Whereas if a class is type hinting for an interface...
1068
-     * then we need to find an actual class to use.
1069
-     * So the interface IS the alias for some other FQN,
1070
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1071
-     * represents some other class.
1072
-     *
1073
-     * @deprecated 4.9.62.p
1074
-     * @param string $fqn
1075
-     * @param string $for_class
1076
-     * @return bool
1077
-     */
1078
-    public function has_alias($fqn = '', $for_class = '')
1079
-    {
1080
-        return $this->isAlias($fqn, $for_class);
1081
-    }
1082
-
1083
-
1084
-    /**
1085
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1086
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1087
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1088
-     *  for example:
1089
-     *      if the following two entries were added to the _aliases array:
1090
-     *          array(
1091
-     *              'interface_alias'           => 'some\namespace\interface'
1092
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1093
-     *          )
1094
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1095
-     *      to load an instance of 'some\namespace\classname'
1096
-     *
1097
-     * @deprecated 4.9.62.p
1098
-     * @param string $alias
1099
-     * @param string $for_class
1100
-     * @return string
1101
-     */
1102
-    public function get_alias($alias = '', $for_class = '')
1103
-    {
1104
-        return $this->getFqnForAlias($alias, $for_class);
1105
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
604
+				array(),
605
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
606
+			),
607
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
608
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
609
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
610
+			),
611
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
612
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
613
+			),
614
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
615
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
618
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
619
+			),
620
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
621
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
+			),
623
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
624
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
+			),
626
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
627
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
630
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
+			),
632
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
633
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
634
+			),
635
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
636
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
637
+			),
638
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
639
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
640
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
641
+			),
642
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
643
+				null,
644
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
647
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'LEGACY_MODELS'                                                                                               => array(
650
+				null,
651
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
652
+			),
653
+			'EE_Module_Request_Router'                                                                                    => array(
654
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
655
+			),
656
+			'EE_Registration_Processor'                                                                                   => array(
657
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
658
+			),
659
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
660
+				null,
661
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
662
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
665
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
666
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
667
+			),
668
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
669
+				null,
670
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
671
+			),
672
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
673
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
674
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
675
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
678
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
679
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
680
+			),
681
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
682
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
683
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
684
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
685
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
686
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
687
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
688
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
689
+			),
690
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
691
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
692
+			),
693
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
694
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
695
+			),
696
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
697
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
698
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
699
+			),
700
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
701
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
702
+			),
703
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
704
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
705
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
706
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
707
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
708
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
709
+			),
710
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
711
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
712
+			),
713
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
714
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
715
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
+			),
717
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
718
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
719
+			),
720
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
721
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
722
+			),
723
+			'EE_CPT_Strategy'                                                                                             => array(
724
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
726
+			),
727
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
728
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
729
+			),
730
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
731
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
732
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
733
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
735
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
736
+			),
737
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
738
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
740
+			),
741
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
742
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
743
+			),
744
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
745
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
746
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
747
+			),
748
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
749
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
750
+			),
751
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
752
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
753
+			),
754
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
755
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
756
+			),
757
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
758
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
759
+			),
760
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
761
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
762
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
763
+			),
764
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
765
+				null,
766
+				null,
767
+				null,
768
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
769
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
771
+			),
772
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
773
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
774
+				'EE_Config' => EE_Dependency_Map::load_from_cache
775
+			),
776
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
777
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
778
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
779
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
780
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
781
+			),
782
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
783
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
788
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
789
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
790
+			),
791
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
792
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
793
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
794
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
795
+			),
796
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
797
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
798
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
799
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
802
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
804
+			),
805
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
806
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
808
+			),
809
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
810
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
811
+			),
812
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
813
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
814
+			),
815
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
816
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
817
+			),
818
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
819
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
820
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
821
+			),
822
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
823
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
824
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
825
+			),
826
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
827
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
828
+			),
829
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
830
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
831
+			),
832
+			'EE_URL_Validation_Strategy' => array(
833
+				null,
834
+				null,
835
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
836
+			),
837
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
838
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
839
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
840
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
841
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
842
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
843
+			),
844
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
845
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
846
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
847
+			),
848
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
849
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
850
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
851
+			),
852
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
853
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
854
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
855
+			),
856
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
857
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
858
+			),
859
+		);
860
+	}
861
+
862
+
863
+	/**
864
+	 * Registers how core classes are loaded.
865
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
866
+	 *        'EE_Request_Handler' => 'load_core'
867
+	 *        'EE_Messages_Queue'  => 'load_lib'
868
+	 *        'EEH_Debug_Tools'    => 'load_helper'
869
+	 * or, if greater control is required, by providing a custom closure. For example:
870
+	 *        'Some_Class' => function () {
871
+	 *            return new Some_Class();
872
+	 *        },
873
+	 * This is required for instantiating dependencies
874
+	 * where an interface has been type hinted in a class constructor. For example:
875
+	 *        'Required_Interface' => function () {
876
+	 *            return new A_Class_That_Implements_Required_Interface();
877
+	 *        },
878
+	 */
879
+	protected function _register_core_class_loaders()
880
+	{
881
+		$this->_class_loaders = array(
882
+			// load_core
883
+			'EE_Dependency_Map'                            => function () {
884
+				return $this;
885
+			},
886
+			'EE_Capabilities'                              => 'load_core',
887
+			'EE_Encryption'                                => 'load_core',
888
+			'EE_Front_Controller'                          => 'load_core',
889
+			'EE_Module_Request_Router'                     => 'load_core',
890
+			'EE_Registry'                                  => 'load_core',
891
+			'EE_Request'                                   => function () {
892
+				return $this->legacy_request;
893
+			},
894
+			'EventEspresso\core\services\request\Request'  => function () {
895
+				return $this->request;
896
+			},
897
+			'EventEspresso\core\services\request\Response' => function () {
898
+				return $this->response;
899
+			},
900
+			'EE_Base'                                      => 'load_core',
901
+			'EE_Request_Handler'                           => 'load_core',
902
+			'EE_Session'                                   => 'load_core',
903
+			'EE_Cron_Tasks'                                => 'load_core',
904
+			'EE_System'                                    => 'load_core',
905
+			'EE_Maintenance_Mode'                          => 'load_core',
906
+			'EE_Register_CPTs'                             => 'load_core',
907
+			'EE_Admin'                                     => 'load_core',
908
+			'EE_CPT_Strategy'                              => 'load_core',
909
+			// load_lib
910
+			'EE_Message_Resource_Manager'                  => 'load_lib',
911
+			'EE_Message_Type_Collection'                   => 'load_lib',
912
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
913
+			'EE_Messenger_Collection'                      => 'load_lib',
914
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
915
+			'EE_Messages_Processor'                        => 'load_lib',
916
+			'EE_Message_Repository'                        => 'load_lib',
917
+			'EE_Messages_Queue'                            => 'load_lib',
918
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
919
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
920
+			'EE_Payment_Method_Manager'                    => 'load_lib',
921
+			'EE_Messages_Generator'                        => function () {
922
+				return EE_Registry::instance()->load_lib(
923
+					'Messages_Generator',
924
+					array(),
925
+					false,
926
+					false
927
+				);
928
+			},
929
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
930
+				return EE_Registry::instance()->load_lib(
931
+					'Messages_Template_Defaults',
932
+					$arguments,
933
+					false,
934
+					false
935
+				);
936
+			},
937
+			// load_helper
938
+			'EEH_Parse_Shortcodes'                         => function () {
939
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
940
+					return new EEH_Parse_Shortcodes();
941
+				}
942
+				return null;
943
+			},
944
+			'EE_Template_Config'                           => function () {
945
+				return EE_Config::instance()->template_settings;
946
+			},
947
+			'EE_Currency_Config'                           => function () {
948
+				return EE_Config::instance()->currency;
949
+			},
950
+			'EE_Registration_Config'                       => function () {
951
+				return EE_Config::instance()->registration;
952
+			},
953
+			'EE_Core_Config'                               => function () {
954
+				return EE_Config::instance()->core;
955
+			},
956
+			'EventEspresso\core\services\loaders\Loader'   => function () {
957
+				return LoaderFactory::getLoader();
958
+			},
959
+			'EE_Network_Config'                            => function () {
960
+				return EE_Network_Config::instance();
961
+			},
962
+			'EE_Config'                                    => function () {
963
+				return EE_Config::instance();
964
+			},
965
+			'EventEspresso\core\domain\Domain'             => function () {
966
+				return DomainFactory::getEventEspressoCoreDomain();
967
+			},
968
+			'EE_Admin_Config'                              => function () {
969
+				return EE_Config::instance()->admin;
970
+			},
971
+			'EE_Organization_Config'                       => function () {
972
+				return EE_Config::instance()->organization;
973
+			},
974
+			'EE_Network_Core_Config'                       => function () {
975
+				return EE_Network_Config::instance()->core;
976
+			},
977
+			'EE_Environment_Config'                        => function () {
978
+				return EE_Config::instance()->environment;
979
+			},
980
+		);
981
+	}
982
+
983
+
984
+	/**
985
+	 * can be used for supplying alternate names for classes,
986
+	 * or for connecting interface names to instantiable classes
987
+	 */
988
+	protected function _register_core_aliases()
989
+	{
990
+		$aliases = array(
991
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
992
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
993
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
994
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
995
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
996
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
997
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
998
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
999
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1000
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1001
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1002
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1003
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1004
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1005
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1006
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1007
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1008
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1009
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1010
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1011
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1012
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1013
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1014
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1015
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1016
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1017
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1018
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1019
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1020
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1021
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1022
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1023
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1024
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1025
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1026
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1027
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1028
+		);
1029
+		foreach ($aliases as $alias => $fqn) {
1030
+			if (is_array($fqn)) {
1031
+				foreach ($fqn as $class => $for_class) {
1032
+					$this->class_cache->addAlias($class, $alias, $for_class);
1033
+				}
1034
+				continue;
1035
+			}
1036
+			$this->class_cache->addAlias($fqn, $alias);
1037
+		}
1038
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1039
+			$this->class_cache->addAlias(
1040
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1041
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1042
+			);
1043
+		}
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1049
+	 * request Primarily used by unit tests.
1050
+	 */
1051
+	public function reset()
1052
+	{
1053
+		$this->_register_core_class_loaders();
1054
+		$this->_register_core_dependencies();
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * PLZ NOTE: a better name for this method would be is_alias()
1060
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1061
+	 * WHY?
1062
+	 * Because if a class is type hinting for a concretion,
1063
+	 * then why would we need to find another class to supply it?
1064
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1065
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1066
+	 * Don't go looking for some substitute.
1067
+	 * Whereas if a class is type hinting for an interface...
1068
+	 * then we need to find an actual class to use.
1069
+	 * So the interface IS the alias for some other FQN,
1070
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1071
+	 * represents some other class.
1072
+	 *
1073
+	 * @deprecated 4.9.62.p
1074
+	 * @param string $fqn
1075
+	 * @param string $for_class
1076
+	 * @return bool
1077
+	 */
1078
+	public function has_alias($fqn = '', $for_class = '')
1079
+	{
1080
+		return $this->isAlias($fqn, $for_class);
1081
+	}
1082
+
1083
+
1084
+	/**
1085
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1086
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1087
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1088
+	 *  for example:
1089
+	 *      if the following two entries were added to the _aliases array:
1090
+	 *          array(
1091
+	 *              'interface_alias'           => 'some\namespace\interface'
1092
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1093
+	 *          )
1094
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1095
+	 *      to load an instance of 'some\namespace\classname'
1096
+	 *
1097
+	 * @deprecated 4.9.62.p
1098
+	 * @param string $alias
1099
+	 * @param string $for_class
1100
+	 * @return string
1101
+	 */
1102
+	public function get_alias($alias = '', $for_class = '')
1103
+	{
1104
+		return $this->getFqnForAlias($alias, $for_class);
1105
+	}
1106 1106
 }
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -38,264 +38,264 @@
 block discarded – undo
38 38
  */
39 39
 class FilesDataHandler
40 40
 {
41
-    /**
42
-     * @var Request
43
-     */
44
-    protected $request;
41
+	/**
42
+	 * @var Request
43
+	 */
44
+	protected $request;
45 45
 
46
-    /**
47
-     * @var CollectionInterface | FileSubmissionInterface[]
48
-     */
49
-    protected $file_objects;
46
+	/**
47
+	 * @var CollectionInterface | FileSubmissionInterface[]
48
+	 */
49
+	protected $file_objects;
50 50
 
51
-    /**
52
-     * @var bool
53
-     */
54
-    protected $initialized = false;
51
+	/**
52
+	 * @var bool
53
+	 */
54
+	protected $initialized = false;
55 55
 
56
-    /**
57
-     * FilesDataHandler constructor.
58
-     * @param Request $request
59
-     */
60
-    public function __construct(Request $request)
61
-    {
62
-        $this->request = $request;
63
-    }
56
+	/**
57
+	 * FilesDataHandler constructor.
58
+	 * @param Request $request
59
+	 */
60
+	public function __construct(Request $request)
61
+	{
62
+		$this->request = $request;
63
+	}
64 64
 
65
-    /**
66
-     * @since $VID:$
67
-     * @return CollectionInterface | FileSubmissionInterface[]
68
-     * @throws UnexpectedValueException
69
-     * @throws InvalidArgumentException
70
-     */
71
-    protected function getFileObjects()
72
-    {
73
-        $this->initialize();
74
-        return $this->file_objects;
75
-    }
65
+	/**
66
+	 * @since $VID:$
67
+	 * @return CollectionInterface | FileSubmissionInterface[]
68
+	 * @throws UnexpectedValueException
69
+	 * @throws InvalidArgumentException
70
+	 */
71
+	protected function getFileObjects()
72
+	{
73
+		$this->initialize();
74
+		return $this->file_objects;
75
+	}
76 76
 
77
-    /**
78
-     * Sets up the file objects from the request's $_FILES data.
79
-     * @since $VID:$
80
-     * @throws UnexpectedValueException
81
-     * @throws InvalidArgumentException
82
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
83
-     */
84
-    protected function initialize()
85
-    {
86
-        if ($this->initialized) {
87
-            return;
88
-        }
89
-        $this->file_objects = new Collection(
90
-            // collection interface
91
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
92
-            // collection name
93
-            'submitted_files'
94
-        );
95
-        $files_raw_data = $this->request->filesParams();
96
-        if (empty($files_raw_data)) {
97
-            return;
98
-        }
99
-        if ($this->isStrangeFilesArray($files_raw_data)) {
100
-            $data = $this->fixFilesDataArray($files_raw_data);
101
-        } else {
102
-            $data = $files_raw_data;
103
-        }
104
-        $this->createFileObjects($data);
105
-        $this->initialized = true;
106
-    }
77
+	/**
78
+	 * Sets up the file objects from the request's $_FILES data.
79
+	 * @since $VID:$
80
+	 * @throws UnexpectedValueException
81
+	 * @throws InvalidArgumentException
82
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
83
+	 */
84
+	protected function initialize()
85
+	{
86
+		if ($this->initialized) {
87
+			return;
88
+		}
89
+		$this->file_objects = new Collection(
90
+			// collection interface
91
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
92
+			// collection name
93
+			'submitted_files'
94
+		);
95
+		$files_raw_data = $this->request->filesParams();
96
+		if (empty($files_raw_data)) {
97
+			return;
98
+		}
99
+		if ($this->isStrangeFilesArray($files_raw_data)) {
100
+			$data = $this->fixFilesDataArray($files_raw_data);
101
+		} else {
102
+			$data = $files_raw_data;
103
+		}
104
+		$this->createFileObjects($data);
105
+		$this->initialized = true;
106
+	}
107 107
 
108
-    /**
109
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
110
-     * @since $VID:$
111
-     * @param $files_data
112
-     * @return bool
113
-     * @throws UnexpectedValueException
114
-     */
115
-    protected function isStrangeFilesArray($files_data)
116
-    {
117
-        if (!is_array($files_data)) {
118
-            throw new UnexpectedValueException(
119
-                sprintf(
120
-                    esc_html__(
121
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
122
-                        'event_espresso'
123
-                    ),
124
-                    (string) $files_data
125
-                )
126
-            );
127
-        }
128
-        $first_value = reset($files_data);
129
-        if (!is_array($first_value)) {
130
-            throw new UnexpectedValueException(
131
-                sprintf(
132
-                    esc_html__(
133
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
134
-                        'event_espresso'
135
-                    ),
136
-                    (string) $first_value
137
-                )
138
-            );
139
-        }
140
-        $first_sub_array_item = reset($first_value);
141
-        if (is_array($first_sub_array_item)) {
142
-            // not just a 2d array
143
-            return true;
144
-        }
145
-        // yep, just 2d array
146
-        return false;
147
-    }
108
+	/**
109
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
110
+	 * @since $VID:$
111
+	 * @param $files_data
112
+	 * @return bool
113
+	 * @throws UnexpectedValueException
114
+	 */
115
+	protected function isStrangeFilesArray($files_data)
116
+	{
117
+		if (!is_array($files_data)) {
118
+			throw new UnexpectedValueException(
119
+				sprintf(
120
+					esc_html__(
121
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
122
+						'event_espresso'
123
+					),
124
+					(string) $files_data
125
+				)
126
+			);
127
+		}
128
+		$first_value = reset($files_data);
129
+		if (!is_array($first_value)) {
130
+			throw new UnexpectedValueException(
131
+				sprintf(
132
+					esc_html__(
133
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
134
+						'event_espresso'
135
+					),
136
+					(string) $first_value
137
+				)
138
+			);
139
+		}
140
+		$first_sub_array_item = reset($first_value);
141
+		if (is_array($first_sub_array_item)) {
142
+			// not just a 2d array
143
+			return true;
144
+		}
145
+		// yep, just 2d array
146
+		return false;
147
+	}
148 148
 
149
-    /**
150
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
151
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
152
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
153
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
154
-     * @since $VID:$
155
-     * @param $files_data
156
-     * @return array
157
-     */
158
-    protected function fixFilesDataArray($files_data)
159
-    {
160
-        $sane_files_array = [];
161
-        foreach ($files_data as $top_level_name => $top_level_children) {
162
-            $sub_array = [];
163
-            $sane_files_array[ $top_level_name ] = [];
164
-            foreach ($top_level_children as $file_data_part => $second_level_children) {
165
-                foreach ($second_level_children as $next_level_name => $sub_values) {
166
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
167
-                }
168
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
169
-                    $sub_array,
170
-                    $sane_files_array[ $top_level_name ]
171
-                );
172
-            }
173
-        }
174
-        return $sane_files_array;
175
-    }
149
+	/**
150
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
151
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
152
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
153
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
154
+	 * @since $VID:$
155
+	 * @param $files_data
156
+	 * @return array
157
+	 */
158
+	protected function fixFilesDataArray($files_data)
159
+	{
160
+		$sane_files_array = [];
161
+		foreach ($files_data as $top_level_name => $top_level_children) {
162
+			$sub_array = [];
163
+			$sane_files_array[ $top_level_name ] = [];
164
+			foreach ($top_level_children as $file_data_part => $second_level_children) {
165
+				foreach ($second_level_children as $next_level_name => $sub_values) {
166
+					$sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
167
+				}
168
+				$sane_files_array[ $top_level_name ] = array_replace_recursive(
169
+					$sub_array,
170
+					$sane_files_array[ $top_level_name ]
171
+				);
172
+			}
173
+		}
174
+		return $sane_files_array;
175
+	}
176 176
 
177
-    /**
178
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
179
-     * @since $VID:$
180
-     * @param $data array|string
181
-     * @param $type 'name', 'tmp_name', 'size', or 'error'
182
-     * @param $name string
183
-     * @return array|string
184
-     */
185
-    protected function organizeFilesData($data, $type)
186
-    {
187
-        if (! is_array($data)) {
188
-            return [
189
-                $type => $data
190
-            ];
191
-        }
192
-        $organized_data = [];
193
-        foreach ($data as $input_name_part => $sub_inputs_or_value) {
194
-            if (is_array($sub_inputs_or_value)) {
195
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
196
-            } else {
197
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
198
-            }
199
-        }
200
-        return $organized_data;
201
-    }
177
+	/**
178
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
179
+	 * @since $VID:$
180
+	 * @param $data array|string
181
+	 * @param $type 'name', 'tmp_name', 'size', or 'error'
182
+	 * @param $name string
183
+	 * @return array|string
184
+	 */
185
+	protected function organizeFilesData($data, $type)
186
+	{
187
+		if (! is_array($data)) {
188
+			return [
189
+				$type => $data
190
+			];
191
+		}
192
+		$organized_data = [];
193
+		foreach ($data as $input_name_part => $sub_inputs_or_value) {
194
+			if (is_array($sub_inputs_or_value)) {
195
+				$organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
196
+			} else {
197
+				$organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
198
+			}
199
+		}
200
+		return $organized_data;
201
+	}
202 202
 
203
-    /**
204
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
205
-     * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
206
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
207
-     * @since $VID:$
208
-     * @param array $organized_files $_FILES but organized like $_POST
209
-     * @param array $name_parts_so_far for multidimensional HTML form names,
210
-     * @throws UnexpectedValueException
211
-     * @throws InvalidArgumentException
212
-     */
213
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
214
-    {
215
-        if (!is_array($organized_files)) {
216
-            throw new UnexpectedValueException(
217
-                sprintf(
218
-                    esc_html__(
219
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
220
-                        'event_espresso'
221
-                    ),
222
-                    (string) $organized_files
223
-                )
224
-            );
225
-        }
226
-        foreach ($organized_files as $key => $value) {
227
-            $this_input_name_parts = $name_parts_so_far;
228
-            array_push(
229
-                $this_input_name_parts,
230
-                $key
231
-            );
232
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
233
-                $html_name = $this->inputNameFromParts($this_input_name_parts);
234
-                $this->file_objects->add(
235
-                    new FileSubmission(
236
-                        $value['name'],
237
-                        $value['tmp_name'],
238
-                        $value['size'],
239
-                        $value['error']
240
-                    ),
241
-                    $html_name
242
-                );
243
-            } else {
244
-                $this->createFileObjects($value, $this_input_name_parts);
245
-            }
246
-        }
247
-    }
203
+	/**
204
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
205
+	 * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
206
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
207
+	 * @since $VID:$
208
+	 * @param array $organized_files $_FILES but organized like $_POST
209
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
210
+	 * @throws UnexpectedValueException
211
+	 * @throws InvalidArgumentException
212
+	 */
213
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
214
+	{
215
+		if (!is_array($organized_files)) {
216
+			throw new UnexpectedValueException(
217
+				sprintf(
218
+					esc_html__(
219
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
220
+						'event_espresso'
221
+					),
222
+					(string) $organized_files
223
+				)
224
+			);
225
+		}
226
+		foreach ($organized_files as $key => $value) {
227
+			$this_input_name_parts = $name_parts_so_far;
228
+			array_push(
229
+				$this_input_name_parts,
230
+				$key
231
+			);
232
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
233
+				$html_name = $this->inputNameFromParts($this_input_name_parts);
234
+				$this->file_objects->add(
235
+					new FileSubmission(
236
+						$value['name'],
237
+						$value['tmp_name'],
238
+						$value['size'],
239
+						$value['error']
240
+					),
241
+					$html_name
242
+				);
243
+			} else {
244
+				$this->createFileObjects($value, $this_input_name_parts);
245
+			}
246
+		}
247
+	}
248 248
 
249
-    /**
250
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
251
-     * and returns the HTML name for it, "my[great][file][input1]"
252
-     * @since $VID:$
253
-     * @param $parts
254
-     * @throws UnexpectedValueException
255
-     */
256
-    protected function inputNameFromParts($parts)
257
-    {
258
-        if (!is_array($parts)) {
259
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
260
-        }
261
-        $generated_string = '';
262
-        foreach ($parts as $part) {
263
-            if ($generated_string === '') {
264
-                $generated_string = (string) $part;
265
-            } else {
266
-                $generated_string .= '[' . (string) $part . ']';
267
-            }
268
-        }
269
-        return $generated_string;
270
-    }
249
+	/**
250
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
251
+	 * and returns the HTML name for it, "my[great][file][input1]"
252
+	 * @since $VID:$
253
+	 * @param $parts
254
+	 * @throws UnexpectedValueException
255
+	 */
256
+	protected function inputNameFromParts($parts)
257
+	{
258
+		if (!is_array($parts)) {
259
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
260
+		}
261
+		$generated_string = '';
262
+		foreach ($parts as $part) {
263
+			if ($generated_string === '') {
264
+				$generated_string = (string) $part;
265
+			} else {
266
+				$generated_string .= '[' . (string) $part . ']';
267
+			}
268
+		}
269
+		return $generated_string;
270
+	}
271 271
 
272
-    /**
273
-     * Gets the input by the indicated $name_parts.
274
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
275
-     * should be `['my', 'great', 'file', 'input1']`.
276
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
277
-     * @since $VID:$
278
-     * @param $name_parts
279
-     * @throws UnexpectedValueException
280
-     * @return FileSubmissionInterface
281
-     */
282
-    public function getFileObjectFromNameParts($name_parts)
283
-    {
284
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
285
-    }
272
+	/**
273
+	 * Gets the input by the indicated $name_parts.
274
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
275
+	 * should be `['my', 'great', 'file', 'input1']`.
276
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
277
+	 * @since $VID:$
278
+	 * @param $name_parts
279
+	 * @throws UnexpectedValueException
280
+	 * @return FileSubmissionInterface
281
+	 */
282
+	public function getFileObjectFromNameParts($name_parts)
283
+	{
284
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
285
+	}
286 286
 
287
-    /**
288
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
289
-     * @since $VID:$
290
-     * @param $html_name
291
-     * @return mixed
292
-     * @throws InvalidArgumentException
293
-     * @throws UnexpectedValueException
294
-     */
295
-    public function getFileObject($html_name)
296
-    {
297
-        return $this->getFileObjects()->get($html_name);
298
-    }
287
+	/**
288
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
289
+	 * @since $VID:$
290
+	 * @param $html_name
291
+	 * @return mixed
292
+	 * @throws InvalidArgumentException
293
+	 * @throws UnexpectedValueException
294
+	 */
295
+	public function getFileObject($html_name)
296
+	{
297
+		return $this->getFileObjects()->get($html_name);
298
+	}
299 299
 }
300 300
 // End of file FilesDataHandler.php
301 301
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     protected function isStrangeFilesArray($files_data)
116 116
     {
117
-        if (!is_array($files_data)) {
117
+        if ( ! is_array($files_data)) {
118 118
             throw new UnexpectedValueException(
119 119
                 sprintf(
120 120
                     esc_html__(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             );
127 127
         }
128 128
         $first_value = reset($files_data);
129
-        if (!is_array($first_value)) {
129
+        if ( ! is_array($first_value)) {
130 130
             throw new UnexpectedValueException(
131 131
                 sprintf(
132 132
                     esc_html__(
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
         $sane_files_array = [];
161 161
         foreach ($files_data as $top_level_name => $top_level_children) {
162 162
             $sub_array = [];
163
-            $sane_files_array[ $top_level_name ] = [];
163
+            $sane_files_array[$top_level_name] = [];
164 164
             foreach ($top_level_children as $file_data_part => $second_level_children) {
165 165
                 foreach ($second_level_children as $next_level_name => $sub_values) {
166
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
166
+                    $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part);
167 167
                 }
168
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
168
+                $sane_files_array[$top_level_name] = array_replace_recursive(
169 169
                     $sub_array,
170
-                    $sane_files_array[ $top_level_name ]
170
+                    $sane_files_array[$top_level_name]
171 171
                 );
172 172
             }
173 173
         }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function organizeFilesData($data, $type)
186 186
     {
187
-        if (! is_array($data)) {
187
+        if ( ! is_array($data)) {
188 188
             return [
189 189
                 $type => $data
190 190
             ];
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
         $organized_data = [];
193 193
         foreach ($data as $input_name_part => $sub_inputs_or_value) {
194 194
             if (is_array($sub_inputs_or_value)) {
195
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
195
+                $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type);
196 196
             } else {
197
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
197
+                $organized_data[$input_name_part][$type] = $sub_inputs_or_value;
198 198
             }
199 199
         }
200 200
         return $organized_data;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
214 214
     {
215
-        if (!is_array($organized_files)) {
215
+        if ( ! is_array($organized_files)) {
216 216
             throw new UnexpectedValueException(
217 217
                 sprintf(
218 218
                     esc_html__(
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      */
256 256
     protected function inputNameFromParts($parts)
257 257
     {
258
-        if (!is_array($parts)) {
258
+        if ( ! is_array($parts)) {
259 259
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
260 260
         }
261 261
         $generated_string = '';
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             if ($generated_string === '') {
264 264
                 $generated_string = (string) $part;
265 265
             } else {
266
-                $generated_string .= '[' . (string) $part . ']';
266
+                $generated_string .= '['.(string) $part.']';
267 267
             }
268 268
         }
269 269
         return $generated_string;
Please login to merge, or discard this patch.
strategies/validation/EE_Text_Validation_Strategy.strategy.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -10,53 +10,53 @@
 block discarded – undo
10 10
 class EE_Text_Validation_Strategy extends EE_Validation_Strategy_Base
11 11
 {
12 12
 
13
-    protected $_regex = null;
14
-    /**
15
-     *
16
-     * @param string $validation_error_message
17
-     * @param string $regex a PHP regex; the javascript regex will be derived from this
18
-     */
19
-    public function __construct($validation_error_message = null, $regex = null)
20
-    {
21
-        $this->_regex = $regex;
22
-        parent::__construct($validation_error_message);
23
-    }
13
+	protected $_regex = null;
14
+	/**
15
+	 *
16
+	 * @param string $validation_error_message
17
+	 * @param string $regex a PHP regex; the javascript regex will be derived from this
18
+	 */
19
+	public function __construct($validation_error_message = null, $regex = null)
20
+	{
21
+		$this->_regex = $regex;
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        $string_normalized_value = (string) $normalized_value;
31
-        if ($this->_regex &&  $string_normalized_value) {
32
-            if (! preg_match($this->_regex, $string_normalized_value)) {
33
-                throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
34
-            }
35
-        }
36
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		$string_normalized_value = (string) $normalized_value;
31
+		if ($this->_regex &&  $string_normalized_value) {
32
+			if (! preg_match($this->_regex, $string_normalized_value)) {
33
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
34
+			}
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @return array
40
-     */
41
-    public function get_jquery_validation_rule_array()
42
-    {
43
-        if ($this->_regex !== null) {
44
-            return array( 'regex'=> $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
45
-        } else {
46
-            return array();
47
-        }
48
-    }
38
+	/**
39
+	 * @return array
40
+	 */
41
+	public function get_jquery_validation_rule_array()
42
+	{
43
+		if ($this->_regex !== null) {
44
+			return array( 'regex'=> $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
45
+		} else {
46
+			return array();
47
+		}
48
+	}
49 49
 
50 50
 /**
51 51
  * Translates a PHP regex into a javscript regex (eg, PHP needs separate delimieters, whereas
52 52
  * javscript does not
53 53
  * @return string
54 54
  */
55
-    public function regex_js()
56
-    {
57
-        // first character must be the delimiter
58
-        $delimeter = $this->_regex[0];
59
-        $last_occurence_of_delimieter = strrpos($this->_regex, $delimeter);
60
-        return substr($this->_regex, 1, $last_occurence_of_delimieter - 1);
61
-    }
55
+	public function regex_js()
56
+	{
57
+		// first character must be the delimiter
58
+		$delimeter = $this->_regex[0];
59
+		$last_occurence_of_delimieter = strrpos($this->_regex, $delimeter);
60
+		return substr($this->_regex, 1, $last_occurence_of_delimieter - 1);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     public function validate($normalized_value)
29 29
     {
30 30
         $string_normalized_value = (string) $normalized_value;
31
-        if ($this->_regex &&  $string_normalized_value) {
32
-            if (! preg_match($this->_regex, $string_normalized_value)) {
31
+        if ($this->_regex && $string_normalized_value) {
32
+            if ( ! preg_match($this->_regex, $string_normalized_value)) {
33 33
                 throw new EE_Validation_Error($this->get_validation_error_message(), 'regex');
34 34
             }
35 35
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function get_jquery_validation_rule_array()
42 42
     {
43 43
         if ($this->_regex !== null) {
44
-            return array( 'regex'=> $this->regex_js(), 'messages' => array( 'regex' => $this->get_validation_error_message() ) );
44
+            return array('regex'=> $this->regex_js(), 'messages' => array('regex' => $this->get_validation_error_message()));
45 45
         } else {
46 46
             return array();
47 47
         }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Indentation   +1236 added lines, -1236 removed lines patch added patch discarded remove patch
@@ -11,1240 +11,1240 @@
 block discarded – undo
11 11
 abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable
12 12
 {
13 13
 
14
-    /**
15
-     * the input's name attribute
16
-     *
17
-     * @var string
18
-     */
19
-    protected $_html_name;
20
-
21
-    /**
22
-     * id for the html label tag
23
-     *
24
-     * @var string
25
-     */
26
-    protected $_html_label_id;
27
-
28
-    /**
29
-     * class for teh html label tag
30
-     *
31
-     * @var string
32
-     */
33
-    protected $_html_label_class;
34
-
35
-    /**
36
-     * any additional html attributes that you may want to add
37
-     *
38
-     * @var string
39
-     */
40
-    protected $_html_other_attributes;
41
-
42
-    /**
43
-     * style for teh html label tag
44
-     *
45
-     * @var string
46
-     */
47
-    protected $_html_label_style;
48
-
49
-    /**
50
-     * text to be placed in the html label
51
-     *
52
-     * @var string
53
-     */
54
-    protected $_html_label_text;
55
-
56
-    /**
57
-     * the full html label. If used, all other html_label_* properties are invalid
58
-     *
59
-     * @var string
60
-     */
61
-    protected $_html_label;
62
-
63
-    /**
64
-     * HTML to use for help text (normally placed below form input), in a span which normally
65
-     * has a class of 'description'
66
-     *
67
-     * @var string
68
-     */
69
-    protected $_html_help_text;
70
-
71
-    /**
72
-     * CSS classes for displaying the help span
73
-     *
74
-     * @var string
75
-     */
76
-    protected $_html_help_class = 'description';
77
-
78
-    /**
79
-     * CSS to put in the style attribute on the help span
80
-     *
81
-     * @var string
82
-     */
83
-    protected $_html_help_style;
84
-
85
-    /**
86
-     * Stores whether or not this input's response is required.
87
-     * Because certain styling elements may also want to know that this
88
-     * input is required etc.
89
-     *
90
-     * @var boolean
91
-     */
92
-    protected $_required;
93
-
94
-    /**
95
-     * css class added to required inputs
96
-     *
97
-     * @var string
98
-     */
99
-    protected $_required_css_class = 'ee-required';
100
-
101
-    /**
102
-     * css styles applied to button type inputs
103
-     *
104
-     * @var string
105
-     */
106
-    protected $_button_css_attributes;
107
-
108
-    /**
109
-     * The raw data submitted for this, like in the $_POST super global.
110
-     * Generally unsafe for usage in client code
111
-     *
112
-     * @var mixed string or array
113
-     */
114
-    protected $_raw_value;
115
-
116
-    /**
117
-     * Value normalized according to the input's normalization strategy.
118
-     * The normalization strategy dictates whether this is a string, int, float,
119
-     * boolean, or array of any of those.
120
-     *
121
-     * @var mixed
122
-     */
123
-    protected $_normalized_value;
124
-
125
-
126
-    /**
127
-     * Normalized default value either initially set on the input, or provided by calling
128
-     * set_default().
129
-     * @var mixed
130
-     */
131
-    protected $_default;
132
-
133
-    /**
134
-     * Strategy used for displaying this field.
135
-     * Child classes must use _get_display_strategy to access it.
136
-     *
137
-     * @var EE_Display_Strategy_Base
138
-     */
139
-    private $_display_strategy;
140
-
141
-    /**
142
-     * Gets all the validation strategies used on this field
143
-     *
144
-     * @var EE_Validation_Strategy_Base[]
145
-     */
146
-    private $_validation_strategies = array();
147
-
148
-    /**
149
-     * The normalization strategy for this field
150
-     *
151
-     * @var EE_Normalization_Strategy_Base
152
-     */
153
-    private $_normalization_strategy;
154
-
155
-    /**
156
-     * Strategy for removing sensitive data after we're done with the form input
157
-     *
158
-     * @var EE_Sensitive_Data_Removal_Base
159
-     */
160
-    protected $_sensitive_data_removal_strategy;
161
-
162
-    /**
163
-     * Whether this input has been disabled or not.
164
-     * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
165
-     * (Client-side code that wants to dynamically disable it must also add this hidden input).
166
-     * When the form is submitted, if the input is disabled in the PHP formsection, then input is ignored.
167
-     * If the input is missing from the $_REQUEST data but the hidden input indicating the input is disabled, then the input is again ignored.
168
-     *
169
-     * @var boolean
170
-     */
171
-    protected $disabled = false;
172
-
173
-
174
-
175
-    /**
176
-     * @param array                         $input_args       {
177
-     * @type string                         $html_name        the html name for the input
178
-     * @type string                         $html_label_id    the id attribute to give to the html label tag
179
-     * @type string                         $html_label_class the class attribute to give to the html label tag
180
-     * @type string                         $html_label_style the style attribute to give ot teh label tag
181
-     * @type string                         $html_label_text  the text to put in the label tag
182
-     * @type string                         $html_label       the full html label. If used,
183
-     *                                                        all other html_label_* args are invalid
184
-     * @type string                         $html_help_text   text to put in help element
185
-     * @type string                         $html_help_style  style attribute to give to teh help element
186
-     * @type string                         $html_help_class  class attribute to give to the help element
187
-     * @type string                         $default          default value NORMALIZED (eg, if providing the default
188
-     *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
189
-     * @type EE_Display_Strategy_Base       $display          strategy
190
-     * @type EE_Normalization_Strategy_Base $normalization_strategy
191
-     * @type EE_Validation_Strategy_Base[]  $validation_strategies
192
-     * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
193
-     *                                                    and sets the normalization strategy to the Null normalization. This is good
194
-     *                                                    when you want the input to be totally ignored server-side (like when using
195
-     *                                                    React.js form inputs)
196
-     *                                                        }
197
-     */
198
-    public function __construct($input_args = array())
199
-    {
200
-        $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
201
-        // the following properties must be cast as arrays
202
-        if (isset($input_args['validation_strategies'])) {
203
-            foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
204
-                if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
205
-                    $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
206
-                }
207
-            }
208
-            unset($input_args['validation_strategies']);
209
-        }
210
-        if (isset($input_args['ignore_input'])) {
211
-            $this->_validation_strategies = array();
212
-        }
213
-        // loop thru incoming options
214
-        foreach ($input_args as $key => $value) {
215
-            // add underscore to $key to match property names
216
-            $_key = '_' . $key;
217
-            if (property_exists($this, $_key)) {
218
-                $this->{$_key} = $value;
219
-            }
220
-        }
221
-        // ensure that "required" is set correctly
222
-        $this->set_required(
223
-            $this->_required,
224
-            isset($input_args['required_validation_error_message'])
225
-            ? $input_args['required_validation_error_message']
226
-            : null
227
-        );
228
-        // $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
229
-        $this->_display_strategy->_construct_finalize($this);
230
-        foreach ($this->_validation_strategies as $validation_strategy) {
231
-            $validation_strategy->_construct_finalize($this);
232
-        }
233
-        if (isset($input_args['ignore_input'])) {
234
-            $this->_normalization_strategy = new EE_Null_Normalization();
235
-        }
236
-        if (! $this->_normalization_strategy) {
237
-                $this->_normalization_strategy = new EE_Text_Normalization();
238
-        }
239
-        $this->_normalization_strategy->_construct_finalize($this);
240
-        // at least we can use the normalization strategy to populate the default
241
-        if (isset($input_args['default'])) {
242
-            $this->set_default($input_args['default']);
243
-            unset($input_args['default']);
244
-        }
245
-        if (! $this->_sensitive_data_removal_strategy) {
246
-            $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
247
-        }
248
-        $this->_sensitive_data_removal_strategy->_construct_finalize($this);
249
-        parent::__construct($input_args);
250
-    }
251
-
252
-
253
-
254
-    /**
255
-     * Sets the html_name to its default value, if none was specified in teh constructor.
256
-     * Calculation involves using the name and the parent's html_name
257
-     *
258
-     * @throws \EE_Error
259
-     */
260
-    protected function _set_default_html_name_if_empty()
261
-    {
262
-        if (! $this->_html_name) {
263
-            $this->_html_name = $this->name();
264
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
265
-                $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
266
-            }
267
-        }
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * @param $parent_form_section
274
-     * @param $name
275
-     * @throws \EE_Error
276
-     */
277
-    public function _construct_finalize($parent_form_section, $name)
278
-    {
279
-        parent::_construct_finalize($parent_form_section, $name);
280
-        if ($this->_html_label === null && $this->_html_label_text === null) {
281
-            $this->_html_label_text = ucwords(str_replace("_", " ", $name));
282
-        }
283
-        do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * Returns the strategy for displaying this form input. If none is set, throws an exception.
290
-     *
291
-     * @return EE_Display_Strategy_Base
292
-     * @throws EE_Error
293
-     */
294
-    protected function _get_display_strategy()
295
-    {
296
-        $this->ensure_construct_finalized_called();
297
-        if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
298
-            throw new EE_Error(
299
-                sprintf(
300
-                    __(
301
-                        "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
302
-                        "event_espresso"
303
-                    ),
304
-                    $this->html_name(),
305
-                    $this->html_id()
306
-                )
307
-            );
308
-        } else {
309
-            return $this->_display_strategy;
310
-        }
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * Sets the display strategy.
317
-     *
318
-     * @param EE_Display_Strategy_Base $strategy
319
-     */
320
-    protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
321
-    {
322
-        $this->_display_strategy = $strategy;
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * Sets the sanitization strategy
329
-     *
330
-     * @param EE_Normalization_Strategy_Base $strategy
331
-     */
332
-    protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
333
-    {
334
-        $this->_normalization_strategy = $strategy;
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     * Gets sensitive_data_removal_strategy
341
-     *
342
-     * @return EE_Sensitive_Data_Removal_Base
343
-     */
344
-    public function get_sensitive_data_removal_strategy()
345
-    {
346
-        return $this->_sensitive_data_removal_strategy;
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * Sets sensitive_data_removal_strategy
353
-     *
354
-     * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
355
-     * @return boolean
356
-     */
357
-    public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
358
-    {
359
-        $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * Gets the display strategy for this input
366
-     *
367
-     * @return EE_Display_Strategy_Base
368
-     */
369
-    public function get_display_strategy()
370
-    {
371
-        return $this->_display_strategy;
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * Overwrites the display strategy
378
-     *
379
-     * @param EE_Display_Strategy_Base $display_strategy
380
-     */
381
-    public function set_display_strategy($display_strategy)
382
-    {
383
-        $this->_display_strategy = $display_strategy;
384
-        $this->_display_strategy->_construct_finalize($this);
385
-    }
386
-
387
-
388
-
389
-    /**
390
-     * Gets the normalization strategy set on this input
391
-     *
392
-     * @return EE_Normalization_Strategy_Base
393
-     */
394
-    public function get_normalization_strategy()
395
-    {
396
-        return $this->_normalization_strategy;
397
-    }
398
-
399
-
400
-
401
-    /**
402
-     * Overwrites the normalization strategy
403
-     *
404
-     * @param EE_Normalization_Strategy_Base $normalization_strategy
405
-     */
406
-    public function set_normalization_strategy($normalization_strategy)
407
-    {
408
-        $this->_normalization_strategy = $normalization_strategy;
409
-        $this->_normalization_strategy->_construct_finalize($this);
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * Returns all teh validation strategies which apply to this field, numerically indexed
416
-     *
417
-     * @return EE_Validation_Strategy_Base[]
418
-     */
419
-    public function get_validation_strategies()
420
-    {
421
-        return $this->_validation_strategies;
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * Adds this strategy to the field so it will be used in both JS validation and server-side validation
428
-     *
429
-     * @param EE_Validation_Strategy_Base $validation_strategy
430
-     * @return void
431
-     */
432
-    protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
433
-    {
434
-        $validation_strategy->_construct_finalize($this);
435
-        $this->_validation_strategies[] = $validation_strategy;
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * Adds a new validation strategy onto the form input
442
-     *
443
-     * @param EE_Validation_Strategy_Base $validation_strategy
444
-     * @return void
445
-     */
446
-    public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
447
-    {
448
-        $this->_add_validation_strategy($validation_strategy);
449
-    }
450
-
451
-
452
-
453
-    /**
454
-     * The classname of the validation strategy to remove
455
-     *
456
-     * @param string $validation_strategy_classname
457
-     */
458
-    public function remove_validation_strategy($validation_strategy_classname)
459
-    {
460
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
461
-            if ($validation_strategy instanceof $validation_strategy_classname
462
-                || is_subclass_of($validation_strategy, $validation_strategy_classname)
463
-            ) {
464
-                unset($this->_validation_strategies[ $key ]);
465
-            }
466
-        }
467
-    }
468
-
469
-
470
-
471
-    /**
472
-     * returns true if input employs any of the validation strategy defined by the supplied array of classnames
473
-     *
474
-     * @param array $validation_strategy_classnames
475
-     * @return bool
476
-     */
477
-    public function has_validation_strategy($validation_strategy_classnames)
478
-    {
479
-        $validation_strategy_classnames = is_array($validation_strategy_classnames)
480
-            ? $validation_strategy_classnames
481
-            : array($validation_strategy_classnames);
482
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
483
-            if (in_array($key, $validation_strategy_classnames)) {
484
-                return true;
485
-            }
486
-        }
487
-        return false;
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     * Gets the HTML
494
-     *
495
-     * @return string
496
-     */
497
-    public function get_html()
498
-    {
499
-        return $this->_parent_section->get_html_for_input($this);
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * Gets the HTML for the input itself (no label or errors) according to the
506
-     * input's display strategy
507
-     * Makes sure the JS and CSS are enqueued for it
508
-     *
509
-     * @return string
510
-     * @throws \EE_Error
511
-     */
512
-    public function get_html_for_input()
513
-    {
514
-        return $this->_form_html_filter
515
-            ? $this->_form_html_filter->filterHtml(
516
-                $this->_get_display_strategy()->display(),
517
-                $this
518
-            )
519
-            : $this->_get_display_strategy()->display();
520
-    }
521
-
522
-
523
-
524
-    /**
525
-     * @return string
526
-     */
527
-    public function html_other_attributes()
528
-    {
529
-        return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : '';
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * @param string $html_other_attributes
536
-     */
537
-    public function set_html_other_attributes($html_other_attributes)
538
-    {
539
-        $this->_html_other_attributes = $html_other_attributes;
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * Gets the HTML for displaying the label for this form input
546
-     * according to the form section's layout strategy
547
-     *
548
-     * @return string
549
-     */
550
-    public function get_html_for_label()
551
-    {
552
-        return $this->_parent_section->get_layout_strategy()->display_label($this);
553
-    }
554
-
555
-
556
-
557
-    /**
558
-     * Gets the HTML for displaying the errors section for this form input
559
-     * according to the form section's layout strategy
560
-     *
561
-     * @return string
562
-     */
563
-    public function get_html_for_errors()
564
-    {
565
-        return $this->_parent_section->get_layout_strategy()->display_errors($this);
566
-    }
567
-
568
-
569
-
570
-    /**
571
-     * Gets the HTML for displaying the help text for this form input
572
-     * according to the form section's layout strategy
573
-     *
574
-     * @return string
575
-     */
576
-    public function get_html_for_help()
577
-    {
578
-        return $this->_parent_section->get_layout_strategy()->display_help_text($this);
579
-    }
580
-
581
-
582
-
583
-    /**
584
-     * Validates the input's sanitized value (assumes _sanitize() has already been called)
585
-     * and returns whether or not the form input's submitted value is value
586
-     *
587
-     * @return boolean
588
-     */
589
-    protected function _validate()
590
-    {
591
-        if ($this->isDisabled()) {
592
-            return true;
593
-        }
594
-        foreach ($this->_validation_strategies as $validation_strategy) {
595
-            if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
596
-                try {
597
-                    $validation_strategy->validate($this->normalized_value());
598
-                } catch (EE_Validation_Error $e) {
599
-                    $this->add_validation_error($e);
600
-                }
601
-            }
602
-        }
603
-        if ($this->get_validation_errors()) {
604
-            return false;
605
-        } else {
606
-            return true;
607
-        }
608
-    }
609
-
610
-
611
-
612
-    /**
613
-     * Performs basic sanitization on this value. But what sanitization can be performed anyways?
614
-     * This value MIGHT be allowed to have tags, so we can't really remove them.
615
-     *
616
-     * @param string $value
617
-     * @return null|string
618
-     */
619
-    protected function _sanitize($value)
620
-    {
621
-        return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
622
-    }
623
-
624
-
625
-
626
-    /**
627
-     * Picks out the form value that relates to this form input,
628
-     * and stores it as the sanitized value on the form input, and sets the normalized value.
629
-     * Returns whether or not any validation errors occurred
630
-     *
631
-     * @param array $req_data like $_POST
632
-     * @return boolean whether or not there was an error
633
-     * @throws \EE_Error
634
-     */
635
-    protected function _normalize($req_data)
636
-    {
637
-        // any existing validation errors don't apply so clear them
638
-        $this->_validation_errors = array();
639
-        // if the input is disabled, ignore whatever input was sent in
640
-        if ($this->isDisabled()) {
641
-            $this->_set_raw_value(null);
642
-            $this->_set_normalized_value($this->get_default());
643
-            return false;
644
-        }
645
-        try {
646
-            $raw_input = $this->find_form_data_for_this_section($req_data);
647
-            // super simple sanitization for now
648
-            if (is_array($raw_input)) {
649
-                $raw_value = array();
650
-                foreach ($raw_input as $key => $value) {
651
-                    $raw_value[ $key ] = $this->_sanitize($value);
652
-                }
653
-                $this->_set_raw_value($raw_value);
654
-            } else {
655
-                $this->_set_raw_value($this->_sanitize($raw_input));
656
-            }
657
-            // we want to mostly leave the input alone in case we need to re-display it to the user
658
-            $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
659
-            return false;
660
-        } catch (EE_Validation_Error $e) {
661
-            $this->add_validation_error($e);
662
-            return true;
663
-        }
664
-    }
665
-
666
-
667
-
668
-    /**
669
-     * @return string
670
-     */
671
-    public function html_name()
672
-    {
673
-        $this->_set_default_html_name_if_empty();
674
-        return $this->_html_name;
675
-    }
676
-
677
-
678
-
679
-    /**
680
-     * @return string
681
-     */
682
-    public function html_label_id()
683
-    {
684
-        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
685
-    }
686
-
687
-
688
-
689
-    /**
690
-     * @return string
691
-     */
692
-    public function html_label_class()
693
-    {
694
-        return $this->_html_label_class;
695
-    }
696
-
697
-
698
-
699
-    /**
700
-     * @return string
701
-     */
702
-    public function html_label_style()
703
-    {
704
-        return $this->_html_label_style;
705
-    }
706
-
707
-
708
-
709
-    /**
710
-     * @return string
711
-     */
712
-    public function html_label_text()
713
-    {
714
-        return $this->_html_label_text;
715
-    }
716
-
717
-
718
-
719
-    /**
720
-     * @return string
721
-     */
722
-    public function html_help_text()
723
-    {
724
-        return $this->_html_help_text;
725
-    }
726
-
727
-
728
-
729
-    /**
730
-     * @return string
731
-     */
732
-    public function html_help_class()
733
-    {
734
-        return $this->_html_help_class;
735
-    }
736
-
737
-
738
-
739
-    /**
740
-     * @return string
741
-     */
742
-    public function html_help_style()
743
-    {
744
-        return $this->_html_style;
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
751
-     * Please note that almost all client code should instead use the normalized_value;
752
-     * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
753
-     * mostly by escaping quotes)
754
-     * Note, we do not store the exact original value sent in the user's request because
755
-     * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
756
-     * in which case, we would have stored the malicious content to our database.
757
-     *
758
-     * @return string
759
-     */
760
-    public function raw_value()
761
-    {
762
-        return $this->_raw_value;
763
-    }
764
-
765
-
766
-
767
-    /**
768
-     * Returns a string safe to usage in form inputs when displaying, because
769
-     * it escapes all html entities
770
-     *
771
-     * @return string
772
-     */
773
-    public function raw_value_in_form()
774
-    {
775
-        return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
776
-    }
777
-
778
-
779
-
780
-    /**
781
-     * returns the value after it's been sanitized, and then converted into it's proper type
782
-     * in PHP. Eg, a string, an int, an array,
783
-     *
784
-     * @return mixed
785
-     */
786
-    public function normalized_value()
787
-    {
788
-        return $this->_normalized_value;
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     * Returns the normalized value is a presentable way. By default this is just
795
-     * the normalized value by itself, but it can be overridden for when that's not
796
-     * the best thing to display
797
-     *
798
-     * @return string
799
-     */
800
-    public function pretty_value()
801
-    {
802
-        return $this->_normalized_value;
803
-    }
804
-
805
-
806
-
807
-    /**
808
-     * When generating the JS for the jquery validation rules like<br>
809
-     * <code>$( "#myform" ).validate({
810
-     * rules: {
811
-     * password: "required",
812
-     * password_again: {
813
-     * equalTo: "#password"
814
-     * }
815
-     * }
816
-     * });</code>
817
-     * if this field had the name 'password_again', it should return
818
-     * <br><code>password_again: {
819
-     * equalTo: "#password"
820
-     * }</code>
821
-     *
822
-     * @return array
823
-     */
824
-    public function get_jquery_validation_rules()
825
-    {
826
-        $jquery_validation_js = array();
827
-        $jquery_validation_rules = array();
828
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
829
-            $jquery_validation_rules = array_replace_recursive(
830
-                $jquery_validation_rules,
831
-                $validation_strategy->get_jquery_validation_rule_array()
832
-            );
833
-        }
834
-        if (! empty($jquery_validation_rules)) {
835
-            foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
836
-                $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
837
-            }
838
-        }
839
-        return $jquery_validation_js;
840
-    }
841
-
842
-
843
-
844
-    /**
845
-     * Sets the input's default value for use in displaying in the form. Note: value should be
846
-     * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
847
-     *
848
-     * @param mixed $value
849
-     * @return void
850
-     */
851
-    public function set_default($value)
852
-    {
853
-        $this->_default = $value;
854
-        $this->_set_normalized_value($value);
855
-        $this->_set_raw_value($value);
856
-    }
857
-
858
-
859
-
860
-    /**
861
-     * Sets the normalized value on this input
862
-     *
863
-     * @param mixed $value
864
-     */
865
-    protected function _set_normalized_value($value)
866
-    {
867
-        $this->_normalized_value = $value;
868
-    }
869
-
870
-
871
-
872
-    /**
873
-     * Sets the raw value on this input (ie, exactly as the user submitted it)
874
-     *
875
-     * @param mixed $value
876
-     */
877
-    protected function _set_raw_value($value)
878
-    {
879
-        $this->_raw_value = $this->_normalization_strategy->unnormalize($value);
880
-    }
881
-
882
-
883
-
884
-    /**
885
-     * Sets the HTML label text after it has already been defined
886
-     *
887
-     * @param string $label
888
-     * @return void
889
-     */
890
-    public function set_html_label_text($label)
891
-    {
892
-        $this->_html_label_text = $label;
893
-    }
894
-
895
-
896
-
897
-    /**
898
-     * Sets whether or not this field is required, and adjusts the validation strategy.
899
-     * If you want to use the EE_Conditionally_Required_Validation_Strategy,
900
-     * please add it as a validation strategy using add_validation_strategy as normal
901
-     *
902
-     * @param boolean $required boolean
903
-     * @param null    $required_text
904
-     */
905
-    public function set_required($required = true, $required_text = null)
906
-    {
907
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
908
-        // whether $required is a string or a boolean, we want to add a required validation strategy
909
-        if ($required) {
910
-            $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
911
-        } else {
912
-            $this->remove_validation_strategy('EE_Required_Validation_Strategy');
913
-        }
914
-        $this->_required = $required;
915
-    }
916
-
917
-
918
-
919
-    /**
920
-     * Returns whether or not this field is required
921
-     *
922
-     * @return boolean
923
-     */
924
-    public function required()
925
-    {
926
-        return $this->_required;
927
-    }
928
-
929
-
930
-
931
-    /**
932
-     * @param string $required_css_class
933
-     */
934
-    public function set_required_css_class($required_css_class)
935
-    {
936
-        $this->_required_css_class = $required_css_class;
937
-    }
938
-
939
-
940
-
941
-    /**
942
-     * @return string
943
-     */
944
-    public function required_css_class()
945
-    {
946
-        return $this->_required_css_class;
947
-    }
948
-
949
-
950
-
951
-    /**
952
-     * @param bool $add_required
953
-     * @return string
954
-     */
955
-    public function html_class($add_required = false)
956
-    {
957
-        return $add_required && $this->required()
958
-            ? $this->required_css_class() . ' ' . $this->_html_class
959
-            : $this->_html_class;
960
-    }
961
-
962
-
963
-    /**
964
-     * Sets the help text, in case
965
-     *
966
-     * @param string $text
967
-     */
968
-    public function set_html_help_text($text)
969
-    {
970
-        $this->_html_help_text = $text;
971
-    }
972
-
973
-
974
-
975
-    /**
976
-     * Uses the sensitive data removal strategy to remove the sensitive data from this
977
-     * input. If there is any kind of sensitive data removal on this input, we clear
978
-     * out the raw value completely
979
-     *
980
-     * @return void
981
-     */
982
-    public function clean_sensitive_data()
983
-    {
984
-        // if we do ANY kind of sensitive data removal on this, then just clear out the raw value
985
-        // if we need more logic than this we'll make a strategy for it
986
-        if ($this->_sensitive_data_removal_strategy
987
-            && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
988
-        ) {
989
-            $this->_set_raw_value(null);
990
-        }
991
-        // and clean the normalized value according to the appropriate strategy
992
-        $this->_set_normalized_value(
993
-            $this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
994
-                $this->_normalized_value
995
-            )
996
-        );
997
-    }
998
-
999
-
1000
-
1001
-    /**
1002
-     * @param bool   $primary
1003
-     * @param string $button_size
1004
-     * @param string $other_attributes
1005
-     */
1006
-    public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1007
-    {
1008
-        $button_css_attributes = 'button';
1009
-        $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1010
-        switch ($button_size) {
1011
-            case 'xs':
1012
-            case 'extra-small':
1013
-                $button_css_attributes .= ' button-xs';
1014
-                break;
1015
-            case 'sm':
1016
-            case 'small':
1017
-                $button_css_attributes .= ' button-sm';
1018
-                break;
1019
-            case 'lg':
1020
-            case 'large':
1021
-                $button_css_attributes .= ' button-lg';
1022
-                break;
1023
-            case 'block':
1024
-                $button_css_attributes .= ' button-block';
1025
-                break;
1026
-            case 'md':
1027
-            case 'medium':
1028
-            default:
1029
-                $button_css_attributes .= '';
1030
-        }
1031
-        $this->_button_css_attributes .= ! empty($other_attributes)
1032
-            ? $button_css_attributes . ' ' . $other_attributes
1033
-            : $button_css_attributes;
1034
-    }
1035
-
1036
-
1037
-
1038
-    /**
1039
-     * @return string
1040
-     */
1041
-    public function button_css_attributes()
1042
-    {
1043
-        if (empty($this->_button_css_attributes)) {
1044
-            $this->set_button_css_attributes();
1045
-        }
1046
-        return $this->_button_css_attributes;
1047
-    }
1048
-
1049
-
1050
-
1051
-    /**
1052
-     * find_form_data_for_this_section
1053
-     * using this section's name and its parents, finds the value of the form data that corresponds to it.
1054
-     * For example, if this form section's HTML name is my_form[subform][form_input_1],
1055
-     * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1'].
1056
-     * (If that doesn't exist, we also check for this subsection's name
1057
-     * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].)
1058
-     * This function finds its value in the form.
1059
-     *
1060
-     * @param array $req_data
1061
-     * @return mixed whatever the raw value of this form section is in the request data
1062
-     * @throws \EE_Error
1063
-     */
1064
-    public function find_form_data_for_this_section($req_data)
1065
-    {
1066
-        $name_parts = $this->getInputNameParts();
1067
-        // now get the value for the input
1068
-        $value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1069
-        // check if this thing's name is at the TOP level of the request data
1070
-        if ($value === null && isset($req_data[ $this->name() ])) {
1071
-            $value = $req_data[ $this->name() ];
1072
-        }
1073
-        return $value;
1074
-    }
1075
-
1076
-
1077
-
1078
-    /**
1079
-     * If this input's name is something like "foo[bar][baz]"
1080
-     * returns an array like `array('foo','bar',baz')`
1081
-     * @return array
1082
-     */
1083
-    protected function getInputNameParts()
1084
-    {
1085
-        // break up the html name by "[]"
1086
-        if (strpos($this->html_name(), '[') !== false) {
1087
-            $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1088
-        } else {
1089
-            $before_any_brackets = $this->html_name();
1090
-        }
1091
-        // grab all of the segments
1092
-        preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1093
-        if (isset($matches[1]) && is_array($matches[1])) {
1094
-            $name_parts = $matches[1];
1095
-            array_unshift($name_parts, $before_any_brackets);
1096
-        } else {
1097
-            $name_parts = array($before_any_brackets);
1098
-        }
1099
-        return $name_parts;
1100
-    }
1101
-
1102
-
1103
-
1104
-    /**
1105
-     * @param array $html_name_parts
1106
-     * @param array $req_data
1107
-     * @return array | NULL
1108
-     */
1109
-    public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1110
-    {
1111
-        $first_part_to_consider = array_shift($html_name_parts);
1112
-        if (isset($req_data[ $first_part_to_consider ])) {
1113
-            if (empty($html_name_parts)) {
1114
-                return $req_data[ $first_part_to_consider ];
1115
-            } else {
1116
-                return $this->findRequestForSectionUsingNameParts(
1117
-                    $html_name_parts,
1118
-                    $req_data[ $first_part_to_consider ]
1119
-                );
1120
-            }
1121
-        } else {
1122
-            return null;
1123
-        }
1124
-    }
1125
-
1126
-
1127
-
1128
-    /**
1129
-     * Checks if this form input's data is in the request data
1130
-     *
1131
-     * @param array $req_data like $_POST
1132
-     * @return boolean
1133
-     * @throws \EE_Error
1134
-     */
1135
-    public function form_data_present_in($req_data = null)
1136
-    {
1137
-        if ($req_data === null) {
1138
-            $req_data = $_POST;
1139
-        }
1140
-        $checked_value = $this->find_form_data_for_this_section($req_data);
1141
-        if ($checked_value !== null) {
1142
-            return true;
1143
-        } else {
1144
-            return false;
1145
-        }
1146
-    }
1147
-
1148
-
1149
-
1150
-    /**
1151
-     * Overrides parent to add js data from validation and display strategies
1152
-     *
1153
-     * @param array $form_other_js_data
1154
-     * @return array
1155
-     */
1156
-    public function get_other_js_data($form_other_js_data = array())
1157
-    {
1158
-        $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
1159
-        return $form_other_js_data;
1160
-    }
1161
-
1162
-
1163
-
1164
-    /**
1165
-     * Gets other JS data for localization from this input's strategies, like
1166
-     * the validation strategies and the display strategy
1167
-     *
1168
-     * @param array $form_other_js_data
1169
-     * @return array
1170
-     */
1171
-    public function get_other_js_data_from_strategies($form_other_js_data = array())
1172
-    {
1173
-        $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1174
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1175
-            $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1176
-        }
1177
-        return $form_other_js_data;
1178
-    }
1179
-
1180
-
1181
-
1182
-    /**
1183
-     * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1184
-     *
1185
-     * @return void
1186
-     */
1187
-    public function enqueue_js()
1188
-    {
1189
-        // ask our display strategy and validation strategies if they have js to enqueue
1190
-        $this->enqueue_js_from_strategies();
1191
-    }
1192
-
1193
-
1194
-
1195
-    /**
1196
-     * Tells strategies when its ok to enqueue their js and css
1197
-     *
1198
-     * @return void
1199
-     */
1200
-    public function enqueue_js_from_strategies()
1201
-    {
1202
-        $this->get_display_strategy()->enqueue_js();
1203
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1204
-            $validation_strategy->enqueue_js();
1205
-        }
1206
-    }
1207
-
1208
-
1209
-
1210
-    /**
1211
-     * Gets the default value set on the input (not the current value, which may have been
1212
-     * changed because of a form submission). If no default was set, this us null.
1213
-     * @return mixed
1214
-     */
1215
-    public function get_default()
1216
-    {
1217
-        return $this->_default;
1218
-    }
1219
-
1220
-
1221
-
1222
-    /**
1223
-     * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1224
-     * and server-side if any input was received it will be ignored
1225
-     */
1226
-    public function disable($disable = true)
1227
-    {
1228
-        $disabled_attribute = ' disabled="disabled"';
1229
-        $this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1230
-        if ($this->disabled) {
1231
-            if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1232
-                $this->_other_html_attributes .= $disabled_attribute;
1233
-            }
1234
-            $this->_set_normalized_value($this->get_default());
1235
-        } else {
1236
-            $this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1237
-        }
1238
-    }
1239
-
1240
-
1241
-
1242
-    /**
1243
-     * Returns whether or not this input is currently disabled.
1244
-     * @return bool
1245
-     */
1246
-    public function isDisabled()
1247
-    {
1248
-        return $this->disabled;
1249
-    }
14
+	/**
15
+	 * the input's name attribute
16
+	 *
17
+	 * @var string
18
+	 */
19
+	protected $_html_name;
20
+
21
+	/**
22
+	 * id for the html label tag
23
+	 *
24
+	 * @var string
25
+	 */
26
+	protected $_html_label_id;
27
+
28
+	/**
29
+	 * class for teh html label tag
30
+	 *
31
+	 * @var string
32
+	 */
33
+	protected $_html_label_class;
34
+
35
+	/**
36
+	 * any additional html attributes that you may want to add
37
+	 *
38
+	 * @var string
39
+	 */
40
+	protected $_html_other_attributes;
41
+
42
+	/**
43
+	 * style for teh html label tag
44
+	 *
45
+	 * @var string
46
+	 */
47
+	protected $_html_label_style;
48
+
49
+	/**
50
+	 * text to be placed in the html label
51
+	 *
52
+	 * @var string
53
+	 */
54
+	protected $_html_label_text;
55
+
56
+	/**
57
+	 * the full html label. If used, all other html_label_* properties are invalid
58
+	 *
59
+	 * @var string
60
+	 */
61
+	protected $_html_label;
62
+
63
+	/**
64
+	 * HTML to use for help text (normally placed below form input), in a span which normally
65
+	 * has a class of 'description'
66
+	 *
67
+	 * @var string
68
+	 */
69
+	protected $_html_help_text;
70
+
71
+	/**
72
+	 * CSS classes for displaying the help span
73
+	 *
74
+	 * @var string
75
+	 */
76
+	protected $_html_help_class = 'description';
77
+
78
+	/**
79
+	 * CSS to put in the style attribute on the help span
80
+	 *
81
+	 * @var string
82
+	 */
83
+	protected $_html_help_style;
84
+
85
+	/**
86
+	 * Stores whether or not this input's response is required.
87
+	 * Because certain styling elements may also want to know that this
88
+	 * input is required etc.
89
+	 *
90
+	 * @var boolean
91
+	 */
92
+	protected $_required;
93
+
94
+	/**
95
+	 * css class added to required inputs
96
+	 *
97
+	 * @var string
98
+	 */
99
+	protected $_required_css_class = 'ee-required';
100
+
101
+	/**
102
+	 * css styles applied to button type inputs
103
+	 *
104
+	 * @var string
105
+	 */
106
+	protected $_button_css_attributes;
107
+
108
+	/**
109
+	 * The raw data submitted for this, like in the $_POST super global.
110
+	 * Generally unsafe for usage in client code
111
+	 *
112
+	 * @var mixed string or array
113
+	 */
114
+	protected $_raw_value;
115
+
116
+	/**
117
+	 * Value normalized according to the input's normalization strategy.
118
+	 * The normalization strategy dictates whether this is a string, int, float,
119
+	 * boolean, or array of any of those.
120
+	 *
121
+	 * @var mixed
122
+	 */
123
+	protected $_normalized_value;
124
+
125
+
126
+	/**
127
+	 * Normalized default value either initially set on the input, or provided by calling
128
+	 * set_default().
129
+	 * @var mixed
130
+	 */
131
+	protected $_default;
132
+
133
+	/**
134
+	 * Strategy used for displaying this field.
135
+	 * Child classes must use _get_display_strategy to access it.
136
+	 *
137
+	 * @var EE_Display_Strategy_Base
138
+	 */
139
+	private $_display_strategy;
140
+
141
+	/**
142
+	 * Gets all the validation strategies used on this field
143
+	 *
144
+	 * @var EE_Validation_Strategy_Base[]
145
+	 */
146
+	private $_validation_strategies = array();
147
+
148
+	/**
149
+	 * The normalization strategy for this field
150
+	 *
151
+	 * @var EE_Normalization_Strategy_Base
152
+	 */
153
+	private $_normalization_strategy;
154
+
155
+	/**
156
+	 * Strategy for removing sensitive data after we're done with the form input
157
+	 *
158
+	 * @var EE_Sensitive_Data_Removal_Base
159
+	 */
160
+	protected $_sensitive_data_removal_strategy;
161
+
162
+	/**
163
+	 * Whether this input has been disabled or not.
164
+	 * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
165
+	 * (Client-side code that wants to dynamically disable it must also add this hidden input).
166
+	 * When the form is submitted, if the input is disabled in the PHP formsection, then input is ignored.
167
+	 * If the input is missing from the $_REQUEST data but the hidden input indicating the input is disabled, then the input is again ignored.
168
+	 *
169
+	 * @var boolean
170
+	 */
171
+	protected $disabled = false;
172
+
173
+
174
+
175
+	/**
176
+	 * @param array                         $input_args       {
177
+	 * @type string                         $html_name        the html name for the input
178
+	 * @type string                         $html_label_id    the id attribute to give to the html label tag
179
+	 * @type string                         $html_label_class the class attribute to give to the html label tag
180
+	 * @type string                         $html_label_style the style attribute to give ot teh label tag
181
+	 * @type string                         $html_label_text  the text to put in the label tag
182
+	 * @type string                         $html_label       the full html label. If used,
183
+	 *                                                        all other html_label_* args are invalid
184
+	 * @type string                         $html_help_text   text to put in help element
185
+	 * @type string                         $html_help_style  style attribute to give to teh help element
186
+	 * @type string                         $html_help_class  class attribute to give to the help element
187
+	 * @type string                         $default          default value NORMALIZED (eg, if providing the default
188
+	 *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
189
+	 * @type EE_Display_Strategy_Base       $display          strategy
190
+	 * @type EE_Normalization_Strategy_Base $normalization_strategy
191
+	 * @type EE_Validation_Strategy_Base[]  $validation_strategies
192
+	 * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
193
+	 *                                                    and sets the normalization strategy to the Null normalization. This is good
194
+	 *                                                    when you want the input to be totally ignored server-side (like when using
195
+	 *                                                    React.js form inputs)
196
+	 *                                                        }
197
+	 */
198
+	public function __construct($input_args = array())
199
+	{
200
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
201
+		// the following properties must be cast as arrays
202
+		if (isset($input_args['validation_strategies'])) {
203
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
204
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
205
+					$this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
206
+				}
207
+			}
208
+			unset($input_args['validation_strategies']);
209
+		}
210
+		if (isset($input_args['ignore_input'])) {
211
+			$this->_validation_strategies = array();
212
+		}
213
+		// loop thru incoming options
214
+		foreach ($input_args as $key => $value) {
215
+			// add underscore to $key to match property names
216
+			$_key = '_' . $key;
217
+			if (property_exists($this, $_key)) {
218
+				$this->{$_key} = $value;
219
+			}
220
+		}
221
+		// ensure that "required" is set correctly
222
+		$this->set_required(
223
+			$this->_required,
224
+			isset($input_args['required_validation_error_message'])
225
+			? $input_args['required_validation_error_message']
226
+			: null
227
+		);
228
+		// $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
229
+		$this->_display_strategy->_construct_finalize($this);
230
+		foreach ($this->_validation_strategies as $validation_strategy) {
231
+			$validation_strategy->_construct_finalize($this);
232
+		}
233
+		if (isset($input_args['ignore_input'])) {
234
+			$this->_normalization_strategy = new EE_Null_Normalization();
235
+		}
236
+		if (! $this->_normalization_strategy) {
237
+				$this->_normalization_strategy = new EE_Text_Normalization();
238
+		}
239
+		$this->_normalization_strategy->_construct_finalize($this);
240
+		// at least we can use the normalization strategy to populate the default
241
+		if (isset($input_args['default'])) {
242
+			$this->set_default($input_args['default']);
243
+			unset($input_args['default']);
244
+		}
245
+		if (! $this->_sensitive_data_removal_strategy) {
246
+			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
247
+		}
248
+		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
249
+		parent::__construct($input_args);
250
+	}
251
+
252
+
253
+
254
+	/**
255
+	 * Sets the html_name to its default value, if none was specified in teh constructor.
256
+	 * Calculation involves using the name and the parent's html_name
257
+	 *
258
+	 * @throws \EE_Error
259
+	 */
260
+	protected function _set_default_html_name_if_empty()
261
+	{
262
+		if (! $this->_html_name) {
263
+			$this->_html_name = $this->name();
264
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
265
+				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
266
+			}
267
+		}
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * @param $parent_form_section
274
+	 * @param $name
275
+	 * @throws \EE_Error
276
+	 */
277
+	public function _construct_finalize($parent_form_section, $name)
278
+	{
279
+		parent::_construct_finalize($parent_form_section, $name);
280
+		if ($this->_html_label === null && $this->_html_label_text === null) {
281
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
282
+		}
283
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * Returns the strategy for displaying this form input. If none is set, throws an exception.
290
+	 *
291
+	 * @return EE_Display_Strategy_Base
292
+	 * @throws EE_Error
293
+	 */
294
+	protected function _get_display_strategy()
295
+	{
296
+		$this->ensure_construct_finalized_called();
297
+		if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
298
+			throw new EE_Error(
299
+				sprintf(
300
+					__(
301
+						"Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
302
+						"event_espresso"
303
+					),
304
+					$this->html_name(),
305
+					$this->html_id()
306
+				)
307
+			);
308
+		} else {
309
+			return $this->_display_strategy;
310
+		}
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * Sets the display strategy.
317
+	 *
318
+	 * @param EE_Display_Strategy_Base $strategy
319
+	 */
320
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
321
+	{
322
+		$this->_display_strategy = $strategy;
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * Sets the sanitization strategy
329
+	 *
330
+	 * @param EE_Normalization_Strategy_Base $strategy
331
+	 */
332
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
333
+	{
334
+		$this->_normalization_strategy = $strategy;
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 * Gets sensitive_data_removal_strategy
341
+	 *
342
+	 * @return EE_Sensitive_Data_Removal_Base
343
+	 */
344
+	public function get_sensitive_data_removal_strategy()
345
+	{
346
+		return $this->_sensitive_data_removal_strategy;
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * Sets sensitive_data_removal_strategy
353
+	 *
354
+	 * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
355
+	 * @return boolean
356
+	 */
357
+	public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
358
+	{
359
+		$this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * Gets the display strategy for this input
366
+	 *
367
+	 * @return EE_Display_Strategy_Base
368
+	 */
369
+	public function get_display_strategy()
370
+	{
371
+		return $this->_display_strategy;
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * Overwrites the display strategy
378
+	 *
379
+	 * @param EE_Display_Strategy_Base $display_strategy
380
+	 */
381
+	public function set_display_strategy($display_strategy)
382
+	{
383
+		$this->_display_strategy = $display_strategy;
384
+		$this->_display_strategy->_construct_finalize($this);
385
+	}
386
+
387
+
388
+
389
+	/**
390
+	 * Gets the normalization strategy set on this input
391
+	 *
392
+	 * @return EE_Normalization_Strategy_Base
393
+	 */
394
+	public function get_normalization_strategy()
395
+	{
396
+		return $this->_normalization_strategy;
397
+	}
398
+
399
+
400
+
401
+	/**
402
+	 * Overwrites the normalization strategy
403
+	 *
404
+	 * @param EE_Normalization_Strategy_Base $normalization_strategy
405
+	 */
406
+	public function set_normalization_strategy($normalization_strategy)
407
+	{
408
+		$this->_normalization_strategy = $normalization_strategy;
409
+		$this->_normalization_strategy->_construct_finalize($this);
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * Returns all teh validation strategies which apply to this field, numerically indexed
416
+	 *
417
+	 * @return EE_Validation_Strategy_Base[]
418
+	 */
419
+	public function get_validation_strategies()
420
+	{
421
+		return $this->_validation_strategies;
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * Adds this strategy to the field so it will be used in both JS validation and server-side validation
428
+	 *
429
+	 * @param EE_Validation_Strategy_Base $validation_strategy
430
+	 * @return void
431
+	 */
432
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
433
+	{
434
+		$validation_strategy->_construct_finalize($this);
435
+		$this->_validation_strategies[] = $validation_strategy;
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * Adds a new validation strategy onto the form input
442
+	 *
443
+	 * @param EE_Validation_Strategy_Base $validation_strategy
444
+	 * @return void
445
+	 */
446
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
447
+	{
448
+		$this->_add_validation_strategy($validation_strategy);
449
+	}
450
+
451
+
452
+
453
+	/**
454
+	 * The classname of the validation strategy to remove
455
+	 *
456
+	 * @param string $validation_strategy_classname
457
+	 */
458
+	public function remove_validation_strategy($validation_strategy_classname)
459
+	{
460
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
461
+			if ($validation_strategy instanceof $validation_strategy_classname
462
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
463
+			) {
464
+				unset($this->_validation_strategies[ $key ]);
465
+			}
466
+		}
467
+	}
468
+
469
+
470
+
471
+	/**
472
+	 * returns true if input employs any of the validation strategy defined by the supplied array of classnames
473
+	 *
474
+	 * @param array $validation_strategy_classnames
475
+	 * @return bool
476
+	 */
477
+	public function has_validation_strategy($validation_strategy_classnames)
478
+	{
479
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
480
+			? $validation_strategy_classnames
481
+			: array($validation_strategy_classnames);
482
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
483
+			if (in_array($key, $validation_strategy_classnames)) {
484
+				return true;
485
+			}
486
+		}
487
+		return false;
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 * Gets the HTML
494
+	 *
495
+	 * @return string
496
+	 */
497
+	public function get_html()
498
+	{
499
+		return $this->_parent_section->get_html_for_input($this);
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * Gets the HTML for the input itself (no label or errors) according to the
506
+	 * input's display strategy
507
+	 * Makes sure the JS and CSS are enqueued for it
508
+	 *
509
+	 * @return string
510
+	 * @throws \EE_Error
511
+	 */
512
+	public function get_html_for_input()
513
+	{
514
+		return $this->_form_html_filter
515
+			? $this->_form_html_filter->filterHtml(
516
+				$this->_get_display_strategy()->display(),
517
+				$this
518
+			)
519
+			: $this->_get_display_strategy()->display();
520
+	}
521
+
522
+
523
+
524
+	/**
525
+	 * @return string
526
+	 */
527
+	public function html_other_attributes()
528
+	{
529
+		return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : '';
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * @param string $html_other_attributes
536
+	 */
537
+	public function set_html_other_attributes($html_other_attributes)
538
+	{
539
+		$this->_html_other_attributes = $html_other_attributes;
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * Gets the HTML for displaying the label for this form input
546
+	 * according to the form section's layout strategy
547
+	 *
548
+	 * @return string
549
+	 */
550
+	public function get_html_for_label()
551
+	{
552
+		return $this->_parent_section->get_layout_strategy()->display_label($this);
553
+	}
554
+
555
+
556
+
557
+	/**
558
+	 * Gets the HTML for displaying the errors section for this form input
559
+	 * according to the form section's layout strategy
560
+	 *
561
+	 * @return string
562
+	 */
563
+	public function get_html_for_errors()
564
+	{
565
+		return $this->_parent_section->get_layout_strategy()->display_errors($this);
566
+	}
567
+
568
+
569
+
570
+	/**
571
+	 * Gets the HTML for displaying the help text for this form input
572
+	 * according to the form section's layout strategy
573
+	 *
574
+	 * @return string
575
+	 */
576
+	public function get_html_for_help()
577
+	{
578
+		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
579
+	}
580
+
581
+
582
+
583
+	/**
584
+	 * Validates the input's sanitized value (assumes _sanitize() has already been called)
585
+	 * and returns whether or not the form input's submitted value is value
586
+	 *
587
+	 * @return boolean
588
+	 */
589
+	protected function _validate()
590
+	{
591
+		if ($this->isDisabled()) {
592
+			return true;
593
+		}
594
+		foreach ($this->_validation_strategies as $validation_strategy) {
595
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
596
+				try {
597
+					$validation_strategy->validate($this->normalized_value());
598
+				} catch (EE_Validation_Error $e) {
599
+					$this->add_validation_error($e);
600
+				}
601
+			}
602
+		}
603
+		if ($this->get_validation_errors()) {
604
+			return false;
605
+		} else {
606
+			return true;
607
+		}
608
+	}
609
+
610
+
611
+
612
+	/**
613
+	 * Performs basic sanitization on this value. But what sanitization can be performed anyways?
614
+	 * This value MIGHT be allowed to have tags, so we can't really remove them.
615
+	 *
616
+	 * @param string $value
617
+	 * @return null|string
618
+	 */
619
+	protected function _sanitize($value)
620
+	{
621
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
622
+	}
623
+
624
+
625
+
626
+	/**
627
+	 * Picks out the form value that relates to this form input,
628
+	 * and stores it as the sanitized value on the form input, and sets the normalized value.
629
+	 * Returns whether or not any validation errors occurred
630
+	 *
631
+	 * @param array $req_data like $_POST
632
+	 * @return boolean whether or not there was an error
633
+	 * @throws \EE_Error
634
+	 */
635
+	protected function _normalize($req_data)
636
+	{
637
+		// any existing validation errors don't apply so clear them
638
+		$this->_validation_errors = array();
639
+		// if the input is disabled, ignore whatever input was sent in
640
+		if ($this->isDisabled()) {
641
+			$this->_set_raw_value(null);
642
+			$this->_set_normalized_value($this->get_default());
643
+			return false;
644
+		}
645
+		try {
646
+			$raw_input = $this->find_form_data_for_this_section($req_data);
647
+			// super simple sanitization for now
648
+			if (is_array($raw_input)) {
649
+				$raw_value = array();
650
+				foreach ($raw_input as $key => $value) {
651
+					$raw_value[ $key ] = $this->_sanitize($value);
652
+				}
653
+				$this->_set_raw_value($raw_value);
654
+			} else {
655
+				$this->_set_raw_value($this->_sanitize($raw_input));
656
+			}
657
+			// we want to mostly leave the input alone in case we need to re-display it to the user
658
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
659
+			return false;
660
+		} catch (EE_Validation_Error $e) {
661
+			$this->add_validation_error($e);
662
+			return true;
663
+		}
664
+	}
665
+
666
+
667
+
668
+	/**
669
+	 * @return string
670
+	 */
671
+	public function html_name()
672
+	{
673
+		$this->_set_default_html_name_if_empty();
674
+		return $this->_html_name;
675
+	}
676
+
677
+
678
+
679
+	/**
680
+	 * @return string
681
+	 */
682
+	public function html_label_id()
683
+	{
684
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
685
+	}
686
+
687
+
688
+
689
+	/**
690
+	 * @return string
691
+	 */
692
+	public function html_label_class()
693
+	{
694
+		return $this->_html_label_class;
695
+	}
696
+
697
+
698
+
699
+	/**
700
+	 * @return string
701
+	 */
702
+	public function html_label_style()
703
+	{
704
+		return $this->_html_label_style;
705
+	}
706
+
707
+
708
+
709
+	/**
710
+	 * @return string
711
+	 */
712
+	public function html_label_text()
713
+	{
714
+		return $this->_html_label_text;
715
+	}
716
+
717
+
718
+
719
+	/**
720
+	 * @return string
721
+	 */
722
+	public function html_help_text()
723
+	{
724
+		return $this->_html_help_text;
725
+	}
726
+
727
+
728
+
729
+	/**
730
+	 * @return string
731
+	 */
732
+	public function html_help_class()
733
+	{
734
+		return $this->_html_help_class;
735
+	}
736
+
737
+
738
+
739
+	/**
740
+	 * @return string
741
+	 */
742
+	public function html_help_style()
743
+	{
744
+		return $this->_html_style;
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
751
+	 * Please note that almost all client code should instead use the normalized_value;
752
+	 * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
753
+	 * mostly by escaping quotes)
754
+	 * Note, we do not store the exact original value sent in the user's request because
755
+	 * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
756
+	 * in which case, we would have stored the malicious content to our database.
757
+	 *
758
+	 * @return string
759
+	 */
760
+	public function raw_value()
761
+	{
762
+		return $this->_raw_value;
763
+	}
764
+
765
+
766
+
767
+	/**
768
+	 * Returns a string safe to usage in form inputs when displaying, because
769
+	 * it escapes all html entities
770
+	 *
771
+	 * @return string
772
+	 */
773
+	public function raw_value_in_form()
774
+	{
775
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
776
+	}
777
+
778
+
779
+
780
+	/**
781
+	 * returns the value after it's been sanitized, and then converted into it's proper type
782
+	 * in PHP. Eg, a string, an int, an array,
783
+	 *
784
+	 * @return mixed
785
+	 */
786
+	public function normalized_value()
787
+	{
788
+		return $this->_normalized_value;
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 * Returns the normalized value is a presentable way. By default this is just
795
+	 * the normalized value by itself, but it can be overridden for when that's not
796
+	 * the best thing to display
797
+	 *
798
+	 * @return string
799
+	 */
800
+	public function pretty_value()
801
+	{
802
+		return $this->_normalized_value;
803
+	}
804
+
805
+
806
+
807
+	/**
808
+	 * When generating the JS for the jquery validation rules like<br>
809
+	 * <code>$( "#myform" ).validate({
810
+	 * rules: {
811
+	 * password: "required",
812
+	 * password_again: {
813
+	 * equalTo: "#password"
814
+	 * }
815
+	 * }
816
+	 * });</code>
817
+	 * if this field had the name 'password_again', it should return
818
+	 * <br><code>password_again: {
819
+	 * equalTo: "#password"
820
+	 * }</code>
821
+	 *
822
+	 * @return array
823
+	 */
824
+	public function get_jquery_validation_rules()
825
+	{
826
+		$jquery_validation_js = array();
827
+		$jquery_validation_rules = array();
828
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
829
+			$jquery_validation_rules = array_replace_recursive(
830
+				$jquery_validation_rules,
831
+				$validation_strategy->get_jquery_validation_rule_array()
832
+			);
833
+		}
834
+		if (! empty($jquery_validation_rules)) {
835
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
836
+				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
837
+			}
838
+		}
839
+		return $jquery_validation_js;
840
+	}
841
+
842
+
843
+
844
+	/**
845
+	 * Sets the input's default value for use in displaying in the form. Note: value should be
846
+	 * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
847
+	 *
848
+	 * @param mixed $value
849
+	 * @return void
850
+	 */
851
+	public function set_default($value)
852
+	{
853
+		$this->_default = $value;
854
+		$this->_set_normalized_value($value);
855
+		$this->_set_raw_value($value);
856
+	}
857
+
858
+
859
+
860
+	/**
861
+	 * Sets the normalized value on this input
862
+	 *
863
+	 * @param mixed $value
864
+	 */
865
+	protected function _set_normalized_value($value)
866
+	{
867
+		$this->_normalized_value = $value;
868
+	}
869
+
870
+
871
+
872
+	/**
873
+	 * Sets the raw value on this input (ie, exactly as the user submitted it)
874
+	 *
875
+	 * @param mixed $value
876
+	 */
877
+	protected function _set_raw_value($value)
878
+	{
879
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
880
+	}
881
+
882
+
883
+
884
+	/**
885
+	 * Sets the HTML label text after it has already been defined
886
+	 *
887
+	 * @param string $label
888
+	 * @return void
889
+	 */
890
+	public function set_html_label_text($label)
891
+	{
892
+		$this->_html_label_text = $label;
893
+	}
894
+
895
+
896
+
897
+	/**
898
+	 * Sets whether or not this field is required, and adjusts the validation strategy.
899
+	 * If you want to use the EE_Conditionally_Required_Validation_Strategy,
900
+	 * please add it as a validation strategy using add_validation_strategy as normal
901
+	 *
902
+	 * @param boolean $required boolean
903
+	 * @param null    $required_text
904
+	 */
905
+	public function set_required($required = true, $required_text = null)
906
+	{
907
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
908
+		// whether $required is a string or a boolean, we want to add a required validation strategy
909
+		if ($required) {
910
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
911
+		} else {
912
+			$this->remove_validation_strategy('EE_Required_Validation_Strategy');
913
+		}
914
+		$this->_required = $required;
915
+	}
916
+
917
+
918
+
919
+	/**
920
+	 * Returns whether or not this field is required
921
+	 *
922
+	 * @return boolean
923
+	 */
924
+	public function required()
925
+	{
926
+		return $this->_required;
927
+	}
928
+
929
+
930
+
931
+	/**
932
+	 * @param string $required_css_class
933
+	 */
934
+	public function set_required_css_class($required_css_class)
935
+	{
936
+		$this->_required_css_class = $required_css_class;
937
+	}
938
+
939
+
940
+
941
+	/**
942
+	 * @return string
943
+	 */
944
+	public function required_css_class()
945
+	{
946
+		return $this->_required_css_class;
947
+	}
948
+
949
+
950
+
951
+	/**
952
+	 * @param bool $add_required
953
+	 * @return string
954
+	 */
955
+	public function html_class($add_required = false)
956
+	{
957
+		return $add_required && $this->required()
958
+			? $this->required_css_class() . ' ' . $this->_html_class
959
+			: $this->_html_class;
960
+	}
961
+
962
+
963
+	/**
964
+	 * Sets the help text, in case
965
+	 *
966
+	 * @param string $text
967
+	 */
968
+	public function set_html_help_text($text)
969
+	{
970
+		$this->_html_help_text = $text;
971
+	}
972
+
973
+
974
+
975
+	/**
976
+	 * Uses the sensitive data removal strategy to remove the sensitive data from this
977
+	 * input. If there is any kind of sensitive data removal on this input, we clear
978
+	 * out the raw value completely
979
+	 *
980
+	 * @return void
981
+	 */
982
+	public function clean_sensitive_data()
983
+	{
984
+		// if we do ANY kind of sensitive data removal on this, then just clear out the raw value
985
+		// if we need more logic than this we'll make a strategy for it
986
+		if ($this->_sensitive_data_removal_strategy
987
+			&& ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
988
+		) {
989
+			$this->_set_raw_value(null);
990
+		}
991
+		// and clean the normalized value according to the appropriate strategy
992
+		$this->_set_normalized_value(
993
+			$this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
994
+				$this->_normalized_value
995
+			)
996
+		);
997
+	}
998
+
999
+
1000
+
1001
+	/**
1002
+	 * @param bool   $primary
1003
+	 * @param string $button_size
1004
+	 * @param string $other_attributes
1005
+	 */
1006
+	public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1007
+	{
1008
+		$button_css_attributes = 'button';
1009
+		$button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1010
+		switch ($button_size) {
1011
+			case 'xs':
1012
+			case 'extra-small':
1013
+				$button_css_attributes .= ' button-xs';
1014
+				break;
1015
+			case 'sm':
1016
+			case 'small':
1017
+				$button_css_attributes .= ' button-sm';
1018
+				break;
1019
+			case 'lg':
1020
+			case 'large':
1021
+				$button_css_attributes .= ' button-lg';
1022
+				break;
1023
+			case 'block':
1024
+				$button_css_attributes .= ' button-block';
1025
+				break;
1026
+			case 'md':
1027
+			case 'medium':
1028
+			default:
1029
+				$button_css_attributes .= '';
1030
+		}
1031
+		$this->_button_css_attributes .= ! empty($other_attributes)
1032
+			? $button_css_attributes . ' ' . $other_attributes
1033
+			: $button_css_attributes;
1034
+	}
1035
+
1036
+
1037
+
1038
+	/**
1039
+	 * @return string
1040
+	 */
1041
+	public function button_css_attributes()
1042
+	{
1043
+		if (empty($this->_button_css_attributes)) {
1044
+			$this->set_button_css_attributes();
1045
+		}
1046
+		return $this->_button_css_attributes;
1047
+	}
1048
+
1049
+
1050
+
1051
+	/**
1052
+	 * find_form_data_for_this_section
1053
+	 * using this section's name and its parents, finds the value of the form data that corresponds to it.
1054
+	 * For example, if this form section's HTML name is my_form[subform][form_input_1],
1055
+	 * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1'].
1056
+	 * (If that doesn't exist, we also check for this subsection's name
1057
+	 * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].)
1058
+	 * This function finds its value in the form.
1059
+	 *
1060
+	 * @param array $req_data
1061
+	 * @return mixed whatever the raw value of this form section is in the request data
1062
+	 * @throws \EE_Error
1063
+	 */
1064
+	public function find_form_data_for_this_section($req_data)
1065
+	{
1066
+		$name_parts = $this->getInputNameParts();
1067
+		// now get the value for the input
1068
+		$value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1069
+		// check if this thing's name is at the TOP level of the request data
1070
+		if ($value === null && isset($req_data[ $this->name() ])) {
1071
+			$value = $req_data[ $this->name() ];
1072
+		}
1073
+		return $value;
1074
+	}
1075
+
1076
+
1077
+
1078
+	/**
1079
+	 * If this input's name is something like "foo[bar][baz]"
1080
+	 * returns an array like `array('foo','bar',baz')`
1081
+	 * @return array
1082
+	 */
1083
+	protected function getInputNameParts()
1084
+	{
1085
+		// break up the html name by "[]"
1086
+		if (strpos($this->html_name(), '[') !== false) {
1087
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1088
+		} else {
1089
+			$before_any_brackets = $this->html_name();
1090
+		}
1091
+		// grab all of the segments
1092
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1093
+		if (isset($matches[1]) && is_array($matches[1])) {
1094
+			$name_parts = $matches[1];
1095
+			array_unshift($name_parts, $before_any_brackets);
1096
+		} else {
1097
+			$name_parts = array($before_any_brackets);
1098
+		}
1099
+		return $name_parts;
1100
+	}
1101
+
1102
+
1103
+
1104
+	/**
1105
+	 * @param array $html_name_parts
1106
+	 * @param array $req_data
1107
+	 * @return array | NULL
1108
+	 */
1109
+	public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1110
+	{
1111
+		$first_part_to_consider = array_shift($html_name_parts);
1112
+		if (isset($req_data[ $first_part_to_consider ])) {
1113
+			if (empty($html_name_parts)) {
1114
+				return $req_data[ $first_part_to_consider ];
1115
+			} else {
1116
+				return $this->findRequestForSectionUsingNameParts(
1117
+					$html_name_parts,
1118
+					$req_data[ $first_part_to_consider ]
1119
+				);
1120
+			}
1121
+		} else {
1122
+			return null;
1123
+		}
1124
+	}
1125
+
1126
+
1127
+
1128
+	/**
1129
+	 * Checks if this form input's data is in the request data
1130
+	 *
1131
+	 * @param array $req_data like $_POST
1132
+	 * @return boolean
1133
+	 * @throws \EE_Error
1134
+	 */
1135
+	public function form_data_present_in($req_data = null)
1136
+	{
1137
+		if ($req_data === null) {
1138
+			$req_data = $_POST;
1139
+		}
1140
+		$checked_value = $this->find_form_data_for_this_section($req_data);
1141
+		if ($checked_value !== null) {
1142
+			return true;
1143
+		} else {
1144
+			return false;
1145
+		}
1146
+	}
1147
+
1148
+
1149
+
1150
+	/**
1151
+	 * Overrides parent to add js data from validation and display strategies
1152
+	 *
1153
+	 * @param array $form_other_js_data
1154
+	 * @return array
1155
+	 */
1156
+	public function get_other_js_data($form_other_js_data = array())
1157
+	{
1158
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
1159
+		return $form_other_js_data;
1160
+	}
1161
+
1162
+
1163
+
1164
+	/**
1165
+	 * Gets other JS data for localization from this input's strategies, like
1166
+	 * the validation strategies and the display strategy
1167
+	 *
1168
+	 * @param array $form_other_js_data
1169
+	 * @return array
1170
+	 */
1171
+	public function get_other_js_data_from_strategies($form_other_js_data = array())
1172
+	{
1173
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1174
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1175
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1176
+		}
1177
+		return $form_other_js_data;
1178
+	}
1179
+
1180
+
1181
+
1182
+	/**
1183
+	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1184
+	 *
1185
+	 * @return void
1186
+	 */
1187
+	public function enqueue_js()
1188
+	{
1189
+		// ask our display strategy and validation strategies if they have js to enqueue
1190
+		$this->enqueue_js_from_strategies();
1191
+	}
1192
+
1193
+
1194
+
1195
+	/**
1196
+	 * Tells strategies when its ok to enqueue their js and css
1197
+	 *
1198
+	 * @return void
1199
+	 */
1200
+	public function enqueue_js_from_strategies()
1201
+	{
1202
+		$this->get_display_strategy()->enqueue_js();
1203
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1204
+			$validation_strategy->enqueue_js();
1205
+		}
1206
+	}
1207
+
1208
+
1209
+
1210
+	/**
1211
+	 * Gets the default value set on the input (not the current value, which may have been
1212
+	 * changed because of a form submission). If no default was set, this us null.
1213
+	 * @return mixed
1214
+	 */
1215
+	public function get_default()
1216
+	{
1217
+		return $this->_default;
1218
+	}
1219
+
1220
+
1221
+
1222
+	/**
1223
+	 * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1224
+	 * and server-side if any input was received it will be ignored
1225
+	 */
1226
+	public function disable($disable = true)
1227
+	{
1228
+		$disabled_attribute = ' disabled="disabled"';
1229
+		$this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1230
+		if ($this->disabled) {
1231
+			if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1232
+				$this->_other_html_attributes .= $disabled_attribute;
1233
+			}
1234
+			$this->_set_normalized_value($this->get_default());
1235
+		} else {
1236
+			$this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1237
+		}
1238
+	}
1239
+
1240
+
1241
+
1242
+	/**
1243
+	 * Returns whether or not this input is currently disabled.
1244
+	 * @return bool
1245
+	 */
1246
+	public function isDisabled()
1247
+	{
1248
+		return $this->disabled;
1249
+	}
1250 1250
 }
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 2 patches
Indentation   +662 added lines, -662 removed lines patch added patch discarded remove patch
@@ -24,666 +24,666 @@
 block discarded – undo
24 24
 class EEH_File extends EEH_Base implements EEHI_File
25 25
 {
26 26
 
27
-    /**
28
-     * @var string $_credentials_form
29
-     */
30
-    private static $_credentials_form;
31
-
32
-    protected static $_wp_filesystem_direct;
33
-
34
-    /**
35
-     * @param string|null $filepath the filepath we want to work in. If its in the
36
-     * wp uploads directory, we'll want to just use the filesystem directly.
37
-     * If not provided, we have to assume its not in the uploads directory
38
-     * @throws EE_Error if filesystem credentials are required
39
-     * @return WP_Filesystem_Base
40
-     */
41
-    private static function _get_wp_filesystem($filepath = null)
42
-    {
43
-        if (apply_filters(
44
-            'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
45
-            $filepath && EEH_File::is_in_uploads_folder($filepath),
46
-            $filepath
47
-        ) ) {
48
-            if (! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
49
-                require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
50
-                $method = 'direct';
51
-                $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
52
-                // check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
53
-                if (! defined('FS_CHMOD_DIR')) {
54
-                    define('FS_CHMOD_DIR', ( fileperms(ABSPATH) & 0777 | 0755 ));
55
-                }
56
-                if (! defined('FS_CHMOD_FILE')) {
57
-                    define('FS_CHMOD_FILE', ( fileperms(ABSPATH . 'index.php') & 0777 | 0644 ));
58
-                }
59
-                require_once($wp_filesystem_direct_file);
60
-                EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
61
-            }
62
-            return EEH_File::$_wp_filesystem_direct;
63
-        }
64
-        global $wp_filesystem;
65
-        // no filesystem setup ???
66
-        if (! $wp_filesystem instanceof WP_Filesystem_Base) {
67
-            // if some eager beaver's just trying to get in there too early...
68
-            // let them do it, because we are one of those eager beavers! :P
69
-            /**
70
-             * more explanations are probably merited. http://codex.wordpress.org/Filesystem_API#Initializing_WP_Filesystem_Base
71
-             * says WP_Filesystem should be used after 'wp_loaded', but currently EE's activation process
72
-             * is setup to mostly happen on 'init', and refactoring to have it happen on
73
-             * 'wp_loaded' is too much work on a BETA milestone.
74
-             * So this fix is expected to work if the WP files are owned by the server user,
75
-             * but probably not if the user needs to enter their FTP credentials to modify files
76
-             * and there may be troubles if the WP files are owned by a different user
77
-             * than the server user. But both of these issues should exist in 4.4 and earlier too
78
-             */
79
-            if (false && ! did_action('wp_loaded')) {
80
-                $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
81
-                if (WP_DEBUG) {
82
-                    $msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
83
-                }
84
-                throw new EE_Error($msg);
85
-            } else {
86
-                // should be loaded if we are past the wp_loaded hook...
87
-                if (! function_exists('WP_Filesystem')) {
88
-                    require_once(ABSPATH . 'wp-admin/includes/file.php');
89
-                    require_once(ABSPATH . 'wp-admin/includes/template.php');
90
-                }
91
-                // turn on output buffering so that we can capture the credentials form
92
-                ob_start();
93
-                $credentials = request_filesystem_credentials('');
94
-                // store credentials form for the time being
95
-                EEH_File::$_credentials_form = ob_get_clean();
96
-                // basically check for direct or previously configured access
97
-                if (! WP_Filesystem($credentials)) {
98
-                    // if credentials do NOT exist
99
-                    if ($credentials === false) {
100
-                        add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
101
-                        throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
102
-                    } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
103
-                        add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
104
-                        throw new EE_Error(
105
-                            sprintf(
106
-                                __('WP Filesystem Error: $1%s', 'event_espresso'),
107
-                                $wp_filesystem->errors->get_error_message()
108
-                            )
109
-                        );
110
-                    }
111
-                }
112
-            }
113
-        }
114
-        return $wp_filesystem;
115
-    }
116
-
117
-    /**
118
-     * display_request_filesystem_credentials_form
119
-     */
120
-    public static function display_request_filesystem_credentials_form()
121
-    {
122
-        if (! empty(EEH_File::$_credentials_form)) {
123
-            echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
124
-        }
125
-    }
126
-
127
-
128
-
129
-    /**
130
-     *    verify_filepath_and_permissions
131
-     *    checks that a file is readable and has sufficient file permissions set to access
132
-     *
133
-     * @access public
134
-     * @param string $full_file_path - full server path to the folder or file
135
-     * @param string $file_name      - name of file if checking a file
136
-     * @param string $file_ext       - file extension (ie: "php") if checking a file
137
-     * @param string $type_of_file   - general type of file (ie: "module"), this is only used to improve error messages
138
-     * @throws EE_Error if filesystem credentials are required
139
-     * @return bool
140
-     */
141
-    public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '')
142
-    {
143
-        // load WP_Filesystem and set file permissions
144
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
145
-        $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
146
-        if (! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
147
-            $file_name = ! empty($type_of_file) ? $file_name . ' ' . $type_of_file : $file_name;
148
-            $file_name .= ! empty($file_ext) ? ' file' : ' folder';
149
-            $msg = sprintf(
150
-                __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
151
-                $file_name,
152
-                '<br />'
153
-            );
154
-            if (EEH_File::exists($full_file_path)) {
155
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
156
-            } else {
157
-                // no file permissions means the file was not found
158
-                $msg .= sprintf(
159
-                    __('Please ensure the following path is correct: "%s".', 'event_espresso'),
160
-                    $full_file_path
161
-                );
162
-            }
163
-            if (defined('WP_DEBUG') && WP_DEBUG) {
164
-                throw new EE_Error($msg . '||' . $msg);
165
-            }
166
-            return false;
167
-        }
168
-        return true;
169
-    }
170
-
171
-
172
-
173
-    /**
174
-     * _permissions_error_for_unreadable_filepath - attempts to determine why permissions are set incorrectly for a file or folder
175
-     *
176
-     * @access private
177
-     * @param string $full_file_path - full server path to the folder or file
178
-     * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages
179
-     * @throws EE_Error if filesystem credentials are required
180
-     * @return string
181
-     */
182
-    private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '')
183
-    {
184
-        // load WP_Filesystem and set file permissions
185
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
186
-        // check file permissions
187
-        $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
188
-        if ($perms) {
189
-            // file permissions exist, but way be set incorrectly
190
-            $type_of_file = ! empty($type_of_file) ? $type_of_file . ' ' : '';
191
-            $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
192
-            return sprintf(
193
-                __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
194
-                $type_of_file,
195
-                $perms
196
-            );
197
-        } else {
198
-            // file exists but file permissions could not be read ?!?!
199
-            return sprintf(
200
-                __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
201
-                $full_file_path
202
-            );
203
-        }
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * ensure_folder_exists_and_is_writable
210
-     * ensures that a folder exists and is writable, will attempt to create folder if it does not exist
211
-     * Also ensures all the parent folders exist, and if not tries to create them.
212
-     * Also, if this function creates the folder, adds a .htaccess file and index.html file
213
-     * @param string $folder
214
-     * @throws EE_Error if the folder exists and is writeable, but for some reason we
215
-     * can't write to it
216
-     * @return bool false if folder isn't writable; true if it exists and is writeable,
217
-     */
218
-    public static function ensure_folder_exists_and_is_writable($folder = '')
219
-    {
220
-        if (empty($folder)) {
221
-            return false;
222
-        }
223
-        // remove ending DS
224
-        $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
225
-        $parent_folder = EEH_File::get_parent_folder($folder);
226
-        // add DS to folder
227
-        $folder = EEH_File::end_with_directory_separator($folder);
228
-        $wp_filesystem = EEH_File::_get_wp_filesystem($folder);
229
-        if (! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
230
-            // ok so it doesn't exist. Does its parent? Can we write to it?
231
-            if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
232
-                return false;
233
-            }
234
-            if (! EEH_File::verify_is_writable($parent_folder, 'folder')) {
235
-                return false;
236
-            } else {
237
-                if (! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
238
-                    if (defined('WP_DEBUG') && WP_DEBUG) {
239
-                        $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
240
-                        $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
241
-                        throw new EE_Error($msg);
242
-                    }
243
-                    return false;
244
-                }
245
-                EEH_File::add_index_file($folder);
246
-            }
247
-        } elseif (! EEH_File::verify_is_writable($folder, 'folder')) {
248
-            return false;
249
-        }
250
-        return true;
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     * verify_is_writable - checks if a file or folder is writable
257
-     * @param string $full_path      - full server path to file or folder
258
-     * @param string $file_or_folder - whether checking a file or folder
259
-     * @throws EE_Error if filesystem credentials are required
260
-     * @return bool
261
-     */
262
-    public static function verify_is_writable($full_path = '', $file_or_folder = 'folder')
263
-    {
264
-        // load WP_Filesystem and set file permissions
265
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
266
-        $full_path = EEH_File::standardise_directory_separators($full_path);
267
-        if (! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
268
-            if (defined('WP_DEBUG') && WP_DEBUG) {
269
-                $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
270
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
271
-                throw new EE_Error($msg);
272
-            }
273
-            return false;
274
-        }
275
-        return true;
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * ensure_file_exists_and_is_writable
282
-     * ensures that a file exists and is writable, will attempt to create file if it does not exist.
283
-     * Also ensures all the parent folders exist, and if not tries to create them.
284
-     * @param string $full_file_path
285
-     * @throws EE_Error if filesystem credentials are required
286
-     * @return bool
287
-     */
288
-    public static function ensure_file_exists_and_is_writable($full_file_path = '')
289
-    {
290
-        // load WP_Filesystem and set file permissions
291
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
292
-        $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
293
-        $parent_folder = EEH_File::get_parent_folder($full_file_path);
294
-        if (! EEH_File::exists($full_file_path)) {
295
-            if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
296
-                return false;
297
-            }
298
-            if (! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
299
-                if (defined('WP_DEBUG') && WP_DEBUG) {
300
-                    $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
301
-                    $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
302
-                    throw new EE_Error($msg);
303
-                }
304
-                return false;
305
-            }
306
-        }
307
-        if (! EEH_File::verify_is_writable($full_file_path, 'file')) {
308
-            return false;
309
-        }
310
-        return true;
311
-    }
312
-
313
-    /**
314
-     * Gets the parent folder. If provided with file, gets the folder that contains it.
315
-     * If provided a folder, gets its parent folder.
316
-     * @param string $file_or_folder_path
317
-     * @return string parent folder, ENDING with a directory separator
318
-     */
319
-    public static function get_parent_folder($file_or_folder_path)
320
-    {
321
-        // find the last DS, ignoring a DS on the very end
322
-        // eg if given "/var/something/somewhere/", we want to get "somewhere"'s
323
-        // parent folder, "/var/something/"
324
-        $ds = strlen($file_or_folder_path) > 1
325
-            ? strrpos($file_or_folder_path, DS, -2)
326
-            : strlen($file_or_folder_path);
327
-        return substr($file_or_folder_path, 0, $ds + 1);
328
-    }
329
-
330
-    // public static function ensure_folder_exists_recursively( $folder ) {
331
-    //
332
-    // }
333
-
334
-
335
-
336
-    /**
337
-     * get_file_contents
338
-     * @param string $full_file_path
339
-     * @throws EE_Error if filesystem credentials are required
340
-     * @return string
341
-     */
342
-    public static function get_file_contents($full_file_path = '')
343
-    {
344
-        $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
345
-        if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
346
-            // load WP_Filesystem and set file permissions
347
-            $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
348
-            return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
349
-        }
350
-        return '';
351
-    }
352
-
353
-
354
-
355
-    /**
356
-     * write_file
357
-     * @param string $full_file_path
358
-     * @param string $file_contents - the content to be written to the file
359
-     * @param string $file_type
360
-     * @throws EE_Error if filesystem credentials are required
361
-     * @return bool
362
-     */
363
-    public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '')
364
-    {
365
-        $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
366
-        $file_type = ! empty($file_type) ? rtrim($file_type, ' ') . ' ' : '';
367
-        $folder = EEH_File::remove_filename_from_filepath($full_file_path);
368
-        if (! EEH_File::verify_is_writable($folder, 'folder')) {
369
-            if (defined('WP_DEBUG') && WP_DEBUG) {
370
-                $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
371
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
372
-                throw new EE_Error($msg);
373
-            }
374
-            return false;
375
-        }
376
-        // load WP_Filesystem and set file permissions
377
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
378
-        // write the file
379
-        if (! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
380
-            if (defined('WP_DEBUG') && WP_DEBUG) {
381
-                $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
382
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
383
-                throw new EE_Error($msg);
384
-            }
385
-            return false;
386
-        }
387
-        return true;
388
-    }
389
-
390
-    /**
391
-     * Wrapper for WP_Filesystem_Base::delete
392
-     *
393
-     * @param string $filepath
394
-     * @param boolean $recursive
395
-     * @param boolean|string $type 'd' for directory, 'f' for file
396
-     * @throws EE_Error if filesystem credentials are required
397
-     * @return boolean
398
-     */
399
-    public static function delete($filepath, $recursive = false, $type = false)
400
-    {
401
-        $wp_filesystem = EEH_File::_get_wp_filesystem();
402
-        return $wp_filesystem->delete($filepath, $recursive, $type) ? true : false;
403
-    }
404
-
405
-
406
-
407
-    /**
408
-     * exists
409
-     * checks if a file exists using the WP filesystem
410
-     * @param string $full_file_path
411
-     * @throws EE_Error if filesystem credentials are required
412
-     * @return bool
413
-     */
414
-    public static function exists($full_file_path = '')
415
-    {
416
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
417
-        return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? true : false;
418
-    }
419
-
420
-
421
-
422
-    /**
423
-     * is_readable
424
-     * checks if a file is_readable using the WP filesystem
425
-     *
426
-     * @param string $full_file_path
427
-     * @throws EE_Error if filesystem credentials are required
428
-     * @return bool
429
-     */
430
-    public static function is_readable($full_file_path = '')
431
-    {
432
-        $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
433
-        if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
434
-            return true;
435
-        } else {
436
-            return false;
437
-        }
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     * remove_filename_from_filepath
444
-     * given a full path to a file including the filename itself, this removes  the filename and returns the path, up to, but NOT including the filename OR slash
445
-     *
446
-     * @param string $full_file_path
447
-     * @return string
448
-     */
449
-    public static function remove_filename_from_filepath($full_file_path = '')
450
-    {
451
-        return pathinfo($full_file_path, PATHINFO_DIRNAME);
452
-    }
453
-
454
-
455
-    /**
456
-     * get_filename_from_filepath. Arguably the same as basename()
457
-     *
458
-     * @param string $full_file_path
459
-     * @return string
460
-     */
461
-    public static function get_filename_from_filepath($full_file_path = '')
462
-    {
463
-        return pathinfo($full_file_path, PATHINFO_BASENAME);
464
-    }
465
-
466
-
467
-    /**
468
-     * get_file_extension
469
-     *
470
-     * @param string $full_file_path
471
-     * @return string
472
-     */
473
-    public static function get_file_extension($full_file_path = '')
474
-    {
475
-        return pathinfo($full_file_path, PATHINFO_EXTENSION);
476
-    }
477
-
478
-
479
-
480
-    /**
481
-     * add_htaccess_deny_from_all so the webserver cannot access this folder
482
-     * @param string $folder
483
-     * @throws EE_Error if filesystem credentials are required
484
-     * @return bool
485
-     */
486
-    public static function add_htaccess_deny_from_all($folder = '')
487
-    {
488
-        $folder = EEH_File::standardise_and_end_with_directory_separator($folder);
489
-        if (! EEH_File::exists($folder . '.htaccess')) {
490
-            if (! EEH_File::write_to_file($folder . '.htaccess', 'deny from all', '.htaccess')) {
491
-                return false;
492
-            }
493
-        }
494
-
495
-        return true;
496
-    }
497
-
498
-    /**
499
-     * Adds an index file to this folder, so folks can't list all the file's contents
500
-     * @param string $folder
501
-     * @throws EE_Error if filesystem credentials are required
502
-     * @return boolean
503
-     */
504
-    public static function add_index_file($folder)
505
-    {
506
-        $folder = EEH_File::standardise_and_end_with_directory_separator($folder);
507
-        if (! EEH_File::exists($folder . 'index.php')) {
508
-            if (! EEH_File::write_to_file($folder . 'index.php', 'You are not permitted to read from this folder', '.php')) {
509
-                return false;
510
-            }
511
-        }
512
-        return true;
513
-    }
514
-
515
-
516
-
517
-    /**
518
-     * Given that the file in $file_path has the normal name, (ie, CLASSNAME.whatever.php),
519
-     * extract that classname.
520
-     * @param string $file_path
521
-     * @return string
522
-     */
523
-    public static function get_classname_from_filepath_with_standard_filename($file_path)
524
-    {
525
-        // extract file from path
526
-        $filename = basename($file_path);
527
-        // now remove the first period and everything after
528
-        $pos_of_first_period = strpos($filename, '.');
529
-        return substr($filename, 0, $pos_of_first_period);
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * standardise_directory_separators
536
-     *  convert all directory separators in a file path to whatever is set for DS
537
-     * @param string $file_path
538
-     * @return string
539
-     */
540
-    public static function standardise_directory_separators($file_path)
541
-    {
542
-        return str_replace(array( '\\', '/' ), DS, $file_path);
543
-    }
544
-
545
-
546
-
547
-    /**
548
-     * end_with_directory_separator
549
-     *  ensures that file path ends with DS
550
-     * @param string $file_path
551
-     * @return string
552
-     */
553
-    public static function end_with_directory_separator($file_path)
554
-    {
555
-        return rtrim($file_path, '/\\') . DS;
556
-    }
557
-
558
-
559
-
560
-    /**
561
-     * shorthand for both EEH_FIle::end_with_directory_separator AND EEH_File::standardise_directory_separators
562
-     * @param $file_path
563
-     * @return string
564
-     */
565
-    public static function standardise_and_end_with_directory_separator($file_path)
566
-    {
567
-        return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
568
-    }
569
-
570
-
571
-
572
-    /**
573
-     * takes the folder name (with or without trailing slash) and finds the files it in,
574
-     * and what the class's name inside of each should be.
575
-     * @param array $folder_paths
576
-     * @param boolean $index_numerically if TRUE, the returned array will be indexed numerically;
577
-     *      if FALSE (Default), returned array will be indexed by the filenames minus extensions.
578
-     *      Set it TRUE if you know there are files in the directory with the same name but different extensions
579
-     * @throws EE_Error if filesystem credentials are required
580
-     * @return array if $index_numerically == TRUE keys are numeric ,
581
-     *      if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
582
-     *       and values are their filepaths
583
-     */
584
-    public static function get_contents_of_folders($folder_paths = array(), $index_numerically = false)
585
-    {
586
-        $class_to_folder_path = array();
587
-        foreach ($folder_paths as $folder_path) {
588
-            $folder_path = self::standardise_and_end_with_directory_separator($folder_path);
589
-            // load WP_Filesystem and set file permissions
590
-            $files_in_folder = glob($folder_path . '*');
591
-            $class_to_folder_path = array();
592
-            if ($files_in_folder) {
593
-                foreach ($files_in_folder as $file_path) {
594
-                    // only add files, not folders
595
-                    if (! is_dir($file_path)) {
596
-                        if ($index_numerically) {
597
-                            $class_to_folder_path[] = $file_path;
598
-                        } else {
599
-                            $classname = self::get_classname_from_filepath_with_standard_filename($file_path);
600
-                            $class_to_folder_path[ $classname ] = $file_path;
601
-                        }
602
-                    }
603
-                }
604
-            }
605
-        }
606
-        return $class_to_folder_path;
607
-    }
608
-
609
-
610
-
611
-    /**
612
-     * Copies a file. Mostly a wrapper of WP_Filesystem::copy
613
-     * @param string $source_file
614
-     * @param string $destination_file
615
-     * @param boolean $overwrite
616
-     * @throws EE_Error if filesystem credentials are required
617
-     * @return boolean success
618
-     */
619
-    public static function copy($source_file, $destination_file, $overwrite = false)
620
-    {
621
-        $full_source_path = EEH_File::standardise_directory_separators($source_file);
622
-        if (! EEH_File::exists($full_source_path)) {
623
-            if (defined('WP_DEBUG') && WP_DEBUG) {
624
-                $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
625
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
626
-                throw new EE_Error($msg);
627
-            }
628
-            return false;
629
-        }
630
-
631
-        $full_dest_path = EEH_File::standardise_directory_separators($destination_file);
632
-        $folder = EEH_File::remove_filename_from_filepath($full_dest_path);
633
-        EEH_File::ensure_folder_exists_and_is_writable($folder);
634
-        if (! EEH_File::verify_is_writable($folder, 'folder')) {
635
-            if (defined('WP_DEBUG') && WP_DEBUG) {
636
-                $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
637
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
638
-                throw new EE_Error($msg);
639
-            }
640
-            return false;
641
-        }
642
-
643
-        // load WP_Filesystem and set file permissions
644
-        $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
645
-        // write the file
646
-        if (! $wp_filesystem->copy(
647
-            EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
648
-            EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
649
-            $overwrite
650
-        )) {
651
-            if (defined('WP_DEBUG') && WP_DEBUG) {
652
-                $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
653
-                $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
654
-                throw new EE_Error($msg);
655
-            }
656
-            return false;
657
-        }
658
-        return true;
659
-    }
660
-
661
-    /**
662
-     * Reports whether or not the filepath is in the EE uploads folder or not
663
-     * @param string $filepath
664
-     * @return boolean
665
-     */
666
-    public static function is_in_uploads_folder($filepath)
667
-    {
668
-        $uploads = wp_upload_dir();
669
-        return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
670
-    }
671
-
672
-    /**
673
-     * Given a "local" filepath (what you probably thought was the only filepath),
674
-     * converts it into a "remote" filepath (the filepath the currently-in-use
675
-     * $wp_filesystem needs to use access the folder or file).
676
-     * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins
677
-     * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one
678
-     * is in use, so you need to provide it
679
-     * @param string $local_filepath the filepath to the folder/file locally
680
-     * @throws EE_Error if filesystem credentials are required
681
-     * @return string the remote filepath (eg the filepath the filesystem method, eg
682
-     * ftp or ssh, will use to access the folder
683
-     */
684
-    public static function convert_local_filepath_to_remote_filepath($local_filepath)
685
-    {
686
-        $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
687
-        return str_replace(WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath);
688
-    }
27
+	/**
28
+	 * @var string $_credentials_form
29
+	 */
30
+	private static $_credentials_form;
31
+
32
+	protected static $_wp_filesystem_direct;
33
+
34
+	/**
35
+	 * @param string|null $filepath the filepath we want to work in. If its in the
36
+	 * wp uploads directory, we'll want to just use the filesystem directly.
37
+	 * If not provided, we have to assume its not in the uploads directory
38
+	 * @throws EE_Error if filesystem credentials are required
39
+	 * @return WP_Filesystem_Base
40
+	 */
41
+	private static function _get_wp_filesystem($filepath = null)
42
+	{
43
+		if (apply_filters(
44
+			'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
45
+			$filepath && EEH_File::is_in_uploads_folder($filepath),
46
+			$filepath
47
+		) ) {
48
+			if (! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
49
+				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
50
+				$method = 'direct';
51
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
52
+				// check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
53
+				if (! defined('FS_CHMOD_DIR')) {
54
+					define('FS_CHMOD_DIR', ( fileperms(ABSPATH) & 0777 | 0755 ));
55
+				}
56
+				if (! defined('FS_CHMOD_FILE')) {
57
+					define('FS_CHMOD_FILE', ( fileperms(ABSPATH . 'index.php') & 0777 | 0644 ));
58
+				}
59
+				require_once($wp_filesystem_direct_file);
60
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
61
+			}
62
+			return EEH_File::$_wp_filesystem_direct;
63
+		}
64
+		global $wp_filesystem;
65
+		// no filesystem setup ???
66
+		if (! $wp_filesystem instanceof WP_Filesystem_Base) {
67
+			// if some eager beaver's just trying to get in there too early...
68
+			// let them do it, because we are one of those eager beavers! :P
69
+			/**
70
+			 * more explanations are probably merited. http://codex.wordpress.org/Filesystem_API#Initializing_WP_Filesystem_Base
71
+			 * says WP_Filesystem should be used after 'wp_loaded', but currently EE's activation process
72
+			 * is setup to mostly happen on 'init', and refactoring to have it happen on
73
+			 * 'wp_loaded' is too much work on a BETA milestone.
74
+			 * So this fix is expected to work if the WP files are owned by the server user,
75
+			 * but probably not if the user needs to enter their FTP credentials to modify files
76
+			 * and there may be troubles if the WP files are owned by a different user
77
+			 * than the server user. But both of these issues should exist in 4.4 and earlier too
78
+			 */
79
+			if (false && ! did_action('wp_loaded')) {
80
+				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
81
+				if (WP_DEBUG) {
82
+					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
83
+				}
84
+				throw new EE_Error($msg);
85
+			} else {
86
+				// should be loaded if we are past the wp_loaded hook...
87
+				if (! function_exists('WP_Filesystem')) {
88
+					require_once(ABSPATH . 'wp-admin/includes/file.php');
89
+					require_once(ABSPATH . 'wp-admin/includes/template.php');
90
+				}
91
+				// turn on output buffering so that we can capture the credentials form
92
+				ob_start();
93
+				$credentials = request_filesystem_credentials('');
94
+				// store credentials form for the time being
95
+				EEH_File::$_credentials_form = ob_get_clean();
96
+				// basically check for direct or previously configured access
97
+				if (! WP_Filesystem($credentials)) {
98
+					// if credentials do NOT exist
99
+					if ($credentials === false) {
100
+						add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
101
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
102
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
103
+						add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
104
+						throw new EE_Error(
105
+							sprintf(
106
+								__('WP Filesystem Error: $1%s', 'event_espresso'),
107
+								$wp_filesystem->errors->get_error_message()
108
+							)
109
+						);
110
+					}
111
+				}
112
+			}
113
+		}
114
+		return $wp_filesystem;
115
+	}
116
+
117
+	/**
118
+	 * display_request_filesystem_credentials_form
119
+	 */
120
+	public static function display_request_filesystem_credentials_form()
121
+	{
122
+		if (! empty(EEH_File::$_credentials_form)) {
123
+			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
124
+		}
125
+	}
126
+
127
+
128
+
129
+	/**
130
+	 *    verify_filepath_and_permissions
131
+	 *    checks that a file is readable and has sufficient file permissions set to access
132
+	 *
133
+	 * @access public
134
+	 * @param string $full_file_path - full server path to the folder or file
135
+	 * @param string $file_name      - name of file if checking a file
136
+	 * @param string $file_ext       - file extension (ie: "php") if checking a file
137
+	 * @param string $type_of_file   - general type of file (ie: "module"), this is only used to improve error messages
138
+	 * @throws EE_Error if filesystem credentials are required
139
+	 * @return bool
140
+	 */
141
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '')
142
+	{
143
+		// load WP_Filesystem and set file permissions
144
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
145
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
146
+		if (! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
147
+			$file_name = ! empty($type_of_file) ? $file_name . ' ' . $type_of_file : $file_name;
148
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
149
+			$msg = sprintf(
150
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
151
+				$file_name,
152
+				'<br />'
153
+			);
154
+			if (EEH_File::exists($full_file_path)) {
155
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
156
+			} else {
157
+				// no file permissions means the file was not found
158
+				$msg .= sprintf(
159
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
160
+					$full_file_path
161
+				);
162
+			}
163
+			if (defined('WP_DEBUG') && WP_DEBUG) {
164
+				throw new EE_Error($msg . '||' . $msg);
165
+			}
166
+			return false;
167
+		}
168
+		return true;
169
+	}
170
+
171
+
172
+
173
+	/**
174
+	 * _permissions_error_for_unreadable_filepath - attempts to determine why permissions are set incorrectly for a file or folder
175
+	 *
176
+	 * @access private
177
+	 * @param string $full_file_path - full server path to the folder or file
178
+	 * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages
179
+	 * @throws EE_Error if filesystem credentials are required
180
+	 * @return string
181
+	 */
182
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '')
183
+	{
184
+		// load WP_Filesystem and set file permissions
185
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
186
+		// check file permissions
187
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
188
+		if ($perms) {
189
+			// file permissions exist, but way be set incorrectly
190
+			$type_of_file = ! empty($type_of_file) ? $type_of_file . ' ' : '';
191
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
192
+			return sprintf(
193
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
194
+				$type_of_file,
195
+				$perms
196
+			);
197
+		} else {
198
+			// file exists but file permissions could not be read ?!?!
199
+			return sprintf(
200
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
201
+				$full_file_path
202
+			);
203
+		}
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * ensure_folder_exists_and_is_writable
210
+	 * ensures that a folder exists and is writable, will attempt to create folder if it does not exist
211
+	 * Also ensures all the parent folders exist, and if not tries to create them.
212
+	 * Also, if this function creates the folder, adds a .htaccess file and index.html file
213
+	 * @param string $folder
214
+	 * @throws EE_Error if the folder exists and is writeable, but for some reason we
215
+	 * can't write to it
216
+	 * @return bool false if folder isn't writable; true if it exists and is writeable,
217
+	 */
218
+	public static function ensure_folder_exists_and_is_writable($folder = '')
219
+	{
220
+		if (empty($folder)) {
221
+			return false;
222
+		}
223
+		// remove ending DS
224
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
225
+		$parent_folder = EEH_File::get_parent_folder($folder);
226
+		// add DS to folder
227
+		$folder = EEH_File::end_with_directory_separator($folder);
228
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
229
+		if (! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
230
+			// ok so it doesn't exist. Does its parent? Can we write to it?
231
+			if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
232
+				return false;
233
+			}
234
+			if (! EEH_File::verify_is_writable($parent_folder, 'folder')) {
235
+				return false;
236
+			} else {
237
+				if (! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
238
+					if (defined('WP_DEBUG') && WP_DEBUG) {
239
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
240
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
241
+						throw new EE_Error($msg);
242
+					}
243
+					return false;
244
+				}
245
+				EEH_File::add_index_file($folder);
246
+			}
247
+		} elseif (! EEH_File::verify_is_writable($folder, 'folder')) {
248
+			return false;
249
+		}
250
+		return true;
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 * verify_is_writable - checks if a file or folder is writable
257
+	 * @param string $full_path      - full server path to file or folder
258
+	 * @param string $file_or_folder - whether checking a file or folder
259
+	 * @throws EE_Error if filesystem credentials are required
260
+	 * @return bool
261
+	 */
262
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder')
263
+	{
264
+		// load WP_Filesystem and set file permissions
265
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
266
+		$full_path = EEH_File::standardise_directory_separators($full_path);
267
+		if (! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
268
+			if (defined('WP_DEBUG') && WP_DEBUG) {
269
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
270
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
271
+				throw new EE_Error($msg);
272
+			}
273
+			return false;
274
+		}
275
+		return true;
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * ensure_file_exists_and_is_writable
282
+	 * ensures that a file exists and is writable, will attempt to create file if it does not exist.
283
+	 * Also ensures all the parent folders exist, and if not tries to create them.
284
+	 * @param string $full_file_path
285
+	 * @throws EE_Error if filesystem credentials are required
286
+	 * @return bool
287
+	 */
288
+	public static function ensure_file_exists_and_is_writable($full_file_path = '')
289
+	{
290
+		// load WP_Filesystem and set file permissions
291
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
292
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
293
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
294
+		if (! EEH_File::exists($full_file_path)) {
295
+			if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
296
+				return false;
297
+			}
298
+			if (! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
299
+				if (defined('WP_DEBUG') && WP_DEBUG) {
300
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
301
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
302
+					throw new EE_Error($msg);
303
+				}
304
+				return false;
305
+			}
306
+		}
307
+		if (! EEH_File::verify_is_writable($full_file_path, 'file')) {
308
+			return false;
309
+		}
310
+		return true;
311
+	}
312
+
313
+	/**
314
+	 * Gets the parent folder. If provided with file, gets the folder that contains it.
315
+	 * If provided a folder, gets its parent folder.
316
+	 * @param string $file_or_folder_path
317
+	 * @return string parent folder, ENDING with a directory separator
318
+	 */
319
+	public static function get_parent_folder($file_or_folder_path)
320
+	{
321
+		// find the last DS, ignoring a DS on the very end
322
+		// eg if given "/var/something/somewhere/", we want to get "somewhere"'s
323
+		// parent folder, "/var/something/"
324
+		$ds = strlen($file_or_folder_path) > 1
325
+			? strrpos($file_or_folder_path, DS, -2)
326
+			: strlen($file_or_folder_path);
327
+		return substr($file_or_folder_path, 0, $ds + 1);
328
+	}
329
+
330
+	// public static function ensure_folder_exists_recursively( $folder ) {
331
+	//
332
+	// }
333
+
334
+
335
+
336
+	/**
337
+	 * get_file_contents
338
+	 * @param string $full_file_path
339
+	 * @throws EE_Error if filesystem credentials are required
340
+	 * @return string
341
+	 */
342
+	public static function get_file_contents($full_file_path = '')
343
+	{
344
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
345
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
346
+			// load WP_Filesystem and set file permissions
347
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
348
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
349
+		}
350
+		return '';
351
+	}
352
+
353
+
354
+
355
+	/**
356
+	 * write_file
357
+	 * @param string $full_file_path
358
+	 * @param string $file_contents - the content to be written to the file
359
+	 * @param string $file_type
360
+	 * @throws EE_Error if filesystem credentials are required
361
+	 * @return bool
362
+	 */
363
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '')
364
+	{
365
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
366
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ') . ' ' : '';
367
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
368
+		if (! EEH_File::verify_is_writable($folder, 'folder')) {
369
+			if (defined('WP_DEBUG') && WP_DEBUG) {
370
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
371
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
372
+				throw new EE_Error($msg);
373
+			}
374
+			return false;
375
+		}
376
+		// load WP_Filesystem and set file permissions
377
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
378
+		// write the file
379
+		if (! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
380
+			if (defined('WP_DEBUG') && WP_DEBUG) {
381
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
382
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
383
+				throw new EE_Error($msg);
384
+			}
385
+			return false;
386
+		}
387
+		return true;
388
+	}
389
+
390
+	/**
391
+	 * Wrapper for WP_Filesystem_Base::delete
392
+	 *
393
+	 * @param string $filepath
394
+	 * @param boolean $recursive
395
+	 * @param boolean|string $type 'd' for directory, 'f' for file
396
+	 * @throws EE_Error if filesystem credentials are required
397
+	 * @return boolean
398
+	 */
399
+	public static function delete($filepath, $recursive = false, $type = false)
400
+	{
401
+		$wp_filesystem = EEH_File::_get_wp_filesystem();
402
+		return $wp_filesystem->delete($filepath, $recursive, $type) ? true : false;
403
+	}
404
+
405
+
406
+
407
+	/**
408
+	 * exists
409
+	 * checks if a file exists using the WP filesystem
410
+	 * @param string $full_file_path
411
+	 * @throws EE_Error if filesystem credentials are required
412
+	 * @return bool
413
+	 */
414
+	public static function exists($full_file_path = '')
415
+	{
416
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
417
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? true : false;
418
+	}
419
+
420
+
421
+
422
+	/**
423
+	 * is_readable
424
+	 * checks if a file is_readable using the WP filesystem
425
+	 *
426
+	 * @param string $full_file_path
427
+	 * @throws EE_Error if filesystem credentials are required
428
+	 * @return bool
429
+	 */
430
+	public static function is_readable($full_file_path = '')
431
+	{
432
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
433
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
434
+			return true;
435
+		} else {
436
+			return false;
437
+		}
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 * remove_filename_from_filepath
444
+	 * given a full path to a file including the filename itself, this removes  the filename and returns the path, up to, but NOT including the filename OR slash
445
+	 *
446
+	 * @param string $full_file_path
447
+	 * @return string
448
+	 */
449
+	public static function remove_filename_from_filepath($full_file_path = '')
450
+	{
451
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
452
+	}
453
+
454
+
455
+	/**
456
+	 * get_filename_from_filepath. Arguably the same as basename()
457
+	 *
458
+	 * @param string $full_file_path
459
+	 * @return string
460
+	 */
461
+	public static function get_filename_from_filepath($full_file_path = '')
462
+	{
463
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
464
+	}
465
+
466
+
467
+	/**
468
+	 * get_file_extension
469
+	 *
470
+	 * @param string $full_file_path
471
+	 * @return string
472
+	 */
473
+	public static function get_file_extension($full_file_path = '')
474
+	{
475
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
476
+	}
477
+
478
+
479
+
480
+	/**
481
+	 * add_htaccess_deny_from_all so the webserver cannot access this folder
482
+	 * @param string $folder
483
+	 * @throws EE_Error if filesystem credentials are required
484
+	 * @return bool
485
+	 */
486
+	public static function add_htaccess_deny_from_all($folder = '')
487
+	{
488
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
489
+		if (! EEH_File::exists($folder . '.htaccess')) {
490
+			if (! EEH_File::write_to_file($folder . '.htaccess', 'deny from all', '.htaccess')) {
491
+				return false;
492
+			}
493
+		}
494
+
495
+		return true;
496
+	}
497
+
498
+	/**
499
+	 * Adds an index file to this folder, so folks can't list all the file's contents
500
+	 * @param string $folder
501
+	 * @throws EE_Error if filesystem credentials are required
502
+	 * @return boolean
503
+	 */
504
+	public static function add_index_file($folder)
505
+	{
506
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
507
+		if (! EEH_File::exists($folder . 'index.php')) {
508
+			if (! EEH_File::write_to_file($folder . 'index.php', 'You are not permitted to read from this folder', '.php')) {
509
+				return false;
510
+			}
511
+		}
512
+		return true;
513
+	}
514
+
515
+
516
+
517
+	/**
518
+	 * Given that the file in $file_path has the normal name, (ie, CLASSNAME.whatever.php),
519
+	 * extract that classname.
520
+	 * @param string $file_path
521
+	 * @return string
522
+	 */
523
+	public static function get_classname_from_filepath_with_standard_filename($file_path)
524
+	{
525
+		// extract file from path
526
+		$filename = basename($file_path);
527
+		// now remove the first period and everything after
528
+		$pos_of_first_period = strpos($filename, '.');
529
+		return substr($filename, 0, $pos_of_first_period);
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * standardise_directory_separators
536
+	 *  convert all directory separators in a file path to whatever is set for DS
537
+	 * @param string $file_path
538
+	 * @return string
539
+	 */
540
+	public static function standardise_directory_separators($file_path)
541
+	{
542
+		return str_replace(array( '\\', '/' ), DS, $file_path);
543
+	}
544
+
545
+
546
+
547
+	/**
548
+	 * end_with_directory_separator
549
+	 *  ensures that file path ends with DS
550
+	 * @param string $file_path
551
+	 * @return string
552
+	 */
553
+	public static function end_with_directory_separator($file_path)
554
+	{
555
+		return rtrim($file_path, '/\\') . DS;
556
+	}
557
+
558
+
559
+
560
+	/**
561
+	 * shorthand for both EEH_FIle::end_with_directory_separator AND EEH_File::standardise_directory_separators
562
+	 * @param $file_path
563
+	 * @return string
564
+	 */
565
+	public static function standardise_and_end_with_directory_separator($file_path)
566
+	{
567
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
568
+	}
569
+
570
+
571
+
572
+	/**
573
+	 * takes the folder name (with or without trailing slash) and finds the files it in,
574
+	 * and what the class's name inside of each should be.
575
+	 * @param array $folder_paths
576
+	 * @param boolean $index_numerically if TRUE, the returned array will be indexed numerically;
577
+	 *      if FALSE (Default), returned array will be indexed by the filenames minus extensions.
578
+	 *      Set it TRUE if you know there are files in the directory with the same name but different extensions
579
+	 * @throws EE_Error if filesystem credentials are required
580
+	 * @return array if $index_numerically == TRUE keys are numeric ,
581
+	 *      if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
582
+	 *       and values are their filepaths
583
+	 */
584
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = false)
585
+	{
586
+		$class_to_folder_path = array();
587
+		foreach ($folder_paths as $folder_path) {
588
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
589
+			// load WP_Filesystem and set file permissions
590
+			$files_in_folder = glob($folder_path . '*');
591
+			$class_to_folder_path = array();
592
+			if ($files_in_folder) {
593
+				foreach ($files_in_folder as $file_path) {
594
+					// only add files, not folders
595
+					if (! is_dir($file_path)) {
596
+						if ($index_numerically) {
597
+							$class_to_folder_path[] = $file_path;
598
+						} else {
599
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
600
+							$class_to_folder_path[ $classname ] = $file_path;
601
+						}
602
+					}
603
+				}
604
+			}
605
+		}
606
+		return $class_to_folder_path;
607
+	}
608
+
609
+
610
+
611
+	/**
612
+	 * Copies a file. Mostly a wrapper of WP_Filesystem::copy
613
+	 * @param string $source_file
614
+	 * @param string $destination_file
615
+	 * @param boolean $overwrite
616
+	 * @throws EE_Error if filesystem credentials are required
617
+	 * @return boolean success
618
+	 */
619
+	public static function copy($source_file, $destination_file, $overwrite = false)
620
+	{
621
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
622
+		if (! EEH_File::exists($full_source_path)) {
623
+			if (defined('WP_DEBUG') && WP_DEBUG) {
624
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
625
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
626
+				throw new EE_Error($msg);
627
+			}
628
+			return false;
629
+		}
630
+
631
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
632
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
633
+		EEH_File::ensure_folder_exists_and_is_writable($folder);
634
+		if (! EEH_File::verify_is_writable($folder, 'folder')) {
635
+			if (defined('WP_DEBUG') && WP_DEBUG) {
636
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
637
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
638
+				throw new EE_Error($msg);
639
+			}
640
+			return false;
641
+		}
642
+
643
+		// load WP_Filesystem and set file permissions
644
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
645
+		// write the file
646
+		if (! $wp_filesystem->copy(
647
+			EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
648
+			EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
649
+			$overwrite
650
+		)) {
651
+			if (defined('WP_DEBUG') && WP_DEBUG) {
652
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
653
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
654
+				throw new EE_Error($msg);
655
+			}
656
+			return false;
657
+		}
658
+		return true;
659
+	}
660
+
661
+	/**
662
+	 * Reports whether or not the filepath is in the EE uploads folder or not
663
+	 * @param string $filepath
664
+	 * @return boolean
665
+	 */
666
+	public static function is_in_uploads_folder($filepath)
667
+	{
668
+		$uploads = wp_upload_dir();
669
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
670
+	}
671
+
672
+	/**
673
+	 * Given a "local" filepath (what you probably thought was the only filepath),
674
+	 * converts it into a "remote" filepath (the filepath the currently-in-use
675
+	 * $wp_filesystem needs to use access the folder or file).
676
+	 * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins
677
+	 * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one
678
+	 * is in use, so you need to provide it
679
+	 * @param string $local_filepath the filepath to the folder/file locally
680
+	 * @throws EE_Error if filesystem credentials are required
681
+	 * @return string the remote filepath (eg the filepath the filesystem method, eg
682
+	 * ftp or ssh, will use to access the folder
683
+	 */
684
+	public static function convert_local_filepath_to_remote_filepath($local_filepath)
685
+	{
686
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
687
+		return str_replace(WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath);
688
+	}
689 689
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
             'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
45 45
             $filepath && EEH_File::is_in_uploads_folder($filepath),
46 46
             $filepath
47
-        ) ) {
48
-            if (! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
49
-                require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
47
+        )) {
48
+            if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
49
+                require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
50 50
                 $method = 'direct';
51
-                $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
51
+                $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
52 52
                 // check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
53
-                if (! defined('FS_CHMOD_DIR')) {
54
-                    define('FS_CHMOD_DIR', ( fileperms(ABSPATH) & 0777 | 0755 ));
53
+                if ( ! defined('FS_CHMOD_DIR')) {
54
+                    define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
55 55
                 }
56
-                if (! defined('FS_CHMOD_FILE')) {
57
-                    define('FS_CHMOD_FILE', ( fileperms(ABSPATH . 'index.php') & 0777 | 0644 ));
56
+                if ( ! defined('FS_CHMOD_FILE')) {
57
+                    define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
58 58
                 }
59 59
                 require_once($wp_filesystem_direct_file);
60 60
                 EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         }
64 64
         global $wp_filesystem;
65 65
         // no filesystem setup ???
66
-        if (! $wp_filesystem instanceof WP_Filesystem_Base) {
66
+        if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
67 67
             // if some eager beaver's just trying to get in there too early...
68 68
             // let them do it, because we are one of those eager beavers! :P
69 69
             /**
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
             if (false && ! did_action('wp_loaded')) {
80 80
                 $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
81 81
                 if (WP_DEBUG) {
82
-                    $msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
82
+                    $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
83 83
                 }
84 84
                 throw new EE_Error($msg);
85 85
             } else {
86 86
                 // should be loaded if we are past the wp_loaded hook...
87
-                if (! function_exists('WP_Filesystem')) {
88
-                    require_once(ABSPATH . 'wp-admin/includes/file.php');
89
-                    require_once(ABSPATH . 'wp-admin/includes/template.php');
87
+                if ( ! function_exists('WP_Filesystem')) {
88
+                    require_once(ABSPATH.'wp-admin/includes/file.php');
89
+                    require_once(ABSPATH.'wp-admin/includes/template.php');
90 90
                 }
91 91
                 // turn on output buffering so that we can capture the credentials form
92 92
                 ob_start();
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
                 // store credentials form for the time being
95 95
                 EEH_File::$_credentials_form = ob_get_clean();
96 96
                 // basically check for direct or previously configured access
97
-                if (! WP_Filesystem($credentials)) {
97
+                if ( ! WP_Filesystem($credentials)) {
98 98
                     // if credentials do NOT exist
99 99
                     if ($credentials === false) {
100
-                        add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
100
+                        add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
101 101
                         throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
102 102
                     } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
103
-                        add_action('admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999);
103
+                        add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
104 104
                         throw new EE_Error(
105 105
                             sprintf(
106 106
                                 __('WP Filesystem Error: $1%s', 'event_espresso'),
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public static function display_request_filesystem_credentials_form()
121 121
     {
122
-        if (! empty(EEH_File::$_credentials_form)) {
123
-            echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
122
+        if ( ! empty(EEH_File::$_credentials_form)) {
123
+            echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
124 124
         }
125 125
     }
126 126
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
         // load WP_Filesystem and set file permissions
144 144
         $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
145 145
         $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
146
-        if (! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
147
-            $file_name = ! empty($type_of_file) ? $file_name . ' ' . $type_of_file : $file_name;
146
+        if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
147
+            $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
148 148
             $file_name .= ! empty($file_ext) ? ' file' : ' folder';
149 149
             $msg = sprintf(
150 150
                 __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                 );
162 162
             }
163 163
             if (defined('WP_DEBUG') && WP_DEBUG) {
164
-                throw new EE_Error($msg . '||' . $msg);
164
+                throw new EE_Error($msg.'||'.$msg);
165 165
             }
166 166
             return false;
167 167
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
188 188
         if ($perms) {
189 189
             // file permissions exist, but way be set incorrectly
190
-            $type_of_file = ! empty($type_of_file) ? $type_of_file . ' ' : '';
190
+            $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
191 191
             $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
192 192
             return sprintf(
193 193
                 __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
         // add DS to folder
227 227
         $folder = EEH_File::end_with_directory_separator($folder);
228 228
         $wp_filesystem = EEH_File::_get_wp_filesystem($folder);
229
-        if (! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
229
+        if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
230 230
             // ok so it doesn't exist. Does its parent? Can we write to it?
231
-            if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
231
+            if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
232 232
                 return false;
233 233
             }
234
-            if (! EEH_File::verify_is_writable($parent_folder, 'folder')) {
234
+            if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
235 235
                 return false;
236 236
             } else {
237
-                if (! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
237
+                if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
238 238
                     if (defined('WP_DEBUG') && WP_DEBUG) {
239 239
                         $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
240 240
                         $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 }
245 245
                 EEH_File::add_index_file($folder);
246 246
             }
247
-        } elseif (! EEH_File::verify_is_writable($folder, 'folder')) {
247
+        } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
248 248
             return false;
249 249
         }
250 250
         return true;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         // load WP_Filesystem and set file permissions
265 265
         $wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
266 266
         $full_path = EEH_File::standardise_directory_separators($full_path);
267
-        if (! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
267
+        if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
268 268
             if (defined('WP_DEBUG') && WP_DEBUG) {
269 269
                 $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
270 270
                 $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
         $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
292 292
         $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
293 293
         $parent_folder = EEH_File::get_parent_folder($full_file_path);
294
-        if (! EEH_File::exists($full_file_path)) {
295
-            if (! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
294
+        if ( ! EEH_File::exists($full_file_path)) {
295
+            if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
296 296
                 return false;
297 297
             }
298
-            if (! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
298
+            if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
299 299
                 if (defined('WP_DEBUG') && WP_DEBUG) {
300 300
                     $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
301 301
                     $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                 return false;
305 305
             }
306 306
         }
307
-        if (! EEH_File::verify_is_writable($full_file_path, 'file')) {
307
+        if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
308 308
             return false;
309 309
         }
310 310
         return true;
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
     public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '')
364 364
     {
365 365
         $full_file_path = EEH_File::standardise_directory_separators($full_file_path);
366
-        $file_type = ! empty($file_type) ? rtrim($file_type, ' ') . ' ' : '';
366
+        $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
367 367
         $folder = EEH_File::remove_filename_from_filepath($full_file_path);
368
-        if (! EEH_File::verify_is_writable($folder, 'folder')) {
368
+        if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
369 369
             if (defined('WP_DEBUG') && WP_DEBUG) {
370 370
                 $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
371 371
                 $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         // load WP_Filesystem and set file permissions
377 377
         $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
378 378
         // write the file
379
-        if (! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
379
+        if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
380 380
             if (defined('WP_DEBUG') && WP_DEBUG) {
381 381
                 $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
382 382
                 $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
     public static function add_htaccess_deny_from_all($folder = '')
487 487
     {
488 488
         $folder = EEH_File::standardise_and_end_with_directory_separator($folder);
489
-        if (! EEH_File::exists($folder . '.htaccess')) {
490
-            if (! EEH_File::write_to_file($folder . '.htaccess', 'deny from all', '.htaccess')) {
489
+        if ( ! EEH_File::exists($folder.'.htaccess')) {
490
+            if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
491 491
                 return false;
492 492
             }
493 493
         }
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
     public static function add_index_file($folder)
505 505
     {
506 506
         $folder = EEH_File::standardise_and_end_with_directory_separator($folder);
507
-        if (! EEH_File::exists($folder . 'index.php')) {
508
-            if (! EEH_File::write_to_file($folder . 'index.php', 'You are not permitted to read from this folder', '.php')) {
507
+        if ( ! EEH_File::exists($folder.'index.php')) {
508
+            if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) {
509 509
                 return false;
510 510
             }
511 511
         }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
      */
540 540
     public static function standardise_directory_separators($file_path)
541 541
     {
542
-        return str_replace(array( '\\', '/' ), DS, $file_path);
542
+        return str_replace(array('\\', '/'), DS, $file_path);
543 543
     }
544 544
 
545 545
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
      */
553 553
     public static function end_with_directory_separator($file_path)
554 554
     {
555
-        return rtrim($file_path, '/\\') . DS;
555
+        return rtrim($file_path, '/\\').DS;
556 556
     }
557 557
 
558 558
 
@@ -587,17 +587,17 @@  discard block
 block discarded – undo
587 587
         foreach ($folder_paths as $folder_path) {
588 588
             $folder_path = self::standardise_and_end_with_directory_separator($folder_path);
589 589
             // load WP_Filesystem and set file permissions
590
-            $files_in_folder = glob($folder_path . '*');
590
+            $files_in_folder = glob($folder_path.'*');
591 591
             $class_to_folder_path = array();
592 592
             if ($files_in_folder) {
593 593
                 foreach ($files_in_folder as $file_path) {
594 594
                     // only add files, not folders
595
-                    if (! is_dir($file_path)) {
595
+                    if ( ! is_dir($file_path)) {
596 596
                         if ($index_numerically) {
597 597
                             $class_to_folder_path[] = $file_path;
598 598
                         } else {
599 599
                             $classname = self::get_classname_from_filepath_with_standard_filename($file_path);
600
-                            $class_to_folder_path[ $classname ] = $file_path;
600
+                            $class_to_folder_path[$classname] = $file_path;
601 601
                         }
602 602
                     }
603 603
                 }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     public static function copy($source_file, $destination_file, $overwrite = false)
620 620
     {
621 621
         $full_source_path = EEH_File::standardise_directory_separators($source_file);
622
-        if (! EEH_File::exists($full_source_path)) {
622
+        if ( ! EEH_File::exists($full_source_path)) {
623 623
             if (defined('WP_DEBUG') && WP_DEBUG) {
624 624
                 $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
625 625
                 $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
         $full_dest_path = EEH_File::standardise_directory_separators($destination_file);
632 632
         $folder = EEH_File::remove_filename_from_filepath($full_dest_path);
633 633
         EEH_File::ensure_folder_exists_and_is_writable($folder);
634
-        if (! EEH_File::verify_is_writable($folder, 'folder')) {
634
+        if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
635 635
             if (defined('WP_DEBUG') && WP_DEBUG) {
636 636
                 $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
637 637
                 $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
         // load WP_Filesystem and set file permissions
644 644
         $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
645 645
         // write the file
646
-        if (! $wp_filesystem->copy(
646
+        if ( ! $wp_filesystem->copy(
647 647
             EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
648 648
             EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
649 649
             $overwrite
@@ -684,6 +684,6 @@  discard block
 block discarded – undo
684 684
     public static function convert_local_filepath_to_remote_filepath($local_filepath)
685 685
     {
686 686
         $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
687
-        return str_replace(WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath);
687
+        return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
688 688
     }
689 689
 }
Please login to merge, or discard this patch.