Completed
Branch BUG/11288/fix-datepicker (d15367)
by
unknown
108:07 queued 94:31
created
core/services/currency/Calculator.php 2 patches
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -9,110 +9,110 @@
 block discarded – undo
9 9
 interface Calculator
10 10
 {
11 11
 
12
-    /**
13
-     * Round val up to precision decimal places AWAY from zero,
14
-     * when it is half way there. Making 1.5 into 2 and -1.5 into -2.
15
-     */
16
-    const ROUND_HALF_UP   = PHP_ROUND_HALF_UP;
17
-
18
-    /**
19
-     * Round val down to precision decimal places TOWARDS zero,
20
-     * when it is half way there. Making 1.5 into 1 and -1.5 into -1.
21
-     */
22
-    const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN;
23
-
24
-    /**
25
-     * Round val to precision decimal places towards the next even value.
26
-     */
27
-    const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN;
28
-
29
-    /**
30
-     * Round val to precision decimal places towards the next odd value.
31
-     */
32
-    const ROUND_HALF_ODD  = PHP_ROUND_HALF_ODD;
33
-
34
-    /**
35
-     * Round val up to the next highest integer
36
-     */
37
-    const ROUND_UP = 5;
38
-
39
-    /**
40
-     * Round val down to the next lowest integer
41
-     */
42
-    const ROUND_DOWN = 6;
43
-
44
-
45
-
46
-    /**
47
-     * returns true if a calculator is supported as determined by loaded server extensions
48
-     *
49
-     * @return bool
50
-     */
51
-    public function isSupported();
52
-
53
-
54
-
55
-    /**
56
-     * adds the supplied Money amount to this Money amount
57
-     * and returns a new Money object
58
-     *
59
-     * @param string           $amount
60
-     * @param float|int|string $amount_to_add
61
-     * @return string
62
-     */
63
-    public function add($amount, $amount_to_add);
64
-
65
-
66
-
67
-    /**
68
-     * subtracts the supplied Money amount from this Money amount
69
-     * and returns a new Money object
70
-     *
71
-     * @param string           $amount
72
-     * @param float|int|string $amount_to_subtract
73
-     * @return string
74
-     */
75
-    public function subtract($amount, $amount_to_subtract);
76
-
77
-
78
-
79
-    /**
80
-     * multiplies this Money amount by the supplied $multiplier
81
-     * and returns a new Money object
82
-     *
83
-     * @param string           $amount
84
-     * @param float|int|string $multiplier
85
-     * @param int              $precision
86
-     * @param int              $rounding_mode
87
-     * @return string
88
-     */
89
-    public function multiply($amount, $multiplier, $precision, $rounding_mode);
90
-
91
-
92
-
93
-    /**
94
-     * divides this Money amount by the supplied $divisor
95
-     * and returns a new Money object
96
-     *
97
-     * @param string           $amount
98
-     * @param float|int|string $divisor
99
-     * @param int              $precision
100
-     * @param int              $rounding_mode
101
-     * @return string
102
-     */
103
-    public function divide($amount, $divisor, $precision, $rounding_mode);
104
-
105
-
106
-
107
-    /**
108
-     * adjust amount according to precision and rounding mode
109
-     *
110
-     * @param int|float $amount
111
-     * @param int       $precision
112
-     * @param int       $rounding_mode
113
-     * @return string
114
-     */
115
-    public function round($amount, $precision, $rounding_mode);
12
+	/**
13
+	 * Round val up to precision decimal places AWAY from zero,
14
+	 * when it is half way there. Making 1.5 into 2 and -1.5 into -2.
15
+	 */
16
+	const ROUND_HALF_UP   = PHP_ROUND_HALF_UP;
17
+
18
+	/**
19
+	 * Round val down to precision decimal places TOWARDS zero,
20
+	 * when it is half way there. Making 1.5 into 1 and -1.5 into -1.
21
+	 */
22
+	const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN;
23
+
24
+	/**
25
+	 * Round val to precision decimal places towards the next even value.
26
+	 */
27
+	const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN;
28
+
29
+	/**
30
+	 * Round val to precision decimal places towards the next odd value.
31
+	 */
32
+	const ROUND_HALF_ODD  = PHP_ROUND_HALF_ODD;
33
+
34
+	/**
35
+	 * Round val up to the next highest integer
36
+	 */
37
+	const ROUND_UP = 5;
38
+
39
+	/**
40
+	 * Round val down to the next lowest integer
41
+	 */
42
+	const ROUND_DOWN = 6;
43
+
44
+
45
+
46
+	/**
47
+	 * returns true if a calculator is supported as determined by loaded server extensions
48
+	 *
49
+	 * @return bool
50
+	 */
51
+	public function isSupported();
52
+
53
+
54
+
55
+	/**
56
+	 * adds the supplied Money amount to this Money amount
57
+	 * and returns a new Money object
58
+	 *
59
+	 * @param string           $amount
60
+	 * @param float|int|string $amount_to_add
61
+	 * @return string
62
+	 */
63
+	public function add($amount, $amount_to_add);
64
+
65
+
66
+
67
+	/**
68
+	 * subtracts the supplied Money amount from this Money amount
69
+	 * and returns a new Money object
70
+	 *
71
+	 * @param string           $amount
72
+	 * @param float|int|string $amount_to_subtract
73
+	 * @return string
74
+	 */
75
+	public function subtract($amount, $amount_to_subtract);
76
+
77
+
78
+
79
+	/**
80
+	 * multiplies this Money amount by the supplied $multiplier
81
+	 * and returns a new Money object
82
+	 *
83
+	 * @param string           $amount
84
+	 * @param float|int|string $multiplier
85
+	 * @param int              $precision
86
+	 * @param int              $rounding_mode
87
+	 * @return string
88
+	 */
89
+	public function multiply($amount, $multiplier, $precision, $rounding_mode);
90
+
91
+
92
+
93
+	/**
94
+	 * divides this Money amount by the supplied $divisor
95
+	 * and returns a new Money object
96
+	 *
97
+	 * @param string           $amount
98
+	 * @param float|int|string $divisor
99
+	 * @param int              $precision
100
+	 * @param int              $rounding_mode
101
+	 * @return string
102
+	 */
103
+	public function divide($amount, $divisor, $precision, $rounding_mode);
104
+
105
+
106
+
107
+	/**
108
+	 * adjust amount according to precision and rounding mode
109
+	 *
110
+	 * @param int|float $amount
111
+	 * @param int       $precision
112
+	 * @param int       $rounding_mode
113
+	 * @return string
114
+	 */
115
+	public function round($amount, $precision, $rounding_mode);
116 116
 
117 117
 
118 118
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Round val up to precision decimal places AWAY from zero,
14 14
      * when it is half way there. Making 1.5 into 2 and -1.5 into -2.
15 15
      */
16
-    const ROUND_HALF_UP   = PHP_ROUND_HALF_UP;
16
+    const ROUND_HALF_UP = PHP_ROUND_HALF_UP;
17 17
 
18 18
     /**
19 19
      * Round val down to precision decimal places TOWARDS zero,
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * Round val to precision decimal places towards the next odd value.
31 31
      */
32
-    const ROUND_HALF_ODD  = PHP_ROUND_HALF_ODD;
32
+    const ROUND_HALF_ODD = PHP_ROUND_HALF_ODD;
33 33
 
34 34
     /**
35 35
      * Round val up to the next highest integer
Please login to merge, or discard this patch.
core/services/currency/CalculatorBase.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -19,72 +19,72 @@
 block discarded – undo
19 19
 abstract class CalculatorBase implements Calculator
20 20
 {
21 21
 
22
-    /**
23
-     * @param int|float $amount
24
-     * @param int       $precision
25
-     * @param int       $rounding_mode
26
-     * @return string
27
-     * @throws InvalidArgumentException
28
-     */
29
-    public function round($amount, $precision, $rounding_mode)
30
-    {
31
-        $this->verifyRoundingMode($rounding_mode);
32
-        if ($rounding_mode === Calculator::ROUND_UP) {
33
-            return (string) ceil($amount);
34
-        }
35
-        if ($rounding_mode === Calculator::ROUND_DOWN) {
36
-            return (string) floor($amount);
37
-        }
38
-        return (string) round($amount, $precision, $rounding_mode);
39
-    }
40
-
41
-
42
-
43
-    /**
44
-     * Asserts that rounding mode is a valid integer value.
45
-     *
46
-     * @param int $rounding_mode
47
-     * @throws InvalidArgumentException If $roundingMode is not valid
48
-     */
49
-    private function verifyRoundingMode($rounding_mode)
50
-    {
51
-        if (
52
-        ! in_array(
53
-            $rounding_mode,
54
-            array(
55
-                Calculator::ROUND_UP,
56
-                Calculator::ROUND_DOWN,
57
-                Calculator::ROUND_HALF_DOWN,
58
-                Calculator::ROUND_HALF_EVEN,
59
-                Calculator::ROUND_HALF_ODD,
60
-                Calculator::ROUND_HALF_UP,
61
-            ),
62
-            true
63
-        )
64
-        ) {
65
-            throw new InvalidArgumentException(
66
-                esc_html__(
67
-                    'Rounding mode should be one of the following: Calculator::ROUND_UP, Calculator::ROUND_DOWN, Calculator::ROUND_HALF_DOWN, Calculator::ROUND_HALF_EVEN, Calculator::ROUND_HALF_ODD, or Calculator::ROUND_HALF_UP.',
68
-                    'event_espresso'
69
-                )
70
-            );
71
-        }
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * @param $divisor
78
-     * @throws InvalidArgumentException
79
-     */
80
-    protected function validateDivisor($divisor)
81
-    {
82
-        if ((int)$divisor === 0) {
83
-            throw new InvalidArgumentException(
84
-                esc_html__('Division by zero.', 'event_espresso')
85
-            );
86
-        }
87
-    }
22
+	/**
23
+	 * @param int|float $amount
24
+	 * @param int       $precision
25
+	 * @param int       $rounding_mode
26
+	 * @return string
27
+	 * @throws InvalidArgumentException
28
+	 */
29
+	public function round($amount, $precision, $rounding_mode)
30
+	{
31
+		$this->verifyRoundingMode($rounding_mode);
32
+		if ($rounding_mode === Calculator::ROUND_UP) {
33
+			return (string) ceil($amount);
34
+		}
35
+		if ($rounding_mode === Calculator::ROUND_DOWN) {
36
+			return (string) floor($amount);
37
+		}
38
+		return (string) round($amount, $precision, $rounding_mode);
39
+	}
40
+
41
+
42
+
43
+	/**
44
+	 * Asserts that rounding mode is a valid integer value.
45
+	 *
46
+	 * @param int $rounding_mode
47
+	 * @throws InvalidArgumentException If $roundingMode is not valid
48
+	 */
49
+	private function verifyRoundingMode($rounding_mode)
50
+	{
51
+		if (
52
+		! in_array(
53
+			$rounding_mode,
54
+			array(
55
+				Calculator::ROUND_UP,
56
+				Calculator::ROUND_DOWN,
57
+				Calculator::ROUND_HALF_DOWN,
58
+				Calculator::ROUND_HALF_EVEN,
59
+				Calculator::ROUND_HALF_ODD,
60
+				Calculator::ROUND_HALF_UP,
61
+			),
62
+			true
63
+		)
64
+		) {
65
+			throw new InvalidArgumentException(
66
+				esc_html__(
67
+					'Rounding mode should be one of the following: Calculator::ROUND_UP, Calculator::ROUND_DOWN, Calculator::ROUND_HALF_DOWN, Calculator::ROUND_HALF_EVEN, Calculator::ROUND_HALF_ODD, or Calculator::ROUND_HALF_UP.',
68
+					'event_espresso'
69
+				)
70
+			);
71
+		}
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * @param $divisor
78
+	 * @throws InvalidArgumentException
79
+	 */
80
+	protected function validateDivisor($divisor)
81
+	{
82
+		if ((int)$divisor === 0) {
83
+			throw new InvalidArgumentException(
84
+				esc_html__('Division by zero.', 'event_espresso')
85
+			);
86
+		}
87
+	}
88 88
 
89 89
 
90 90
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
      */
80 80
     protected function validateDivisor($divisor)
81 81
     {
82
-        if ((int)$divisor === 0) {
82
+        if ((int) $divisor === 0) {
83 83
             throw new InvalidArgumentException(
84 84
                 esc_html__('Division by zero.', 'event_espresso')
85 85
             );
Please login to merge, or discard this patch.
core/entities/Label.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,49 +17,49 @@
 block discarded – undo
17 17
 class Label
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $singular
22
-     */
23
-    public $singular;
20
+	/**
21
+	 * @var string $singular
22
+	 */
23
+	public $singular;
24 24
 
25
-    /**
26
-     * @var string $plural
27
-     */
28
-    public $plural;
25
+	/**
26
+	 * @var string $plural
27
+	 */
28
+	public $plural;
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * Label constructor.
34
-     *
35
-     * @param string $singular
36
-     * @param string $plural
37
-     */
38
-    public function __construct($singular, $plural)
39
-    {
40
-        $this->singular = $singular;
41
-        $this->plural = $plural;
42
-    }
32
+	/**
33
+	 * Label constructor.
34
+	 *
35
+	 * @param string $singular
36
+	 * @param string $plural
37
+	 */
38
+	public function __construct($singular, $plural)
39
+	{
40
+		$this->singular = $singular;
41
+		$this->plural = $plural;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * @return string
48
-     */
49
-    public function singular()
50
-    {
51
-        return $this->singular;
52
-    }
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function singular()
50
+	{
51
+		return $this->singular;
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * @return string
58
-     */
59
-    public function plural()
60
-    {
61
-        return $this->plural;
62
-    }
56
+	/**
57
+	 * @return string
58
+	 */
59
+	public function plural()
60
+	{
61
+		return $this->plural;
62
+	}
63 63
 
64 64
 
65 65
 
Please login to merge, or discard this patch.
core/services/currency/DefaultCalculator.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -21,82 +21,82 @@
 block discarded – undo
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * returns true if a calculator is supported as determined by loaded server extensions
26
-     *
27
-     * @return bool
28
-     */
29
-    public function isSupported()
30
-    {
31
-        return true;
32
-    }
33
-
34
-
35
-
36
-    /**
37
-     * adds the supplied Money amount to this Money amount
38
-     * and returns a new Money object
39
-     *
40
-     * @param float|int|string $amount
41
-     * @param float|int|string $amount_to_add
42
-     * @return string
43
-     */
44
-    public function add($amount, $amount_to_add)
45
-    {
46
-        return (string) ($amount + $amount_to_add);
47
-    }
48
-
49
-
50
-
51
-    /**
52
-     * subtracts the supplied Money amount from this Money amount
53
-     * and returns a new Money object
54
-     *
55
-     * @param float|int|string $amount
56
-     * @param float|int|string $amount_to_subtract
57
-     * @return string
58
-     */
59
-    public function subtract($amount, $amount_to_subtract)
60
-    {
61
-        return (string) ($amount - $amount_to_subtract);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * multiplies this Money amount by the supplied $multiplier
68
-     * and returns a new Money object
69
-     *
70
-     * @param float|int|string $amount
71
-     * @param float|int|string $multiplier
72
-     * @param int              $precision
73
-     * @param int              $rounding_mode
74
-     * @return string
75
-     * @throws InvalidArgumentException
76
-     */
77
-    public function multiply($amount, $multiplier, $precision = 3, $rounding_mode = Calculator::ROUND_HALF_UP)
78
-    {
79
-        return $this->round($amount * $multiplier, $precision, $rounding_mode);
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * divides this Money amount by the supplied $divisor
86
-     * and returns a new Money object
87
-     *
88
-     * @param float|int|string $amount
89
-     * @param float|int|string $divisor
90
-     * @param int              $precision
91
-     * @param int              $rounding_mode
92
-     * @return string
93
-     * @throws InvalidArgumentException
94
-     */
95
-    public function divide($amount, $divisor, $precision = 3, $rounding_mode = Calculator::ROUND_HALF_UP)
96
-    {
97
-        $this->validateDivisor($divisor);
98
-        return $this->round($amount / $divisor, $precision, $rounding_mode);
99
-    }
24
+	/**
25
+	 * returns true if a calculator is supported as determined by loaded server extensions
26
+	 *
27
+	 * @return bool
28
+	 */
29
+	public function isSupported()
30
+	{
31
+		return true;
32
+	}
33
+
34
+
35
+
36
+	/**
37
+	 * adds the supplied Money amount to this Money amount
38
+	 * and returns a new Money object
39
+	 *
40
+	 * @param float|int|string $amount
41
+	 * @param float|int|string $amount_to_add
42
+	 * @return string
43
+	 */
44
+	public function add($amount, $amount_to_add)
45
+	{
46
+		return (string) ($amount + $amount_to_add);
47
+	}
48
+
49
+
50
+
51
+	/**
52
+	 * subtracts the supplied Money amount from this Money amount
53
+	 * and returns a new Money object
54
+	 *
55
+	 * @param float|int|string $amount
56
+	 * @param float|int|string $amount_to_subtract
57
+	 * @return string
58
+	 */
59
+	public function subtract($amount, $amount_to_subtract)
60
+	{
61
+		return (string) ($amount - $amount_to_subtract);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * multiplies this Money amount by the supplied $multiplier
68
+	 * and returns a new Money object
69
+	 *
70
+	 * @param float|int|string $amount
71
+	 * @param float|int|string $multiplier
72
+	 * @param int              $precision
73
+	 * @param int              $rounding_mode
74
+	 * @return string
75
+	 * @throws InvalidArgumentException
76
+	 */
77
+	public function multiply($amount, $multiplier, $precision = 3, $rounding_mode = Calculator::ROUND_HALF_UP)
78
+	{
79
+		return $this->round($amount * $multiplier, $precision, $rounding_mode);
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * divides this Money amount by the supplied $divisor
86
+	 * and returns a new Money object
87
+	 *
88
+	 * @param float|int|string $amount
89
+	 * @param float|int|string $divisor
90
+	 * @param int              $precision
91
+	 * @param int              $rounding_mode
92
+	 * @return string
93
+	 * @throws InvalidArgumentException
94
+	 */
95
+	public function divide($amount, $divisor, $precision = 3, $rounding_mode = Calculator::ROUND_HALF_UP)
96
+	{
97
+		$this->validateDivisor($divisor);
98
+		return $this->round($amount / $divisor, $precision, $rounding_mode);
99
+	}
100 100
 
101 101
 
102 102
 
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\loaders\LoaderFactory;
5 5
 use EventEspresso\core\services\loaders\LoaderInterface;
6 6
 
7
-if (! defined('EVENT_ESPRESSO_VERSION')) {
7
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8 8
     exit('No direct script access allowed');
9 9
 }
10 10
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public static function instance(EE_Request $request = null, EE_Response $response = null)
131 131
     {
132 132
         // check if class object is instantiated, and instantiated properly
133
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
134 134
             self::$_instance = new EE_Dependency_Map($request, $response);
135 135
         }
136 136
         return self::$_instance;
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
     ) {
186 186
         $class = trim($class, '\\');
187 187
         $registered = false;
188
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
189
-            self::$_instance->_dependency_map[ $class ] = array();
188
+        if (empty(self::$_instance->_dependency_map[$class])) {
189
+            self::$_instance->_dependency_map[$class] = array();
190 190
         }
191 191
         // we need to make sure that any aliases used when registering a dependency
192 192
         // get resolved to the correct class name
193
-        foreach ((array)$dependencies as $dependency => $load_source) {
193
+        foreach ((array) $dependencies as $dependency => $load_source) {
194 194
             $alias = self::$_instance->get_alias($dependency);
195 195
             if (
196 196
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
197
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
198 198
             ) {
199 199
                 unset($dependencies[$dependency]);
200 200
                 $dependencies[$alias] = $load_source;
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
208 208
         // Union is way faster than array_merge() but should be used with caution...
209 209
         // especially with numerically indexed arrays
210
-        $dependencies += self::$_instance->_dependency_map[ $class ];
210
+        $dependencies += self::$_instance->_dependency_map[$class];
211 211
         // now we need to ensure that the resulting dependencies
212 212
         // array only has the entries that are required for the class
213 213
         // so first count how many dependencies were originally registered for the class
214
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
214
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
215 215
         // if that count is non-zero (meaning dependencies were already registered)
216
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
216
+        self::$_instance->_dependency_map[$class] = $dependency_count
217 217
             // then truncate the  final array to match that count
218 218
             ? array_slice($dependencies, 0, $dependency_count)
219 219
             // otherwise just take the incoming array because nothing previously existed
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public static function register_class_loader($class_name, $loader = 'load_core')
233 233
     {
234
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
234
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235 235
             throw new DomainException(
236 236
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237 237
             );
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             );
256 256
         }
257 257
         $class_name = self::$_instance->get_alias($class_name);
258
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
258
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
259 259
             self::$_instance->_class_loaders[$class_name] = $loader;
260 260
             return true;
261 261
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function class_loader($class_name)
341 341
     {
342 342
         // all legacy models use load_model()
343
-        if(strpos($class_name, 'EEM_') === 0){
343
+        if (strpos($class_name, 'EEM_') === 0) {
344 344
             return 'load_model';
345 345
         }
346 346
         $class_name = $this->get_alias($class_name);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     public function add_alias($class_name, $alias, $for_class = '')
370 370
     {
371 371
         if ($for_class !== '') {
372
-            if (! isset($this->_aliases[$for_class])) {
372
+            if ( ! isset($this->_aliases[$for_class])) {
373 373
                 $this->_aliases[$for_class] = array();
374 374
             }
375 375
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function get_alias($class_name = '', $for_class = '')
417 417
     {
418
-        if (! $this->has_alias($class_name, $for_class)) {
418
+        if ( ! $this->has_alias($class_name, $for_class)) {
419 419
             return $class_name;
420 420
         }
421
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
421
+        if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) {
422 422
             return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423 423
         }
424 424
         return $this->get_alias($this->_aliases[$class_name]);
@@ -691,10 +691,10 @@  discard block
 block discarded – undo
691 691
             'EE_Front_Controller'                  => 'load_core',
692 692
             'EE_Module_Request_Router'             => 'load_core',
693 693
             'EE_Registry'                          => 'load_core',
694
-            'EE_Request'                           => function () use (&$request) {
694
+            'EE_Request'                           => function() use (&$request) {
695 695
                 return $request;
696 696
             },
697
-            'EE_Response'                          => function () use (&$response) {
697
+            'EE_Response'                          => function() use (&$response) {
698 698
                 return $response;
699 699
             },
700 700
             'EE_Request_Handler'                   => 'load_core',
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
717 717
             'EE_Message_Template_Group_Collection' => 'load_lib',
718 718
             'EE_Payment_Method_Manager'            => 'load_lib',
719
-            'EE_Messages_Generator'                => function () {
719
+            'EE_Messages_Generator'                => function() {
720 720
                 return EE_Registry::instance()->load_lib(
721 721
                     'Messages_Generator',
722 722
                     array(),
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
                     false
725 725
                 );
726 726
             },
727
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
727
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
728 728
                 return EE_Registry::instance()->load_lib(
729 729
                     'Messages_Template_Defaults',
730 730
                     $arguments,
@@ -737,25 +737,25 @@  discard block
 block discarded – undo
737 737
             // 'EEM_Message_Template_Group'           => 'load_model',
738 738
             // 'EEM_Message_Template'                 => 'load_model',
739 739
             //load_helper
740
-            'EEH_Parse_Shortcodes'                 => function () {
740
+            'EEH_Parse_Shortcodes'                 => function() {
741 741
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
742 742
                     return new EEH_Parse_Shortcodes();
743 743
                 }
744 744
                 return null;
745 745
             },
746
-            'EE_Template_Config'                   => function () {
746
+            'EE_Template_Config'                   => function() {
747 747
                 return EE_Config::instance()->template_settings;
748 748
             },
749
-            'EE_Currency_Config'                   => function () {
749
+            'EE_Currency_Config'                   => function() {
750 750
                 return EE_Config::instance()->currency;
751 751
             },
752
-            'EE_Registration_Config'                   => function () {
752
+            'EE_Registration_Config'                   => function() {
753 753
                 return EE_Config::instance()->registration;
754 754
             },
755
-            'EE_Organization_Config'                   => function () {
755
+            'EE_Organization_Config'                   => function() {
756 756
                 return EE_Config::instance()->organization;
757 757
             },
758
-            'EventEspresso\core\services\loaders\Loader' => function () {
758
+            'EventEspresso\core\services\loaders\Loader' => function() {
759 759
                 return LoaderFactory::getLoader();
760 760
             },
761 761
         );
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
             'EventEspresso\core\services\notices\NoticesContainerInterface'               => 'EventEspresso\core\services\notices\NoticesContainer',
810 810
             'EventEspresso\core\services\currency\Calculator'                             => 'EventEspresso\core\services\currency\DefaultCalculator',
811 811
         );
812
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
812
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
813 813
             $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
814 814
         }
815 815
     }
Please login to merge, or discard this patch.
Indentation   +815 added lines, -815 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderInterface;
6 6
 
7 7
 if (! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -22,820 +22,820 @@  discard block
 block discarded – undo
22 22
 class EE_Dependency_Map
23 23
 {
24 24
 
25
-    /**
26
-     * This means that the requested class dependency is not present in the dependency map
27
-     */
28
-    const not_registered = 0;
29
-
30
-    /**
31
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
-     */
33
-    const load_new_object = 1;
34
-
35
-    /**
36
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
-     */
39
-    const load_from_cache = 2;
40
-
41
-    /**
42
-     * When registering a dependency,
43
-     * this indicates to keep any existing dependencies that already exist,
44
-     * and simply discard any new dependencies declared in the incoming data
45
-     */
46
-    const KEEP_EXISTING_DEPENDENCIES = 0;
47
-
48
-    /**
49
-     * When registering a dependency,
50
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
-     */
52
-    const OVERWRITE_DEPENDENCIES = 1;
53
-
54
-
55
-
56
-    /**
57
-     * @type EE_Dependency_Map $_instance
58
-     */
59
-    protected static $_instance;
60
-
61
-    /**
62
-     * @type EE_Request $request
63
-     */
64
-    protected $_request;
65
-
66
-    /**
67
-     * @type EE_Response $response
68
-     */
69
-    protected $_response;
70
-
71
-    /**
72
-     * @type LoaderInterface $loader
73
-     */
74
-    protected $loader;
75
-
76
-    /**
77
-     * @type array $_dependency_map
78
-     */
79
-    protected $_dependency_map = array();
80
-
81
-    /**
82
-     * @type array $_class_loaders
83
-     */
84
-    protected $_class_loaders = array();
85
-
86
-    /**
87
-     * @type array $_aliases
88
-     */
89
-    protected $_aliases = array();
90
-
91
-
92
-
93
-    /**
94
-     * EE_Dependency_Map constructor.
95
-     *
96
-     * @param EE_Request  $request
97
-     * @param EE_Response $response
98
-     */
99
-    protected function __construct(EE_Request $request, EE_Response $response)
100
-    {
101
-        $this->_request = $request;
102
-        $this->_response = $response;
103
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
-        do_action('EE_Dependency_Map____construct');
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     * @throws InvalidArgumentException
113
-     */
114
-    public function initialize()
115
-    {
116
-        $this->_register_core_dependencies();
117
-        $this->_register_core_class_loaders();
118
-        $this->_register_core_aliases();
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * @singleton method used to instantiate class object
125
-     * @access    public
126
-     * @param EE_Request  $request
127
-     * @param EE_Response $response
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
131
-    {
132
-        // check if class object is instantiated, and instantiated properly
133
-        if (! self::$_instance instanceof EE_Dependency_Map) {
134
-            self::$_instance = new EE_Dependency_Map($request, $response);
135
-        }
136
-        return self::$_instance;
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     * @param LoaderInterface $loader
143
-     */
144
-    public function setLoader(LoaderInterface $loader)
145
-    {
146
-        $this->loader = $loader;
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @param string $class
153
-     * @param array  $dependencies
154
-     * @param int    $overwrite
155
-     * @return bool
156
-     */
157
-    public static function register_dependencies(
158
-        $class,
159
-        array $dependencies,
160
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
-    ) {
162
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Assigns an array of class names and corresponding load sources (new or cached)
169
-     * to the class specified by the first parameter.
170
-     * IMPORTANT !!!
171
-     * The order of elements in the incoming $dependencies array MUST match
172
-     * the order of the constructor parameters for the class in question.
173
-     * This is especially important when overriding any existing dependencies that are registered.
174
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
-     *
176
-     * @param string $class
177
-     * @param array  $dependencies
178
-     * @param int    $overwrite
179
-     * @return bool
180
-     */
181
-    public function registerDependencies(
182
-        $class,
183
-        array $dependencies,
184
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
-    ) {
186
-        $class = trim($class, '\\');
187
-        $registered = false;
188
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
189
-            self::$_instance->_dependency_map[ $class ] = array();
190
-        }
191
-        // we need to make sure that any aliases used when registering a dependency
192
-        // get resolved to the correct class name
193
-        foreach ((array)$dependencies as $dependency => $load_source) {
194
-            $alias = self::$_instance->get_alias($dependency);
195
-            if (
196
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
-            ) {
199
-                unset($dependencies[$dependency]);
200
-                $dependencies[$alias] = $load_source;
201
-                $registered = true;
202
-            }
203
-        }
204
-        // now add our two lists of dependencies together.
205
-        // using Union (+=) favours the arrays in precedence from left to right,
206
-        // so $dependencies is NOT overwritten because it is listed first
207
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
-        // Union is way faster than array_merge() but should be used with caution...
209
-        // especially with numerically indexed arrays
210
-        $dependencies += self::$_instance->_dependency_map[ $class ];
211
-        // now we need to ensure that the resulting dependencies
212
-        // array only has the entries that are required for the class
213
-        // so first count how many dependencies were originally registered for the class
214
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
-        // if that count is non-zero (meaning dependencies were already registered)
216
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
217
-            // then truncate the  final array to match that count
218
-            ? array_slice($dependencies, 0, $dependency_count)
219
-            // otherwise just take the incoming array because nothing previously existed
220
-            : $dependencies;
221
-        return $registered;
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * @param string $class_name
228
-     * @param string $loader
229
-     * @return bool
230
-     * @throws DomainException
231
-     */
232
-    public static function register_class_loader($class_name, $loader = 'load_core')
233
-    {
234
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
-            throw new DomainException(
236
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
-            );
238
-        }
239
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
240
-        if (
241
-            ! is_callable($loader)
242
-            && (
243
-                strpos($loader, 'load_') !== 0
244
-                || ! method_exists('EE_Registry', $loader)
245
-            )
246
-        ) {
247
-            throw new DomainException(
248
-                sprintf(
249
-                    esc_html__(
250
-                        '"%1$s" is not a valid loader method on EE_Registry.',
251
-                        'event_espresso'
252
-                    ),
253
-                    $loader
254
-                )
255
-            );
256
-        }
257
-        $class_name = self::$_instance->get_alias($class_name);
258
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
-            self::$_instance->_class_loaders[$class_name] = $loader;
260
-            return true;
261
-        }
262
-        return false;
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * @return array
269
-     */
270
-    public function dependency_map()
271
-    {
272
-        return $this->_dependency_map;
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * returns TRUE if dependency map contains a listing for the provided class name
279
-     *
280
-     * @param string $class_name
281
-     * @return boolean
282
-     */
283
-    public function has($class_name = '')
284
-    {
285
-        // all legacy models have the same dependencies
286
-        if (strpos($class_name, 'EEM_') === 0) {
287
-            $class_name = 'LEGACY_MODELS';
288
-        }
289
-        return isset($this->_dependency_map[$class_name]) ? true : false;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
-     *
297
-     * @param string $class_name
298
-     * @param string $dependency
299
-     * @return bool
300
-     */
301
-    public function has_dependency_for_class($class_name = '', $dependency = '')
302
-    {
303
-        // all legacy models have the same dependencies
304
-        if (strpos($class_name, 'EEM_') === 0) {
305
-            $class_name = 'LEGACY_MODELS';
306
-        }
307
-        $dependency = $this->get_alias($dependency);
308
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
-            ? true
310
-            : false;
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
-     *
318
-     * @param string $class_name
319
-     * @param string $dependency
320
-     * @return int
321
-     */
322
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
-    {
324
-        // all legacy models have the same dependencies
325
-        if (strpos($class_name, 'EEM_') === 0) {
326
-            $class_name = 'LEGACY_MODELS';
327
-        }
328
-        $dependency = $this->get_alias($dependency);
329
-        return $this->has_dependency_for_class($class_name, $dependency)
330
-            ? $this->_dependency_map[$class_name][$dependency]
331
-            : EE_Dependency_Map::not_registered;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * @param string $class_name
338
-     * @return string | Closure
339
-     */
340
-    public function class_loader($class_name)
341
-    {
342
-        // all legacy models use load_model()
343
-        if(strpos($class_name, 'EEM_') === 0){
344
-            return 'load_model';
345
-        }
346
-        $class_name = $this->get_alias($class_name);
347
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * @return array
354
-     */
355
-    public function class_loaders()
356
-    {
357
-        return $this->_class_loaders;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * adds an alias for a classname
364
-     *
365
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
366
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
-     */
369
-    public function add_alias($class_name, $alias, $for_class = '')
370
-    {
371
-        if ($for_class !== '') {
372
-            if (! isset($this->_aliases[$for_class])) {
373
-                $this->_aliases[$for_class] = array();
374
-            }
375
-            $this->_aliases[$for_class][$class_name] = $alias;
376
-        }
377
-        $this->_aliases[$class_name] = $alias;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * returns TRUE if the provided class name has an alias
384
-     *
385
-     * @param string $class_name
386
-     * @param string $for_class
387
-     * @return bool
388
-     */
389
-    public function has_alias($class_name = '', $for_class = '')
390
-    {
391
-        return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
-               || (
393
-                   isset($this->_aliases[$class_name])
394
-                   && ! is_array($this->_aliases[$class_name])
395
-               );
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     * returns alias for class name if one exists, otherwise returns the original classname
402
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
403
-     *  for example:
404
-     *      if the following two entries were added to the _aliases array:
405
-     *          array(
406
-     *              'interface_alias'           => 'some\namespace\interface'
407
-     *              'some\namespace\interface'  => 'some\namespace\classname'
408
-     *          )
409
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
-     *      to load an instance of 'some\namespace\classname'
411
-     *
412
-     * @param string $class_name
413
-     * @param string $for_class
414
-     * @return string
415
-     */
416
-    public function get_alias($class_name = '', $for_class = '')
417
-    {
418
-        if (! $this->has_alias($class_name, $for_class)) {
419
-            return $class_name;
420
-        }
421
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
-        }
424
-        return $this->get_alias($this->_aliases[$class_name]);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
-     * This is done by using the following class constants:
433
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
435
-     */
436
-    protected function _register_core_dependencies()
437
-    {
438
-        $this->_dependency_map = array(
439
-            'EE_Request_Handler'                                                                                          => array(
440
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_System'                                                                                                   => array(
443
-                'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
-                'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
-                'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
-                'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_Session'                                                                                                  => array(
450
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
-            ),
453
-            'EE_Cart'                                                                                                     => array(
454
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
455
-            ),
456
-            'EE_Front_Controller'                                                                                         => array(
457
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_Messenger_Collection_Loader'                                                                              => array(
462
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
-            ),
464
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
465
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
-            ),
467
-            'EE_Message_Resource_Manager'                                                                                 => array(
468
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
-            ),
472
-            'EE_Message_Factory'                                                                                          => array(
473
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
-            ),
475
-            'EE_messages'                                                                                                 => array(
476
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
-            ),
478
-            'EE_Messages_Generator'                                                                                       => array(
479
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_Messages_Processor'                                                                                       => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Queue'                                                                                           => array(
488
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
-            ),
490
-            'EE_Messages_Template_Defaults'                                                                               => array(
491
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
-            ),
494
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
495
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
-            ),
498
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
-            ),
501
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
-            ),
508
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
-            ),
512
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
-            ),
515
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
-            ),
518
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
552
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EE_Data_Migration_Class_Base'                                                                                => array(
555
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
-            ),
558
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
559
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
563
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
567
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
-            ),
570
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
571
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
575
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
-            ),
604
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
-            ),
607
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
-                null,
631
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
-            ),
633
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
-            ),
636
-            'LEGACY_MODELS'                                                   => array(
637
-                null,
638
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EE_Module_Request_Router' => array(
641
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EE_Registration_Processor' => array(
644
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\services\currency\CurrencyFactory' => array(
647
-                'EventEspresso\core\services\currency\CountryCurrencyDao' => EE_Dependency_Map::load_from_cache,
648
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
649
-            ),
650
-            'EventEspresso\core\services\currency\MoneyFactory' => array(
651
-                'EventEspresso\core\services\currency\CurrencyFactory'  => EE_Dependency_Map::load_from_cache,
652
-                'EventEspresso\core\services\currency\Calculator'       => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
655
-                null,
656
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
657
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
658
-            ),
659
-            'EventEspresso\core\services\currency\MoneyFactory' => array(
660
-                'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache
661
-            )
662
-        );
663
-    }
664
-
665
-
666
-
667
-    /**
668
-     * Registers how core classes are loaded.
669
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
670
-     *        'EE_Request_Handler' => 'load_core'
671
-     *        'EE_Messages_Queue'  => 'load_lib'
672
-     *        'EEH_Debug_Tools'    => 'load_helper'
673
-     * or, if greater control is required, by providing a custom closure. For example:
674
-     *        'Some_Class' => function () {
675
-     *            return new Some_Class();
676
-     *        },
677
-     * This is required for instantiating dependencies
678
-     * where an interface has been type hinted in a class constructor. For example:
679
-     *        'Required_Interface' => function () {
680
-     *            return new A_Class_That_Implements_Required_Interface();
681
-     *        },
682
-     *
683
-     * @throws InvalidInterfaceException
684
-     * @throws InvalidDataTypeException
685
-     * @throws InvalidArgumentException
686
-     */
687
-    protected function _register_core_class_loaders()
688
-    {
689
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
690
-        //be used in a closure.
691
-        $request = &$this->_request;
692
-        $response = &$this->_response;
693
-        // $loader = &$this->loader;
694
-        $this->_class_loaders = array(
695
-            //load_core
696
-            'EE_Capabilities'                      => 'load_core',
697
-            'EE_Encryption'                        => 'load_core',
698
-            'EE_Front_Controller'                  => 'load_core',
699
-            'EE_Module_Request_Router'             => 'load_core',
700
-            'EE_Registry'                          => 'load_core',
701
-            'EE_Request'                           => function () use (&$request) {
702
-                return $request;
703
-            },
704
-            'EE_Response'                          => function () use (&$response) {
705
-                return $response;
706
-            },
707
-            'EE_Request_Handler'                   => 'load_core',
708
-            'EE_Session'                           => 'load_core',
709
-            'EE_Cron_Tasks'                        => 'load_core',
710
-            'EE_System'                            => 'load_core',
711
-            'EE_Maintenance_Mode'                  => 'load_core',
712
-            'EE_Register_CPTs'                     => 'load_core',
713
-            'EE_Admin'                             => 'load_core',
714
-            //load_lib
715
-            'EE_Message_Resource_Manager'          => 'load_lib',
716
-            'EE_Message_Type_Collection'           => 'load_lib',
717
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
718
-            'EE_Messenger_Collection'              => 'load_lib',
719
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
720
-            'EE_Messages_Processor'                => 'load_lib',
721
-            'EE_Message_Repository'                => 'load_lib',
722
-            'EE_Messages_Queue'                    => 'load_lib',
723
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
724
-            'EE_Message_Template_Group_Collection' => 'load_lib',
725
-            'EE_Payment_Method_Manager'            => 'load_lib',
726
-            'EE_Messages_Generator'                => function () {
727
-                return EE_Registry::instance()->load_lib(
728
-                    'Messages_Generator',
729
-                    array(),
730
-                    false,
731
-                    false
732
-                );
733
-            },
734
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
735
-                return EE_Registry::instance()->load_lib(
736
-                    'Messages_Template_Defaults',
737
-                    $arguments,
738
-                    false,
739
-                    false
740
-                );
741
-            },
742
-            //load_model
743
-            // 'EEM_Attendee'                         => 'load_model',
744
-            // 'EEM_Message_Template_Group'           => 'load_model',
745
-            // 'EEM_Message_Template'                 => 'load_model',
746
-            //load_helper
747
-            'EEH_Parse_Shortcodes'                 => function () {
748
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
749
-                    return new EEH_Parse_Shortcodes();
750
-                }
751
-                return null;
752
-            },
753
-            'EE_Template_Config'                   => function () {
754
-                return EE_Config::instance()->template_settings;
755
-            },
756
-            'EE_Currency_Config'                   => function () {
757
-                return EE_Config::instance()->currency;
758
-            },
759
-            'EE_Registration_Config'                   => function () {
760
-                return EE_Config::instance()->registration;
761
-            },
762
-            'EE_Organization_Config'                   => function () {
763
-                return EE_Config::instance()->organization;
764
-            },
765
-            'EventEspresso\core\services\loaders\Loader' => function () {
766
-                return LoaderFactory::getLoader();
767
-            },
768
-        );
769
-    }
770
-
771
-
772
-
773
-    /**
774
-     * can be used for supplying alternate names for classes,
775
-     * or for connecting interface names to instantiable classes
776
-     */
777
-    protected function _register_core_aliases()
778
-    {
779
-        $this->_aliases = array(
780
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
781
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
782
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
783
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
784
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
785
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
786
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
787
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
788
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
789
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
790
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
791
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
792
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
793
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
794
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
795
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
796
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
797
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
798
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
799
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
800
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
801
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
802
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
803
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
804
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
805
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
806
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
807
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
808
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
809
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
810
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
811
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
812
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
813
-            'NoticeConverterInterface'                                                    => 'EventEspresso\core\services\notices\NoticeConverterInterface',
814
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
815
-            'NoticesContainerInterface'                                                   => 'EventEspresso\core\services\notices\NoticesContainerInterface',
816
-            'EventEspresso\core\services\notices\NoticesContainerInterface'               => 'EventEspresso\core\services\notices\NoticesContainer',
817
-            'EventEspresso\core\services\currency\Calculator'                             => 'EventEspresso\core\services\currency\DefaultCalculator',
818
-        );
819
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
820
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
821
-        }
822
-    }
823
-
824
-
825
-
826
-    /**
827
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
828
-     * request Primarily used by unit tests.
829
-     *
830
-     * @throws InvalidDataTypeException
831
-     * @throws InvalidInterfaceException
832
-     * @throws InvalidArgumentException
833
-     */
834
-    public function reset()
835
-    {
836
-        $this->_register_core_class_loaders();
837
-        $this->_register_core_dependencies();
838
-    }
25
+	/**
26
+	 * This means that the requested class dependency is not present in the dependency map
27
+	 */
28
+	const not_registered = 0;
29
+
30
+	/**
31
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
+	 */
33
+	const load_new_object = 1;
34
+
35
+	/**
36
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
+	 */
39
+	const load_from_cache = 2;
40
+
41
+	/**
42
+	 * When registering a dependency,
43
+	 * this indicates to keep any existing dependencies that already exist,
44
+	 * and simply discard any new dependencies declared in the incoming data
45
+	 */
46
+	const KEEP_EXISTING_DEPENDENCIES = 0;
47
+
48
+	/**
49
+	 * When registering a dependency,
50
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
+	 */
52
+	const OVERWRITE_DEPENDENCIES = 1;
53
+
54
+
55
+
56
+	/**
57
+	 * @type EE_Dependency_Map $_instance
58
+	 */
59
+	protected static $_instance;
60
+
61
+	/**
62
+	 * @type EE_Request $request
63
+	 */
64
+	protected $_request;
65
+
66
+	/**
67
+	 * @type EE_Response $response
68
+	 */
69
+	protected $_response;
70
+
71
+	/**
72
+	 * @type LoaderInterface $loader
73
+	 */
74
+	protected $loader;
75
+
76
+	/**
77
+	 * @type array $_dependency_map
78
+	 */
79
+	protected $_dependency_map = array();
80
+
81
+	/**
82
+	 * @type array $_class_loaders
83
+	 */
84
+	protected $_class_loaders = array();
85
+
86
+	/**
87
+	 * @type array $_aliases
88
+	 */
89
+	protected $_aliases = array();
90
+
91
+
92
+
93
+	/**
94
+	 * EE_Dependency_Map constructor.
95
+	 *
96
+	 * @param EE_Request  $request
97
+	 * @param EE_Response $response
98
+	 */
99
+	protected function __construct(EE_Request $request, EE_Response $response)
100
+	{
101
+		$this->_request = $request;
102
+		$this->_response = $response;
103
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
+		do_action('EE_Dependency_Map____construct');
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 * @throws InvalidArgumentException
113
+	 */
114
+	public function initialize()
115
+	{
116
+		$this->_register_core_dependencies();
117
+		$this->_register_core_class_loaders();
118
+		$this->_register_core_aliases();
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * @singleton method used to instantiate class object
125
+	 * @access    public
126
+	 * @param EE_Request  $request
127
+	 * @param EE_Response $response
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
131
+	{
132
+		// check if class object is instantiated, and instantiated properly
133
+		if (! self::$_instance instanceof EE_Dependency_Map) {
134
+			self::$_instance = new EE_Dependency_Map($request, $response);
135
+		}
136
+		return self::$_instance;
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 * @param LoaderInterface $loader
143
+	 */
144
+	public function setLoader(LoaderInterface $loader)
145
+	{
146
+		$this->loader = $loader;
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @param string $class
153
+	 * @param array  $dependencies
154
+	 * @param int    $overwrite
155
+	 * @return bool
156
+	 */
157
+	public static function register_dependencies(
158
+		$class,
159
+		array $dependencies,
160
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
+	) {
162
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Assigns an array of class names and corresponding load sources (new or cached)
169
+	 * to the class specified by the first parameter.
170
+	 * IMPORTANT !!!
171
+	 * The order of elements in the incoming $dependencies array MUST match
172
+	 * the order of the constructor parameters for the class in question.
173
+	 * This is especially important when overriding any existing dependencies that are registered.
174
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
+	 *
176
+	 * @param string $class
177
+	 * @param array  $dependencies
178
+	 * @param int    $overwrite
179
+	 * @return bool
180
+	 */
181
+	public function registerDependencies(
182
+		$class,
183
+		array $dependencies,
184
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
+	) {
186
+		$class = trim($class, '\\');
187
+		$registered = false;
188
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
189
+			self::$_instance->_dependency_map[ $class ] = array();
190
+		}
191
+		// we need to make sure that any aliases used when registering a dependency
192
+		// get resolved to the correct class name
193
+		foreach ((array)$dependencies as $dependency => $load_source) {
194
+			$alias = self::$_instance->get_alias($dependency);
195
+			if (
196
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
+			) {
199
+				unset($dependencies[$dependency]);
200
+				$dependencies[$alias] = $load_source;
201
+				$registered = true;
202
+			}
203
+		}
204
+		// now add our two lists of dependencies together.
205
+		// using Union (+=) favours the arrays in precedence from left to right,
206
+		// so $dependencies is NOT overwritten because it is listed first
207
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
+		// Union is way faster than array_merge() but should be used with caution...
209
+		// especially with numerically indexed arrays
210
+		$dependencies += self::$_instance->_dependency_map[ $class ];
211
+		// now we need to ensure that the resulting dependencies
212
+		// array only has the entries that are required for the class
213
+		// so first count how many dependencies were originally registered for the class
214
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
+		// if that count is non-zero (meaning dependencies were already registered)
216
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
217
+			// then truncate the  final array to match that count
218
+			? array_slice($dependencies, 0, $dependency_count)
219
+			// otherwise just take the incoming array because nothing previously existed
220
+			: $dependencies;
221
+		return $registered;
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * @param string $class_name
228
+	 * @param string $loader
229
+	 * @return bool
230
+	 * @throws DomainException
231
+	 */
232
+	public static function register_class_loader($class_name, $loader = 'load_core')
233
+	{
234
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
+			throw new DomainException(
236
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
+			);
238
+		}
239
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
240
+		if (
241
+			! is_callable($loader)
242
+			&& (
243
+				strpos($loader, 'load_') !== 0
244
+				|| ! method_exists('EE_Registry', $loader)
245
+			)
246
+		) {
247
+			throw new DomainException(
248
+				sprintf(
249
+					esc_html__(
250
+						'"%1$s" is not a valid loader method on EE_Registry.',
251
+						'event_espresso'
252
+					),
253
+					$loader
254
+				)
255
+			);
256
+		}
257
+		$class_name = self::$_instance->get_alias($class_name);
258
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
+			self::$_instance->_class_loaders[$class_name] = $loader;
260
+			return true;
261
+		}
262
+		return false;
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * @return array
269
+	 */
270
+	public function dependency_map()
271
+	{
272
+		return $this->_dependency_map;
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * returns TRUE if dependency map contains a listing for the provided class name
279
+	 *
280
+	 * @param string $class_name
281
+	 * @return boolean
282
+	 */
283
+	public function has($class_name = '')
284
+	{
285
+		// all legacy models have the same dependencies
286
+		if (strpos($class_name, 'EEM_') === 0) {
287
+			$class_name = 'LEGACY_MODELS';
288
+		}
289
+		return isset($this->_dependency_map[$class_name]) ? true : false;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
+	 *
297
+	 * @param string $class_name
298
+	 * @param string $dependency
299
+	 * @return bool
300
+	 */
301
+	public function has_dependency_for_class($class_name = '', $dependency = '')
302
+	{
303
+		// all legacy models have the same dependencies
304
+		if (strpos($class_name, 'EEM_') === 0) {
305
+			$class_name = 'LEGACY_MODELS';
306
+		}
307
+		$dependency = $this->get_alias($dependency);
308
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
+			? true
310
+			: false;
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
+	 *
318
+	 * @param string $class_name
319
+	 * @param string $dependency
320
+	 * @return int
321
+	 */
322
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
+	{
324
+		// all legacy models have the same dependencies
325
+		if (strpos($class_name, 'EEM_') === 0) {
326
+			$class_name = 'LEGACY_MODELS';
327
+		}
328
+		$dependency = $this->get_alias($dependency);
329
+		return $this->has_dependency_for_class($class_name, $dependency)
330
+			? $this->_dependency_map[$class_name][$dependency]
331
+			: EE_Dependency_Map::not_registered;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * @param string $class_name
338
+	 * @return string | Closure
339
+	 */
340
+	public function class_loader($class_name)
341
+	{
342
+		// all legacy models use load_model()
343
+		if(strpos($class_name, 'EEM_') === 0){
344
+			return 'load_model';
345
+		}
346
+		$class_name = $this->get_alias($class_name);
347
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * @return array
354
+	 */
355
+	public function class_loaders()
356
+	{
357
+		return $this->_class_loaders;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * adds an alias for a classname
364
+	 *
365
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
366
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
+	 */
369
+	public function add_alias($class_name, $alias, $for_class = '')
370
+	{
371
+		if ($for_class !== '') {
372
+			if (! isset($this->_aliases[$for_class])) {
373
+				$this->_aliases[$for_class] = array();
374
+			}
375
+			$this->_aliases[$for_class][$class_name] = $alias;
376
+		}
377
+		$this->_aliases[$class_name] = $alias;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * returns TRUE if the provided class name has an alias
384
+	 *
385
+	 * @param string $class_name
386
+	 * @param string $for_class
387
+	 * @return bool
388
+	 */
389
+	public function has_alias($class_name = '', $for_class = '')
390
+	{
391
+		return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
+			   || (
393
+				   isset($this->_aliases[$class_name])
394
+				   && ! is_array($this->_aliases[$class_name])
395
+			   );
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 * returns alias for class name if one exists, otherwise returns the original classname
402
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
403
+	 *  for example:
404
+	 *      if the following two entries were added to the _aliases array:
405
+	 *          array(
406
+	 *              'interface_alias'           => 'some\namespace\interface'
407
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
408
+	 *          )
409
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
+	 *      to load an instance of 'some\namespace\classname'
411
+	 *
412
+	 * @param string $class_name
413
+	 * @param string $for_class
414
+	 * @return string
415
+	 */
416
+	public function get_alias($class_name = '', $for_class = '')
417
+	{
418
+		if (! $this->has_alias($class_name, $for_class)) {
419
+			return $class_name;
420
+		}
421
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
+		}
424
+		return $this->get_alias($this->_aliases[$class_name]);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
+	 * This is done by using the following class constants:
433
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
435
+	 */
436
+	protected function _register_core_dependencies()
437
+	{
438
+		$this->_dependency_map = array(
439
+			'EE_Request_Handler'                                                                                          => array(
440
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_System'                                                                                                   => array(
443
+				'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
+				'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
+				'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
+				'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_Session'                                                                                                  => array(
450
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
+			),
453
+			'EE_Cart'                                                                                                     => array(
454
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
455
+			),
456
+			'EE_Front_Controller'                                                                                         => array(
457
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_Messenger_Collection_Loader'                                                                              => array(
462
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
+			),
464
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
465
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
+			),
467
+			'EE_Message_Resource_Manager'                                                                                 => array(
468
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
+			),
472
+			'EE_Message_Factory'                                                                                          => array(
473
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
+			),
475
+			'EE_messages'                                                                                                 => array(
476
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
+			),
478
+			'EE_Messages_Generator'                                                                                       => array(
479
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_Messages_Processor'                                                                                       => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Queue'                                                                                           => array(
488
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
+			),
490
+			'EE_Messages_Template_Defaults'                                                                               => array(
491
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
+			),
494
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
495
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
+			),
498
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
+			),
501
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
+			),
508
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
+			),
512
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
+			),
515
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
+			),
518
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
552
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EE_Data_Migration_Class_Base'                                                                                => array(
555
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
+			),
558
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
559
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
563
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
567
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
+			),
570
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
571
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
575
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
+			),
604
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
+			),
607
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
+				null,
631
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
+			),
633
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
+			),
636
+			'LEGACY_MODELS'                                                   => array(
637
+				null,
638
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EE_Module_Request_Router' => array(
641
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EE_Registration_Processor' => array(
644
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\services\currency\CurrencyFactory' => array(
647
+				'EventEspresso\core\services\currency\CountryCurrencyDao' => EE_Dependency_Map::load_from_cache,
648
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
649
+			),
650
+			'EventEspresso\core\services\currency\MoneyFactory' => array(
651
+				'EventEspresso\core\services\currency\CurrencyFactory'  => EE_Dependency_Map::load_from_cache,
652
+				'EventEspresso\core\services\currency\Calculator'       => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
655
+				null,
656
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
657
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
658
+			),
659
+			'EventEspresso\core\services\currency\MoneyFactory' => array(
660
+				'EventEspresso\core\services\currency\CurrencyFactory' => EE_Dependency_Map::load_from_cache
661
+			)
662
+		);
663
+	}
664
+
665
+
666
+
667
+	/**
668
+	 * Registers how core classes are loaded.
669
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
670
+	 *        'EE_Request_Handler' => 'load_core'
671
+	 *        'EE_Messages_Queue'  => 'load_lib'
672
+	 *        'EEH_Debug_Tools'    => 'load_helper'
673
+	 * or, if greater control is required, by providing a custom closure. For example:
674
+	 *        'Some_Class' => function () {
675
+	 *            return new Some_Class();
676
+	 *        },
677
+	 * This is required for instantiating dependencies
678
+	 * where an interface has been type hinted in a class constructor. For example:
679
+	 *        'Required_Interface' => function () {
680
+	 *            return new A_Class_That_Implements_Required_Interface();
681
+	 *        },
682
+	 *
683
+	 * @throws InvalidInterfaceException
684
+	 * @throws InvalidDataTypeException
685
+	 * @throws InvalidArgumentException
686
+	 */
687
+	protected function _register_core_class_loaders()
688
+	{
689
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
690
+		//be used in a closure.
691
+		$request = &$this->_request;
692
+		$response = &$this->_response;
693
+		// $loader = &$this->loader;
694
+		$this->_class_loaders = array(
695
+			//load_core
696
+			'EE_Capabilities'                      => 'load_core',
697
+			'EE_Encryption'                        => 'load_core',
698
+			'EE_Front_Controller'                  => 'load_core',
699
+			'EE_Module_Request_Router'             => 'load_core',
700
+			'EE_Registry'                          => 'load_core',
701
+			'EE_Request'                           => function () use (&$request) {
702
+				return $request;
703
+			},
704
+			'EE_Response'                          => function () use (&$response) {
705
+				return $response;
706
+			},
707
+			'EE_Request_Handler'                   => 'load_core',
708
+			'EE_Session'                           => 'load_core',
709
+			'EE_Cron_Tasks'                        => 'load_core',
710
+			'EE_System'                            => 'load_core',
711
+			'EE_Maintenance_Mode'                  => 'load_core',
712
+			'EE_Register_CPTs'                     => 'load_core',
713
+			'EE_Admin'                             => 'load_core',
714
+			//load_lib
715
+			'EE_Message_Resource_Manager'          => 'load_lib',
716
+			'EE_Message_Type_Collection'           => 'load_lib',
717
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
718
+			'EE_Messenger_Collection'              => 'load_lib',
719
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
720
+			'EE_Messages_Processor'                => 'load_lib',
721
+			'EE_Message_Repository'                => 'load_lib',
722
+			'EE_Messages_Queue'                    => 'load_lib',
723
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
724
+			'EE_Message_Template_Group_Collection' => 'load_lib',
725
+			'EE_Payment_Method_Manager'            => 'load_lib',
726
+			'EE_Messages_Generator'                => function () {
727
+				return EE_Registry::instance()->load_lib(
728
+					'Messages_Generator',
729
+					array(),
730
+					false,
731
+					false
732
+				);
733
+			},
734
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
735
+				return EE_Registry::instance()->load_lib(
736
+					'Messages_Template_Defaults',
737
+					$arguments,
738
+					false,
739
+					false
740
+				);
741
+			},
742
+			//load_model
743
+			// 'EEM_Attendee'                         => 'load_model',
744
+			// 'EEM_Message_Template_Group'           => 'load_model',
745
+			// 'EEM_Message_Template'                 => 'load_model',
746
+			//load_helper
747
+			'EEH_Parse_Shortcodes'                 => function () {
748
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
749
+					return new EEH_Parse_Shortcodes();
750
+				}
751
+				return null;
752
+			},
753
+			'EE_Template_Config'                   => function () {
754
+				return EE_Config::instance()->template_settings;
755
+			},
756
+			'EE_Currency_Config'                   => function () {
757
+				return EE_Config::instance()->currency;
758
+			},
759
+			'EE_Registration_Config'                   => function () {
760
+				return EE_Config::instance()->registration;
761
+			},
762
+			'EE_Organization_Config'                   => function () {
763
+				return EE_Config::instance()->organization;
764
+			},
765
+			'EventEspresso\core\services\loaders\Loader' => function () {
766
+				return LoaderFactory::getLoader();
767
+			},
768
+		);
769
+	}
770
+
771
+
772
+
773
+	/**
774
+	 * can be used for supplying alternate names for classes,
775
+	 * or for connecting interface names to instantiable classes
776
+	 */
777
+	protected function _register_core_aliases()
778
+	{
779
+		$this->_aliases = array(
780
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
781
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
782
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
783
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
784
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
785
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
786
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
787
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
788
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
789
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
790
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
791
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
792
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
793
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
794
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
795
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
796
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
797
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
798
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
799
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
800
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
801
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
802
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
803
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
804
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
805
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
806
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
807
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
808
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
809
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
810
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
811
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
812
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
813
+			'NoticeConverterInterface'                                                    => 'EventEspresso\core\services\notices\NoticeConverterInterface',
814
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
815
+			'NoticesContainerInterface'                                                   => 'EventEspresso\core\services\notices\NoticesContainerInterface',
816
+			'EventEspresso\core\services\notices\NoticesContainerInterface'               => 'EventEspresso\core\services\notices\NoticesContainer',
817
+			'EventEspresso\core\services\currency\Calculator'                             => 'EventEspresso\core\services\currency\DefaultCalculator',
818
+		);
819
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
820
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
821
+		}
822
+	}
823
+
824
+
825
+
826
+	/**
827
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
828
+	 * request Primarily used by unit tests.
829
+	 *
830
+	 * @throws InvalidDataTypeException
831
+	 * @throws InvalidInterfaceException
832
+	 * @throws InvalidArgumentException
833
+	 */
834
+	public function reset()
835
+	{
836
+		$this->_register_core_class_loaders();
837
+		$this->_register_core_dependencies();
838
+	}
839 839
 
840 840
 
841 841
 }
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
312 312
 		//parent folder, "/var/something/"
313 313
 		$ds = strlen($file_or_folder_path) > 1
314
-            ? strrpos($file_or_folder_path, DS, -2)
315
-            : strlen($file_or_folder_path);
314
+			? strrpos($file_or_folder_path, DS, -2)
315
+			: strlen($file_or_folder_path);
316 316
 		return substr($file_or_folder_path, 0, $ds + 1);
317 317
 	}
318 318
 
@@ -658,14 +658,14 @@  discard block
 block discarded – undo
658 658
 
659 659
 
660 660
 
661
-    /**
662
-     * Resets the file helper's state. Useful between tests that may have used a mock
663
-     * filesystem.
664
-     */
661
+	/**
662
+	 * Resets the file helper's state. Useful between tests that may have used a mock
663
+	 * filesystem.
664
+	 */
665 665
 	public static function reset()
666
-    {
667
-        self::$_wp_filesystem_direct = null;
668
-    }
666
+	{
667
+		self::$_wp_filesystem_direct = null;
668
+	}
669 669
 }
670 670
 // End of file EEH_File.helper.php
671 671
 // Location: /helpers/EEH_File.helper.php
672 672
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -38,30 +38,30 @@  discard block
 block discarded – undo
38 38
 	 * @throws EE_Error if filesystem credentials are required
39 39
 	 * @return WP_Filesystem_Base
40 40
 	 */
41
-	private static function _get_wp_filesystem( $filepath = null) {
42
-		if( apply_filters(
41
+	private static function _get_wp_filesystem($filepath = null) {
42
+		if (apply_filters(
43 43
 				'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct',
44
-				$filepath && EEH_File::is_in_uploads_folder( $filepath ),
45
-				$filepath ) ) {
46
-			if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) {
47
-				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
44
+				$filepath && EEH_File::is_in_uploads_folder($filepath),
45
+				$filepath )) {
46
+			if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
47
+				require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
48 48
 				$method = 'direct';
49
-				$wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
49
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
50 50
 				//check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
51
-				if ( ! defined('FS_CHMOD_DIR') ) {
52
-					define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
51
+				if ( ! defined('FS_CHMOD_DIR')) {
52
+					define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
53 53
 				}
54
-				if ( ! defined('FS_CHMOD_FILE') ) {
55
-					define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
54
+				if ( ! defined('FS_CHMOD_FILE')) {
55
+					define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
56 56
 				}
57
-				require_once( $wp_filesystem_direct_file );
58
-				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() );
57
+				require_once($wp_filesystem_direct_file);
58
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
59 59
 			}
60 60
 			return EEH_File::$_wp_filesystem_direct;
61 61
 		}
62 62
 		global $wp_filesystem;
63 63
 		// no filesystem setup ???
64
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
64
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
65 65
 			// if some eager beaver's just trying to get in there too early...
66 66
 			// let them do it, because we are one of those eager beavers! :P
67 67
 			/**
@@ -74,34 +74,34 @@  discard block
 block discarded – undo
74 74
 			 * and there may be troubles if the WP files are owned by a different user
75 75
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
76 76
 			 */
77
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
77
+			if (FALSE && ! did_action('wp_loaded')) {
78 78
 				$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');
79
-				if ( WP_DEBUG ) {
80
-					$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');
79
+				if (WP_DEBUG) {
80
+					$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');
81 81
 				}
82
-				throw new EE_Error( $msg );
82
+				throw new EE_Error($msg);
83 83
 			} else {
84 84
 				// should be loaded if we are past the wp_loaded hook...
85
-				if ( ! function_exists( 'WP_Filesystem' )) {
86
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
87
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
85
+				if ( ! function_exists('WP_Filesystem')) {
86
+					require_once(ABSPATH.'wp-admin/includes/file.php');
87
+					require_once(ABSPATH.'wp-admin/includes/template.php');
88 88
 				}
89 89
 				// turn on output buffering so that we can capture the credentials form
90 90
 				ob_start();
91
-				$credentials = request_filesystem_credentials( '' );
91
+				$credentials = request_filesystem_credentials('');
92 92
 				// store credentials form for the time being
93 93
 				EEH_File::$_credentials_form = ob_get_clean();
94 94
 				// basically check for direct or previously configured access
95
-				if ( ! WP_Filesystem( $credentials ) ) {
95
+				if ( ! WP_Filesystem($credentials)) {
96 96
 					// if credentials do NOT exist
97
-					if ( $credentials === FALSE ) {
98
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
99
-						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'));
100
-					} elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
101
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
97
+					if ($credentials === FALSE) {
98
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
99
+						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'));
100
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
101
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
102 102
 						throw new EE_Error(
103 103
 								sprintf(
104
-										__( 'WP Filesystem Error: $1%s', 'event_espresso' ),
104
+										__('WP Filesystem Error: $1%s', 'event_espresso'),
105 105
 										$wp_filesystem->errors->get_error_message() ) );
106 106
 					}
107 107
 				}
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * display_request_filesystem_credentials_form
115 115
 	 */
116 116
 	public static function display_request_filesystem_credentials_form() {
117
-		if ( ! empty( EEH_File::$_credentials_form )) {
118
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
117
+		if ( ! empty(EEH_File::$_credentials_form)) {
118
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
119 119
 		}
120 120
 	}
121 121
 
@@ -133,29 +133,29 @@  discard block
 block discarded – undo
133 133
 	 * @throws EE_Error if filesystem credentials are required
134 134
 	 * @return bool
135 135
 	 */
136
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
136
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
137 137
 		// load WP_Filesystem and set file permissions
138
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
139
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
140
-		if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) {
141
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
142
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
138
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
139
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
140
+		if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
141
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
142
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
143 143
 			$msg = sprintf(
144
-				__( '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' ),
144
+				__('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'),
145 145
 				$file_name,
146 146
 				'<br />'
147 147
 			);
148
-			if ( EEH_File::exists( $full_file_path )) {
149
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
148
+			if (EEH_File::exists($full_file_path)) {
149
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
150 150
 			} else {
151 151
 				// no file permissions means the file was not found
152 152
 				$msg .= sprintf(
153
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
153
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
154 154
 					$full_file_path
155 155
 				);
156 156
 			}
157
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
158
-				throw new EE_Error( $msg . '||' . $msg );
157
+			if (defined('WP_DEBUG') && WP_DEBUG) {
158
+				throw new EE_Error($msg.'||'.$msg);
159 159
 			}
160 160
 			return FALSE;
161 161
 		}
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
 	 * @throws EE_Error if filesystem credentials are required
174 174
 	 * @return string
175 175
 	 */
176
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
176
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
177 177
 		// load WP_Filesystem and set file permissions
178
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
178
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
179 179
 		// check file permissions
180
-		$perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
181
-		if ( $perms ) {
180
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
181
+		if ($perms) {
182 182
 			// file permissions exist, but way be set incorrectly
183
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
184
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
183
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
184
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
185 185
 			return sprintf(
186
-				__( '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' ),
186
+				__('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'),
187 187
 				$type_of_file,
188 188
 				$perms
189 189
 			);
190 190
 		} else {
191 191
 			// file exists but file permissions could not be read ?!?!
192 192
 			return sprintf(
193
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
193
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
194 194
 				$full_file_path
195 195
 			);
196 196
 		}
@@ -208,35 +208,35 @@  discard block
 block discarded – undo
208 208
 	 * can't write to it
209 209
 	 * @return bool false if folder isn't writable; true if it exists and is writeable,
210 210
 	 */
211
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
212
-		if ( empty( $folder )) {
211
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
212
+		if (empty($folder)) {
213 213
 			return false;
214 214
 		}
215 215
 		// remove ending DS
216
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
217
-		$parent_folder = EEH_File::get_parent_folder( $folder );
216
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
217
+		$parent_folder = EEH_File::get_parent_folder($folder);
218 218
 		// add DS to folder
219
-		$folder = EEH_File::end_with_directory_separator( $folder );
220
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $folder );
221
-		if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) {
219
+		$folder = EEH_File::end_with_directory_separator($folder);
220
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
221
+		if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
222 222
 			//ok so it doesn't exist. Does its parent? Can we write to it?
223
-			if(	! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
223
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
224 224
 				return false;
225 225
 			}
226
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
226
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
227 227
 				return false;
228 228
 			} else {
229
-				if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath(  $folder ) ) ) {
230
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
231
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
232
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
233
-						throw new EE_Error( $msg );
229
+				if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
230
+					if (defined('WP_DEBUG') && WP_DEBUG) {
231
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
232
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
233
+						throw new EE_Error($msg);
234 234
 					}
235 235
 					return false;
236 236
 				}
237
-				EEH_File::add_index_file( $folder );
237
+				EEH_File::add_index_file($folder);
238 238
 			}
239
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
239
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
240 240
 			return false;
241 241
 		}
242 242
 		return true;
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 	 * @throws EE_Error if filesystem credentials are required
252 252
 	 * @return bool
253 253
 	 */
254
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
254
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
255 255
 		// load WP_Filesystem and set file permissions
256
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_path );
257
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
258
-		if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) {
259
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
260
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
261
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
262
-				throw new EE_Error( $msg );
256
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
257
+		$full_path = EEH_File::standardise_directory_separators($full_path);
258
+		if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
259
+			if (defined('WP_DEBUG') && WP_DEBUG) {
260
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
261
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
262
+				throw new EE_Error($msg);
263 263
 			}
264 264
 			return FALSE;
265 265
 		}
@@ -276,25 +276,25 @@  discard block
 block discarded – undo
276 276
 	 * @throws EE_Error if filesystem credentials are required
277 277
 	 * @return bool
278 278
 	 */
279
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
279
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
280 280
 		// load WP_Filesystem and set file permissions
281
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
282
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
283
-		$parent_folder = EEH_File::get_parent_folder( $full_file_path );
284
-		if ( ! EEH_File::exists( $full_file_path )) {
285
-			if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
281
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
282
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
283
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
284
+		if ( ! EEH_File::exists($full_file_path)) {
285
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
286 286
 				return false;
287 287
 			}
288
-			if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) {
289
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
290
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
291
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
292
-					throw new EE_Error( $msg );
288
+			if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
289
+				if (defined('WP_DEBUG') && WP_DEBUG) {
290
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
291
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
292
+					throw new EE_Error($msg);
293 293
 				}
294 294
 				return false;
295 295
 			}
296 296
 		}
297
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
297
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
298 298
 			return false;
299 299
 		}
300 300
 		return true;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param string $file_or_folder_path
307 307
 	 * @return string parent folder, ENDING with a directory separator
308 308
 	 */
309
-	public static function get_parent_folder( $file_or_folder_path ) {
309
+	public static function get_parent_folder($file_or_folder_path) {
310 310
 		//find the last DS, ignoring a DS on the very end
311 311
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
312 312
 		//parent folder, "/var/something/"
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 	 * @throws EE_Error if filesystem credentials are required
329 329
 	 * @return string
330 330
 	 */
331
-	public static function get_file_contents( $full_file_path = '' ){
332
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
333
-		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 ))) {
331
+	public static function get_file_contents($full_file_path = '') {
332
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
333
+		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))) {
334 334
 			// load WP_Filesystem and set file permissions
335
-			$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
336
-			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
335
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
336
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
337 337
 		}
338 338
 		return '';
339 339
 	}
@@ -348,26 +348,26 @@  discard block
 block discarded – undo
348 348
 	 * @throws EE_Error if filesystem credentials are required
349 349
 	 * @return bool
350 350
 	 */
351
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
352
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
353
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
354
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
355
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
356
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
357
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
358
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
359
-				throw new EE_Error( $msg );
351
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
352
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
353
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
354
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
355
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
356
+			if (defined('WP_DEBUG') && WP_DEBUG) {
357
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
358
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
359
+				throw new EE_Error($msg);
360 360
 			}
361 361
 			return FALSE;
362 362
 		}
363 363
 		// load WP_Filesystem and set file permissions
364
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
364
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
365 365
 		// write the file
366
-		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) {
367
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
368
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
369
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
370
-				throw new EE_Error( $msg );
366
+		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
367
+			if (defined('WP_DEBUG') && WP_DEBUG) {
368
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
369
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
370
+				throw new EE_Error($msg);
371 371
 			}
372 372
 			return FALSE;
373 373
 		}
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 	 * @throws EE_Error if filesystem credentials are required
384 384
 	 * @return boolean
385 385
 	 */
386
-	public static function delete( $filepath, $recursive = false, $type = false ) {
386
+	public static function delete($filepath, $recursive = false, $type = false) {
387 387
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
388
-		return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE;
388
+		return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE;
389 389
 	}
390 390
 
391 391
 
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 	 * @throws EE_Error if filesystem credentials are required
398 398
 	 * @return bool
399 399
 	 */
400
-	public static function exists( $full_file_path = '' ) {
401
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
402
-		return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE;
400
+	public static function exists($full_file_path = '') {
401
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
402
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE;
403 403
 	}
404 404
 
405 405
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	 * @throws EE_Error if filesystem credentials are required
413 413
 	 * @return bool
414 414
 	 */
415
-	public static function is_readable( $full_file_path = '' ) {
416
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
417
-		if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath(  $full_file_path ) ) ) {
415
+	public static function is_readable($full_file_path = '') {
416
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
417
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
418 418
 			return true;
419 419
 		} else {
420 420
 			return false;
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 	 * @param string $full_file_path
431 431
 	 * @return string
432 432
 	 */
433
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
434
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
433
+	public static function remove_filename_from_filepath($full_file_path = '') {
434
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
435 435
 	}
436 436
 
437 437
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param string $full_file_path
442 442
 	 * @return string
443 443
 	 */
444
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
445
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
444
+	public static function get_filename_from_filepath($full_file_path = '') {
445
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
446 446
 	}
447 447
 
448 448
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param string $full_file_path
453 453
 	 * @return string
454 454
 	 */
455
-	public static function get_file_extension( $full_file_path = '' ) {
456
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
455
+	public static function get_file_extension($full_file_path = '') {
456
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
457 457
 	}
458 458
 
459 459
 
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
 	 * @throws EE_Error if filesystem credentials are required
465 465
 	 * @return bool
466 466
 	 */
467
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
468
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
469
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
470
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
467
+	public static function add_htaccess_deny_from_all($folder = '') {
468
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
469
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
470
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
471 471
 				return FALSE;
472 472
 			}
473 473
 		}
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @throws EE_Error if filesystem credentials are required
482 482
 	 * @return boolean
483 483
 	 */
484
-	public static function add_index_file( $folder ) {
485
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
486
-		if ( ! EEH_File::exists( $folder . 'index.php' ) ) {
487
-			if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) {
484
+	public static function add_index_file($folder) {
485
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
486
+		if ( ! EEH_File::exists($folder.'index.php')) {
487
+			if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) {
488 488
 				return false;
489 489
 			}
490 490
 		}
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * @param string $file_path
500 500
 	 * @return string
501 501
 	 */
502
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
502
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
503 503
 		//extract file from path
504
-		$filename = basename( $file_path );
504
+		$filename = basename($file_path);
505 505
 		//now remove the first period and everything after
506
-		$pos_of_first_period = strpos( $filename,'.' );
506
+		$pos_of_first_period = strpos($filename, '.');
507 507
 		return substr($filename, 0, $pos_of_first_period);
508 508
 	}
509 509
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	 * @param string $file_path
516 516
 	 * @return string
517 517
 	 */
518
-	public static function standardise_directory_separators( $file_path ){
519
-		return str_replace( array( '\\', '/' ), DS, $file_path );
518
+	public static function standardise_directory_separators($file_path) {
519
+		return str_replace(array('\\', '/'), DS, $file_path);
520 520
 	}
521 521
 
522 522
 
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @param string $file_path
528 528
 	 * @return string
529 529
 	 */
530
-	public static function end_with_directory_separator( $file_path ){
531
-		return rtrim( $file_path, '/\\' ) . DS;
530
+	public static function end_with_directory_separator($file_path) {
531
+		return rtrim($file_path, '/\\').DS;
532 532
 	}
533 533
 
534 534
 
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @param $file_path
539 539
 	 * @return string
540 540
 	 */
541
-	public static function standardise_and_end_with_directory_separator( $file_path ){
542
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
541
+	public static function standardise_and_end_with_directory_separator($file_path) {
542
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
543 543
 	}
544 544
 
545 545
 
@@ -556,21 +556,21 @@  discard block
 block discarded – undo
556 556
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
557 557
 	 *		 and values are their filepaths
558 558
 	 */
559
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
559
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
560 560
 		$class_to_folder_path = array();
561
-		foreach( $folder_paths as $folder_path ){
562
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
561
+		foreach ($folder_paths as $folder_path) {
562
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
563 563
 			// load WP_Filesystem and set file permissions
564
-			$files_in_folder = glob( $folder_path . '*' );
564
+			$files_in_folder = glob($folder_path.'*');
565 565
 			$class_to_folder_path = array();
566
-			if ( $files_in_folder ) {
567
-				foreach( $files_in_folder as $file_path ){
566
+			if ($files_in_folder) {
567
+				foreach ($files_in_folder as $file_path) {
568 568
 					//only add files, not folders
569
-					if ( ! is_dir( $file_path )) {
570
-						if ( $index_numerically ) {
569
+					if ( ! is_dir($file_path)) {
570
+						if ($index_numerically) {
571 571
 							$class_to_folder_path[] = $file_path;
572 572
 						} else {
573
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
573
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
574 574
 							$class_to_folder_path[$classname] = $file_path;
575 575
 						}
576 576
 					}
@@ -590,39 +590,39 @@  discard block
 block discarded – undo
590 590
 	 * @throws EE_Error if filesystem credentials are required
591 591
 	 * @return boolean success
592 592
 	 */
593
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
594
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
595
-		if( ! EEH_File::exists( $full_source_path ) ){
596
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
597
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
598
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
599
-				throw new EE_Error( $msg );
593
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
594
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
595
+		if ( ! EEH_File::exists($full_source_path)) {
596
+			if (defined('WP_DEBUG') && WP_DEBUG) {
597
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
598
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
599
+				throw new EE_Error($msg);
600 600
 			}
601 601
 			return FALSE;
602 602
 		}
603 603
 
604
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
605
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
606
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
607
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
608
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
609
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
610
-				throw new EE_Error( $msg );
604
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
605
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
606
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
607
+			if (defined('WP_DEBUG') && WP_DEBUG) {
608
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
609
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
610
+				throw new EE_Error($msg);
611 611
 			}
612 612
 			return FALSE;
613 613
 		}
614 614
 
615 615
 		// load WP_Filesystem and set file permissions
616
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file );
616
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
617 617
 		// write the file
618 618
 		if ( ! $wp_filesystem->copy(
619
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ),
620
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ),
619
+						EEH_File::convert_local_filepath_to_remote_filepath($full_source_path),
620
+						EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path),
621 621
 						$overwrite )) {
622
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
623
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
624
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
625
-				throw new EE_Error( $msg );
622
+			if (defined('WP_DEBUG') && WP_DEBUG) {
623
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
624
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
625
+				throw new EE_Error($msg);
626 626
 			}
627 627
 			return FALSE;
628 628
 		}
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param string $filepath
635 635
 	 * @return boolean
636 636
 	 */
637
-	public static function is_in_uploads_folder( $filepath ) {
637
+	public static function is_in_uploads_folder($filepath) {
638 638
 		$uploads = wp_upload_dir();
639
-		return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false;
639
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
640 640
 	}
641 641
 
642 642
 	/**
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg
652 652
 	 * ftp or ssh, will use to access the folder
653 653
 	 */
654
-	public static function convert_local_filepath_to_remote_filepath( $local_filepath ) {
655
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath );
656
-		return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath );
654
+	public static function convert_local_filepath_to_remote_filepath($local_filepath) {
655
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
656
+		return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
657 657
 	}
658 658
 
659 659
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Money_Field.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $default_value = null,
40 40
         MoneyFactory $factory = null
41 41
     ) {
42
-        if (! $factory instanceof MoneyFactory) {
42
+        if ( ! $factory instanceof MoneyFactory) {
43 43
             $factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
44 44
         }
45 45
         $this->money_factory = $factory;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function ensureMoney($value)
126 126
     {
127
-        if (! $value instanceof Money) {
127
+        if ( ! $value instanceof Money) {
128 128
             return $this->money_factory->createForSite($value);
129 129
         }
130 130
         return $value;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     private function ensureNotMoney($value)
142 142
     {
143
-        if( $value instanceof Money) {
143
+        if ($value instanceof Money) {
144 144
             return $value->amount();
145 145
         }
146 146
         return $value;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @param string       $table_column
28 28
      * @param string       $nicename
29 29
      * @param bool         $nullable
30
-     * @param null         $default_value
30
+     * @param integer         $default_value
31 31
      * @param MoneyFactory $factory
32 32
      * @throws InvalidArgumentException
33 33
      * @throws InvalidInterfaceException
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * Make sure this value is a money object
90 90
      *
91
-     * @param string|float|int|Money $value
91
+     * @param double $value
92 92
      * @return Money
93 93
      * @throws InvalidIdentifierException
94 94
      * @throws InvalidArgumentException
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -17,211 +17,211 @@
 block discarded – undo
17 17
 class EE_Money_Field extends EE_Float_Field
18 18
 {
19 19
 
20
-    /**
21
-     * @var $money_factory MoneyFactory
22
-     */
23
-    protected $money_factory;
24
-
25
-
26
-    /**
27
-     * @param string       $table_column
28
-     * @param string       $nicename
29
-     * @param bool         $nullable
30
-     * @param null         $default_value
31
-     * @param MoneyFactory $factory
32
-     * @throws InvalidArgumentException
33
-     * @throws InvalidInterfaceException
34
-     * @throws InvalidDataTypeException
35
-     */
36
-    public function __construct(
37
-        $table_column,
38
-        $nicename,
39
-        $nullable,
40
-        $default_value = null,
41
-        MoneyFactory $factory = null
42
-    ) {
43
-        if (! $factory instanceof MoneyFactory) {
44
-            $factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
45
-        }
46
-        $this->money_factory = $factory;
47
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
48
-        $this->setSchemaType('object');
49
-    }
50
-
51
-
52
-    /**
53
-     * Formats the value for pretty output, according to $schema.
54
-     * If legacy filters are being used, uses EEH_Money::format_currency() to format it and currency data from the database
55
-     * (which admins can change), otherwise uses MoneyFormatter which takes currency information from a JSON file
56
-     * (which admins CANNOT change).
57
-     * Legacy Schemas (use the admin-editable currency data from the database):
58
-     *    'localized_float': "3,023.00"
59
-     *    'no_currency_code': "$3,023.00"
60
-     *    null: "$3,023.00<span>USD</span>"
61
-     * New Schemas (use the currency data from a JSON file that we control):
62
-     *    MoneyFormatter::RAW: "3023.0000"
63
-     *    MoneyFormatter::DECIMAL_ONLY: "3023.00"
64
-     *    MoneyFormatter::ADD THOUSANDS/: "3,023.00"
65
-     *    MoneyFormatter::ADD_CURRENCY_SIGN: "$3,023.00"
66
-     *    MoneyFormatter::ADD_CURRENCY_CODE: "$3,023.00<span>USD</span>"
67
-     *
68
-     * @param string|Money $value_on_field_to_be_outputted
69
-     * @param string       $schema
70
-     * @return string
71
-     * @throws InvalidIdentifierException
72
-     * @throws InvalidArgumentException
73
-     * @throws InvalidInterfaceException
74
-     * @throws InvalidDataTypeException
75
-     * @throws EE_Error
76
-     * @throws ReflectionException
77
-     */
78
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
79
-    {
80
-            $value_on_field_to_be_outputted = $this->ensureNotMoney($value_on_field_to_be_outputted);
81
-            $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
82
-
83
-            if ($schema === 'localized_float') {
84
-                return $pretty_float;
85
-            }
86
-            $display_code = true;
87
-            if ($schema === 'no_currency_code') {
88
-                //          echo "schema no currency!";
89
-                $display_code = false;
90
-            }
91
-
92
-            //we don't use the $pretty_float because format_currency will take care of it.
93
-            return EEH_Money::format_currency($value_on_field_to_be_outputted, false, $display_code);
94
-
95
-    }
96
-
97
-
98
-    /**
99
-     * Make sure this value is a money object
100
-     *
101
-     * @param string|float|int|Money $value
102
-     * @return Money
103
-     * @throws InvalidIdentifierException
104
-     * @throws InvalidArgumentException
105
-     * @throws InvalidInterfaceException
106
-     * @throws InvalidDataTypeException
107
-     * @throws EE_Error
108
-     */
109
-    private function ensureMoney($value)
110
-    {
111
-        if (! $value instanceof Money) {
112
-            return $this->money_factory->createForSite($value);
113
-        }
114
-        return $value;
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * Ensures we're dealing with something that isn't Money
121
-     * (for passing off to legacy systems or the parent field)
122
-     * @param  string|float|int|Money $value
123
-     * @return string|float|int
124
-     */
125
-    private function ensureNotMoney($value)
126
-    {
127
-        if( $value instanceof Money) {
128
-            return $value->amount();
129
-        }
130
-        return $value;
131
-    }
132
-
133
-
134
-    /**
135
-     * If provided with a string, strips out money-related formatting to turn it into a proper float.
136
-     * Rounds the float to the correct number of decimal places for this country's currency.
137
-     * Also, interprets periods and commas according to the country's currency settings.
138
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks,
139
-     * type cast it to a float first.
140
-     *
141
-     * @param string|float|int|Money $value_inputted_for_field_on_model_object
142
-     * @return Money
143
-     * @throws InvalidInterfaceException
144
-     * @throws InvalidIdentifierException
145
-     * @throws InvalidDataTypeException
146
-     * @throws EE_Error
147
-     * @throws InvalidArgumentException
148
-     */
149
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
150
-    {
151
-        if ($value_inputted_for_field_on_model_object instanceof Money) {
152
-            return $value_inputted_for_field_on_model_object;
153
-        }
154
-        //now it's a float-style string or number
155
-        return $this->ensureMoney(
156
-            parent::prepare_for_set($value_inputted_for_field_on_model_object)
157
-        );
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * @param string|float|int|Money $value_of_field_on_model_object
164
-     * @return float
165
-     * @throws InvalidArgumentException
166
-     * @throws InvalidInterfaceException
167
-     * @throws InvalidDataTypeException
168
-     */
169
-    public function prepare_for_get($value_of_field_on_model_object)
170
-    {
171
-        $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object);
172
-        $c = EE_Registry::instance()->CFG->currency;
173
-        return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
174
-    }
175
-
176
-
177
-    /**
178
-     * Takes the incoming float and create a money entity for the model object
179
-     *
180
-     * @param string|float|int $value_found_in_db_for_model_object
181
-     * @return Money
182
-     * @throws InvalidIdentifierException
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidInterfaceException
185
-     * @throws InvalidDataTypeException
186
-     * @throws EE_Error
187
-     */
188
-    public function prepare_for_set_from_db($value_found_in_db_for_model_object)
189
-    {
190
-        return $this->money_factory->createForSite($value_found_in_db_for_model_object);
191
-    }
192
-
193
-
194
-
195
-    /**
196
-     * Prepares a value for use in the DB
197
-     * @param string|float|int|Money $value_of_field_on_model_object
198
-     * @return float
199
-     */
200
-    public function prepare_for_use_in_db($value_of_field_on_model_object)
201
-    {
202
-        $value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object);
203
-        return parent::prepare_for_use_in_db($value_of_field_on_model_object);
204
-    }
205
-
206
-
207
-
208
-    public function getSchemaProperties()
209
-    {
210
-        return array(
211
-            'raw' => array(
212
-                'description' =>  sprintf(
213
-                    __('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
214
-                    $this->get_nicename()
215
-                ),
216
-                'type' => 'number'
217
-            ),
218
-            'pretty' => array(
219
-                'description' =>  sprintf(
220
-                    __('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
221
-                    $this->get_nicename()
222
-                ),
223
-                'type' => 'string'
224
-            )
225
-        );
226
-    }
20
+	/**
21
+	 * @var $money_factory MoneyFactory
22
+	 */
23
+	protected $money_factory;
24
+
25
+
26
+	/**
27
+	 * @param string       $table_column
28
+	 * @param string       $nicename
29
+	 * @param bool         $nullable
30
+	 * @param null         $default_value
31
+	 * @param MoneyFactory $factory
32
+	 * @throws InvalidArgumentException
33
+	 * @throws InvalidInterfaceException
34
+	 * @throws InvalidDataTypeException
35
+	 */
36
+	public function __construct(
37
+		$table_column,
38
+		$nicename,
39
+		$nullable,
40
+		$default_value = null,
41
+		MoneyFactory $factory = null
42
+	) {
43
+		if (! $factory instanceof MoneyFactory) {
44
+			$factory = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\currency\MoneyFactory');
45
+		}
46
+		$this->money_factory = $factory;
47
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
48
+		$this->setSchemaType('object');
49
+	}
50
+
51
+
52
+	/**
53
+	 * Formats the value for pretty output, according to $schema.
54
+	 * If legacy filters are being used, uses EEH_Money::format_currency() to format it and currency data from the database
55
+	 * (which admins can change), otherwise uses MoneyFormatter which takes currency information from a JSON file
56
+	 * (which admins CANNOT change).
57
+	 * Legacy Schemas (use the admin-editable currency data from the database):
58
+	 *    'localized_float': "3,023.00"
59
+	 *    'no_currency_code': "$3,023.00"
60
+	 *    null: "$3,023.00<span>USD</span>"
61
+	 * New Schemas (use the currency data from a JSON file that we control):
62
+	 *    MoneyFormatter::RAW: "3023.0000"
63
+	 *    MoneyFormatter::DECIMAL_ONLY: "3023.00"
64
+	 *    MoneyFormatter::ADD THOUSANDS/: "3,023.00"
65
+	 *    MoneyFormatter::ADD_CURRENCY_SIGN: "$3,023.00"
66
+	 *    MoneyFormatter::ADD_CURRENCY_CODE: "$3,023.00<span>USD</span>"
67
+	 *
68
+	 * @param string|Money $value_on_field_to_be_outputted
69
+	 * @param string       $schema
70
+	 * @return string
71
+	 * @throws InvalidIdentifierException
72
+	 * @throws InvalidArgumentException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws EE_Error
76
+	 * @throws ReflectionException
77
+	 */
78
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
79
+	{
80
+			$value_on_field_to_be_outputted = $this->ensureNotMoney($value_on_field_to_be_outputted);
81
+			$pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
82
+
83
+			if ($schema === 'localized_float') {
84
+				return $pretty_float;
85
+			}
86
+			$display_code = true;
87
+			if ($schema === 'no_currency_code') {
88
+				//          echo "schema no currency!";
89
+				$display_code = false;
90
+			}
91
+
92
+			//we don't use the $pretty_float because format_currency will take care of it.
93
+			return EEH_Money::format_currency($value_on_field_to_be_outputted, false, $display_code);
94
+
95
+	}
96
+
97
+
98
+	/**
99
+	 * Make sure this value is a money object
100
+	 *
101
+	 * @param string|float|int|Money $value
102
+	 * @return Money
103
+	 * @throws InvalidIdentifierException
104
+	 * @throws InvalidArgumentException
105
+	 * @throws InvalidInterfaceException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws EE_Error
108
+	 */
109
+	private function ensureMoney($value)
110
+	{
111
+		if (! $value instanceof Money) {
112
+			return $this->money_factory->createForSite($value);
113
+		}
114
+		return $value;
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * Ensures we're dealing with something that isn't Money
121
+	 * (for passing off to legacy systems or the parent field)
122
+	 * @param  string|float|int|Money $value
123
+	 * @return string|float|int
124
+	 */
125
+	private function ensureNotMoney($value)
126
+	{
127
+		if( $value instanceof Money) {
128
+			return $value->amount();
129
+		}
130
+		return $value;
131
+	}
132
+
133
+
134
+	/**
135
+	 * If provided with a string, strips out money-related formatting to turn it into a proper float.
136
+	 * Rounds the float to the correct number of decimal places for this country's currency.
137
+	 * Also, interprets periods and commas according to the country's currency settings.
138
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks,
139
+	 * type cast it to a float first.
140
+	 *
141
+	 * @param string|float|int|Money $value_inputted_for_field_on_model_object
142
+	 * @return Money
143
+	 * @throws InvalidInterfaceException
144
+	 * @throws InvalidIdentifierException
145
+	 * @throws InvalidDataTypeException
146
+	 * @throws EE_Error
147
+	 * @throws InvalidArgumentException
148
+	 */
149
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
150
+	{
151
+		if ($value_inputted_for_field_on_model_object instanceof Money) {
152
+			return $value_inputted_for_field_on_model_object;
153
+		}
154
+		//now it's a float-style string or number
155
+		return $this->ensureMoney(
156
+			parent::prepare_for_set($value_inputted_for_field_on_model_object)
157
+		);
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * @param string|float|int|Money $value_of_field_on_model_object
164
+	 * @return float
165
+	 * @throws InvalidArgumentException
166
+	 * @throws InvalidInterfaceException
167
+	 * @throws InvalidDataTypeException
168
+	 */
169
+	public function prepare_for_get($value_of_field_on_model_object)
170
+	{
171
+		$value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object);
172
+		$c = EE_Registry::instance()->CFG->currency;
173
+		return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
174
+	}
175
+
176
+
177
+	/**
178
+	 * Takes the incoming float and create a money entity for the model object
179
+	 *
180
+	 * @param string|float|int $value_found_in_db_for_model_object
181
+	 * @return Money
182
+	 * @throws InvalidIdentifierException
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidInterfaceException
185
+	 * @throws InvalidDataTypeException
186
+	 * @throws EE_Error
187
+	 */
188
+	public function prepare_for_set_from_db($value_found_in_db_for_model_object)
189
+	{
190
+		return $this->money_factory->createForSite($value_found_in_db_for_model_object);
191
+	}
192
+
193
+
194
+
195
+	/**
196
+	 * Prepares a value for use in the DB
197
+	 * @param string|float|int|Money $value_of_field_on_model_object
198
+	 * @return float
199
+	 */
200
+	public function prepare_for_use_in_db($value_of_field_on_model_object)
201
+	{
202
+		$value_of_field_on_model_object = $this->ensureNotMoney($value_of_field_on_model_object);
203
+		return parent::prepare_for_use_in_db($value_of_field_on_model_object);
204
+	}
205
+
206
+
207
+
208
+	public function getSchemaProperties()
209
+	{
210
+		return array(
211
+			'raw' => array(
212
+				'description' =>  sprintf(
213
+					__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
214
+					$this->get_nicename()
215
+				),
216
+				'type' => 'number'
217
+			),
218
+			'pretty' => array(
219
+				'description' =>  sprintf(
220
+					__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
221
+					$this->get_nicename()
222
+				),
223
+				'type' => 'string'
224
+			)
225
+		);
226
+	}
227 227
 }
Please login to merge, or discard this patch.
core/services/context/ContextChecker.php 2 patches
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -22,148 +22,148 @@
 block discarded – undo
22 22
 class ContextChecker
23 23
 {
24 24
 
25
-    /**
26
-     * A unique string used to identify where this ContextChecker is being employed
27
-     * Is currently only used within the hook name for the filterable return value of isAllowed().
28
-     *
29
-     * @var string $identifier
30
-     */
31
-    private $identifier;
32
-
33
-    /**
34
-     * A list of values to be compared against the slug of the Context class passed to isAllowed()
35
-     *
36
-     * @var array $acceptable_values
37
-     */
38
-    private $acceptable_values;
39
-
40
-    /**
41
-     * Closure that will be called to perform the evaluation within isAllowed().
42
-     * If none is provided, then a simple type sensitive in_array() check will be used
43
-     * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
44
-     *
45
-     * @var Closure $evaluation_callback
46
-     */
47
-    private $evaluation_callback;
48
-
49
-
50
-    /**
51
-     * ContextChecker constructor.
52
-     *
53
-     * @param string       $identifier
54
-     * @param array        $acceptable_values
55
-     * @param Closure|null $evaluation_callback [optional]
56
-     */
57
-    public function __construct($identifier, array $acceptable_values, Closure $evaluation_callback = null)
58
-    {
59
-        $this->setIdentifier($identifier);
60
-        $this->setAcceptableValues($acceptable_values);
61
-        $this->setEvaluationCallback($evaluation_callback);
62
-    }
63
-
64
-
65
-    /**
66
-     * @param string $identifier
67
-     */
68
-    private function setIdentifier($identifier)
69
-    {
70
-        $this->identifier = sanitize_key($identifier);
71
-    }
72
-
73
-
74
-    /**
75
-     * @param array $acceptable_values
76
-     */
77
-    private function setAcceptableValues(array $acceptable_values)
78
-    {
79
-        $this->acceptable_values = $acceptable_values;
80
-    }
81
-
82
-
83
-    /**
84
-     * @param Closure $evaluation_callback
85
-     */
86
-    private function setEvaluationCallback(Closure $evaluation_callback = null)
87
-    {
88
-        $this->evaluation_callback = $evaluation_callback instanceof Closure
89
-            ? $evaluation_callback
90
-            : function (ContextInterface $context, $acceptable_values) {
91
-                return in_array($context->slug(), $acceptable_values, true);
92
-            };
93
-    }
94
-
95
-
96
-    /**
97
-     * @return string
98
-     */
99
-    protected function identifier()
100
-    {
101
-        return $this->identifier;
102
-    }
103
-
104
-
105
-    /**
106
-     * @return array
107
-     */
108
-    protected function acceptableValues()
109
-    {
110
-        return apply_filters(
111
-            "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
112
-            $this->acceptable_values
113
-        );
114
-    }
115
-
116
-
117
-    /**
118
-     * @return Closure
119
-     */
120
-    protected function evaluationCallback()
121
-    {
122
-        return $this->evaluation_callback;
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * Returns true if the incoming Context class slug matches one of the preset acceptable values.
129
-     * The result is filterable using the identifier for this ContextChecker.
130
-     * example:
131
-     * If this ContextChecker's $identifier was set to "registration-checkout-type",
132
-     * then the filter here would be named:
133
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
134
-     * Other code could hook into the filter in isAllowed() using the above name
135
-     * and test for additional acceptable values.
136
-     * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
137
-     * then adding a filter to
138
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
139
-     * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
140
-     *  example:
141
-     *      add_filter(
142
-     *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
143
-     *          function ($is_allowed, ContextInterface $context) {
144
-     *              return $context->slug() === 'wait-list-checkout'
145
-     *                  ? true
146
-     *                  : $is_allowed;
147
-     *          },
148
-     *          10,
149
-     *          2
150
-     *      );
151
-     *
152
-     * @param ContextInterface $context
153
-     * @return boolean
154
-     */
155
-    public function isAllowed(ContextInterface $context)
156
-    {
157
-        $evaluation_callback = $this->evaluationCallback();
158
-        return filter_var(
159
-            apply_filters(
160
-                "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
161
-                $evaluation_callback($context, $this->acceptableValues()),
162
-                $context,
163
-                $this
164
-            ),
165
-            FILTER_VALIDATE_BOOLEAN
166
-        );
167
-    }
25
+	/**
26
+	 * A unique string used to identify where this ContextChecker is being employed
27
+	 * Is currently only used within the hook name for the filterable return value of isAllowed().
28
+	 *
29
+	 * @var string $identifier
30
+	 */
31
+	private $identifier;
32
+
33
+	/**
34
+	 * A list of values to be compared against the slug of the Context class passed to isAllowed()
35
+	 *
36
+	 * @var array $acceptable_values
37
+	 */
38
+	private $acceptable_values;
39
+
40
+	/**
41
+	 * Closure that will be called to perform the evaluation within isAllowed().
42
+	 * If none is provided, then a simple type sensitive in_array() check will be used
43
+	 * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
44
+	 *
45
+	 * @var Closure $evaluation_callback
46
+	 */
47
+	private $evaluation_callback;
48
+
49
+
50
+	/**
51
+	 * ContextChecker constructor.
52
+	 *
53
+	 * @param string       $identifier
54
+	 * @param array        $acceptable_values
55
+	 * @param Closure|null $evaluation_callback [optional]
56
+	 */
57
+	public function __construct($identifier, array $acceptable_values, Closure $evaluation_callback = null)
58
+	{
59
+		$this->setIdentifier($identifier);
60
+		$this->setAcceptableValues($acceptable_values);
61
+		$this->setEvaluationCallback($evaluation_callback);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param string $identifier
67
+	 */
68
+	private function setIdentifier($identifier)
69
+	{
70
+		$this->identifier = sanitize_key($identifier);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param array $acceptable_values
76
+	 */
77
+	private function setAcceptableValues(array $acceptable_values)
78
+	{
79
+		$this->acceptable_values = $acceptable_values;
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param Closure $evaluation_callback
85
+	 */
86
+	private function setEvaluationCallback(Closure $evaluation_callback = null)
87
+	{
88
+		$this->evaluation_callback = $evaluation_callback instanceof Closure
89
+			? $evaluation_callback
90
+			: function (ContextInterface $context, $acceptable_values) {
91
+				return in_array($context->slug(), $acceptable_values, true);
92
+			};
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return string
98
+	 */
99
+	protected function identifier()
100
+	{
101
+		return $this->identifier;
102
+	}
103
+
104
+
105
+	/**
106
+	 * @return array
107
+	 */
108
+	protected function acceptableValues()
109
+	{
110
+		return apply_filters(
111
+			"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
112
+			$this->acceptable_values
113
+		);
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return Closure
119
+	 */
120
+	protected function evaluationCallback()
121
+	{
122
+		return $this->evaluation_callback;
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * Returns true if the incoming Context class slug matches one of the preset acceptable values.
129
+	 * The result is filterable using the identifier for this ContextChecker.
130
+	 * example:
131
+	 * If this ContextChecker's $identifier was set to "registration-checkout-type",
132
+	 * then the filter here would be named:
133
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
134
+	 * Other code could hook into the filter in isAllowed() using the above name
135
+	 * and test for additional acceptable values.
136
+	 * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
137
+	 * then adding a filter to
138
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
139
+	 * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
140
+	 *  example:
141
+	 *      add_filter(
142
+	 *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
143
+	 *          function ($is_allowed, ContextInterface $context) {
144
+	 *              return $context->slug() === 'wait-list-checkout'
145
+	 *                  ? true
146
+	 *                  : $is_allowed;
147
+	 *          },
148
+	 *          10,
149
+	 *          2
150
+	 *      );
151
+	 *
152
+	 * @param ContextInterface $context
153
+	 * @return boolean
154
+	 */
155
+	public function isAllowed(ContextInterface $context)
156
+	{
157
+		$evaluation_callback = $this->evaluationCallback();
158
+		return filter_var(
159
+			apply_filters(
160
+				"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
161
+				$evaluation_callback($context, $this->acceptableValues()),
162
+				$context,
163
+				$this
164
+			),
165
+			FILTER_VALIDATE_BOOLEAN
166
+		);
167
+	}
168 168
 
169 169
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
     {
88 88
         $this->evaluation_callback = $evaluation_callback instanceof Closure
89 89
             ? $evaluation_callback
90
-            : function (ContextInterface $context, $acceptable_values) {
90
+            : function(ContextInterface $context, $acceptable_values) {
91 91
                 return in_array($context->slug(), $acceptable_values, true);
92 92
             };
93 93
     }
Please login to merge, or discard this patch.
core/domain/entities/Context.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -17,64 +17,64 @@
 block discarded – undo
17 17
 class Context implements ContextInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $slug
22
-     */
23
-    private $slug;
24
-
25
-    /**
26
-     * @var string $description
27
-     */
28
-    private $description;
29
-
30
-
31
-    /**
32
-     * Context constructor.
33
-     *
34
-     * @param string $slug
35
-     * @param string $description
36
-     */
37
-    public function __construct($slug, $description)
38
-    {
39
-        $this->setSlug($slug);
40
-        $this->setDescription($description);
41
-    }
42
-
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function slug()
48
-    {
49
-        return $this->slug;
50
-    }
51
-
52
-
53
-    /**
54
-     * @param string $slug
55
-     */
56
-    private function setSlug($slug)
57
-    {
58
-        $this->slug = sanitize_key($slug);
59
-    }
60
-
61
-
62
-    /**
63
-     * @return string
64
-     */
65
-    public function description()
66
-    {
67
-        return $this->description;
68
-    }
69
-
70
-
71
-    /**
72
-     * @param string $description
73
-     */
74
-    private function setDescription($description)
75
-    {
76
-        $this->description = sanitize_text_field($description);
77
-    }
20
+	/**
21
+	 * @var string $slug
22
+	 */
23
+	private $slug;
24
+
25
+	/**
26
+	 * @var string $description
27
+	 */
28
+	private $description;
29
+
30
+
31
+	/**
32
+	 * Context constructor.
33
+	 *
34
+	 * @param string $slug
35
+	 * @param string $description
36
+	 */
37
+	public function __construct($slug, $description)
38
+	{
39
+		$this->setSlug($slug);
40
+		$this->setDescription($description);
41
+	}
42
+
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function slug()
48
+	{
49
+		return $this->slug;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param string $slug
55
+	 */
56
+	private function setSlug($slug)
57
+	{
58
+		$this->slug = sanitize_key($slug);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return string
64
+	 */
65
+	public function description()
66
+	{
67
+		return $this->description;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param string $description
73
+	 */
74
+	private function setDescription($description)
75
+	{
76
+		$this->description = sanitize_text_field($description);
77
+	}
78 78
 
79 79
 }
80 80
 // Location: Context.php
Please login to merge, or discard this patch.