Completed
Branch BUG/11214/move-command-handler... (de017e)
by
unknown
04:20 queued 02:32
created
Paypal_Standard/templates/paypal_standard_intro.template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 $closing_tag = '</a>';
3 3
 //if this is decaf, which is put on WordPress.org, we need to inform users that
4 4
 //we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12
5
-if( apply_filters( 'FHEE__ee_show_affiliate_links', true ) ) {
6
-	$closing_tag .= esc_html__( ' (affiliate link)', 'event_espresso' );
5
+if (apply_filters('FHEE__ee_show_affiliate_links', true)) {
6
+	$closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
7 7
 }
8
-printf( esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag );
9 8
\ No newline at end of file
9
+printf(esc_html__('PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', $closing_tag);
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/container/Recipe.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     )
122 122
     {
123 123
         $this->setIdentifier($identifier);
124
-        $this->setFilters((array)$filters);
125
-        $this->setIngredients((array)$ingredients);
124
+        $this->setFilters((array) $filters);
125
+        $this->setIngredients((array) $ingredients);
126 126
         $this->setType($type);
127 127
         $this->setPaths($paths);
128 128
         $this->setFqcn($fqcn);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function filters()
157 157
     {
158
-        return (array)$this->filters;
158
+        return (array) $this->filters;
159 159
     }
160 160
 
161 161
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function paths()
187 187
     {
188
-        return (array)$this->paths;
188
+        return (array) $this->paths;
189 189
     }
190 190
 
191 191
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                 __('string or array of strings (full server filepath(s))', 'event_espresso')
318 318
             );
319 319
         }
320
-        $paths = (array)$paths;
320
+        $paths = (array) $paths;
321 321
         foreach ($paths as $path) {
322 322
             if (strpos($path, '*') === false && ! is_readable($path)) {
323 323
                 throw new RuntimeException(
Please login to merge, or discard this patch.
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use RuntimeException;
9 9
 
10 10
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -24,316 +24,316 @@  discard block
 block discarded – undo
24 24
 class Recipe implements RecipeInterface
25 25
 {
26 26
 
27
-    /**
28
-     * A default Recipe to use if none is specified for a class
29
-     */
30
-    const DEFAULT_ID = '*';
31
-
32
-    /**
33
-     * Identifier for the entity class to be constructed.
34
-     * Typically a Fully Qualified Class Name
35
-     *
36
-     * @var string $identifier
37
-     */
38
-    private $identifier;
39
-
40
-    /**
41
-     * Fully Qualified Class Name
42
-     *
43
-     * @var string $fqcn
44
-     */
45
-    private $fqcn;
46
-
47
-    /**
48
-     * a dependency class map array
49
-     * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
50
-     * and that class type hints for an interface, then this property allows you to configure what dependencies
51
-     * get used when instantiating the class.
52
-     * For example:
53
-     *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
54
-     *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
55
-     *  We want one Coffee object to use HonduranBean for its BeanInterface,
56
-     *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
57
-     *  To do this, we need to create two Recipes:
58
-     *      one with an identifier of 'HonduranCoffee' using the following ingredients :
59
-     *          array('BeanInterface' => 'HonduranBean')
60
-     *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
61
-     *          array('BeanInterface' => 'KenyanBean')
62
-     *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
63
-     *  an instance of HonduranBean will get injected for the BeanInterface dependency,
64
-     *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
65
-     *  an instance of KenyanBean will get injected for the BeanInterface dependency
66
-     *
67
-     * @var array $ingredients
68
-     */
69
-    private $ingredients = array();
70
-
71
-    /**
72
-     * one of the class constants from CoffeeShop:
73
-     *  CoffeeMaker::BREW_NEW - creates a new instance
74
-     *  CoffeeMaker::BREW_SHARED - creates a shared instance
75
-     *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
76
-     *
77
-     * @var string $type
78
-     */
79
-    private $type;
80
-
81
-    /**
82
-     * class name aliases - typically a Fully Qualified Interface that the class implements
83
-     * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
84
-     *
85
-     * @var array $filters
86
-     */
87
-    private $filters = array();
88
-
89
-    /**
90
-     * array of full server filepaths to files that may contain the class
91
-     *
92
-     * @var array $paths
93
-     */
94
-    private $paths = array();
95
-
96
-
97
-
98
-    /**
99
-     * Recipe constructor.
100
-     *
101
-     * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
102
-     * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
103
-     * @param array  $ingredients   array of dependencies that can not be resolved automatically,
104
-     *                              used for resolving concrete classes for type hinted interfaces
105
-     *                              for the dependencies of THIS class
106
-     * @param string $type          recipe type: one of the class constants on
107
-     *                              \EventEspresso\core\services\container\CoffeeMaker
108
-     * @param array  $filters       array of class aliases, or class interfaces
109
-     *                              this works somewhat opposite to the $ingredients array above,
110
-     *                              in that this array specifies interfaces or aliases
111
-     *                              that this Recipe can be used for when resolving OTHER class's dependencies
112
-     * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
113
-     *                              then supply a filepath, or array of filepaths, so that it can be included
114
-     */
115
-    public function __construct(
116
-	    $identifier,
117
-        $fqcn = '',
118
-        $filters = array(),
119
-        $ingredients = array(),
120
-	    $type = CoffeeMaker::BREW_NEW,
121
-	    $paths = array()
122
-    )
123
-    {
124
-        $this->setIdentifier($identifier);
125
-        $this->setFilters((array)$filters);
126
-        $this->setIngredients((array)$ingredients);
127
-        $this->setType($type);
128
-        $this->setPaths($paths);
129
-        $this->setFqcn($fqcn);
130
-    }
131
-
132
-
133
-
134
-    /**
135
-     * @return string
136
-     */
137
-    public function identifier()
138
-    {
139
-        return $this->identifier;
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @return string
146
-     */
147
-    public function fqcn()
148
-    {
149
-        return $this->fqcn;
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     * @return array
156
-     */
157
-    public function filters()
158
-    {
159
-        return (array)$this->filters;
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * @return array
166
-     */
167
-    public function ingredients()
168
-    {
169
-        return $this->ingredients;
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * @return string
176
-     */
177
-    public function type()
178
-    {
179
-        return $this->type;
180
-    }
181
-
182
-
183
-
184
-    /**
185
-     * @return array
186
-     */
187
-    public function paths()
188
-    {
189
-        return (array)$this->paths;
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * @param  string $identifier Identifier for the entity class that the Recipe applies to
196
-     *                            Typically a Fully Qualified Class Name
197
-     */
198
-    public function setIdentifier($identifier)
199
-    {
200
-        if ( ! is_string($identifier) || empty($identifier)) {
201
-            throw new InvalidIdentifierException(
202
-                is_object($identifier) ? get_class($identifier) : gettype($identifier),
203
-                __('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
204
-            );
205
-        }
206
-        $this->identifier = $identifier;
207
-    }
208
-
209
-
210
-
211
-    /**
212
-     * Ensures incoming string is a valid Fully Qualified Class Name,
213
-     * except if this is the default wildcard Recipe ( * ),
214
-     * or it's NOT an actual FQCN because the Recipe is using filepaths
215
-     * for classes that are not PSR-4 compatible
216
-     * PLZ NOTE:
217
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
218
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
219
-     *
220
-     * @param string $fqcn
221
-     * @throws InvalidDataTypeException
222
-     * @throws InvalidClassException
223
-     * @throws InvalidInterfaceException
224
-     */
225
-    public function setFqcn($fqcn)
226
-    {
227
-	    $fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
228
-        if ( ! is_string($fqcn)) {
229
-            throw new InvalidDataTypeException(
230
-                '$fqcn',
231
-                is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
232
-                __('string (Fully\Qualified\ClassName)', 'event_espresso')
233
-            );
234
-        }
235
-        $fqcn = ltrim($fqcn, '\\');
236
-        if (
237
-            $fqcn !== Recipe::DEFAULT_ID
238
-            && ! empty($fqcn)
239
-            && empty($this->paths)
240
-            && ! (class_exists($fqcn) || interface_exists($fqcn))
241
-        ) {
242
-            throw new InvalidClassException($fqcn);
243
-        }
244
-        $this->fqcn = $fqcn;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
251
-     *                              example:
252
-     *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
253
-     */
254
-    public function setIngredients(array $ingredients)
255
-    {
256
-        if (empty($ingredients)) {
257
-            return;
258
-        }
259
-        if ( ! is_array($ingredients)) {
260
-            throw new InvalidDataTypeException(
261
-                '$ingredients',
262
-                is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
263
-                __('array of class dependencies', 'event_espresso')
264
-            );
265
-        }
266
-        $this->ingredients = array_merge($this->ingredients, $ingredients);
267
-    }
268
-
269
-
270
-    /**
271
-     * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
272
-     */
273
-    public function setType($type = CoffeeMaker::BREW_NEW)
274
-    {
275
-        $this->type = CoffeeMaker::validateType($type);
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
282
-     *                          example:
283
-     *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
284
-     */
285
-    public function setFilters(array $filters)
286
-    {
287
-        if (empty($filters)) {
288
-            return;
289
-        }
290
-        if ( ! is_array($filters)) {
291
-            throw new InvalidDataTypeException(
292
-                '$filters',
293
-                is_object($filters) ? get_class($filters) : gettype($filters),
294
-                __('array of class aliases', 'event_espresso')
295
-            );
296
-        }
297
-        $this->filters = array_merge($this->filters, $filters);
298
-    }
299
-
300
-
301
-
302
-    /**
303
-     * Ensures incoming paths is a valid filepath, or array of valid filepaths,
304
-     * and merges them in with any existing filepaths
305
-     *
306
-     * PLZ NOTE:
307
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
308
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
309
-     *
310
-     * @param string|array $paths
311
-     */
312
-    public function setPaths($paths = array())
313
-    {
314
-        if (empty($paths)) {
315
-            return;
316
-        }
317
-        if ( ! (is_string($paths) || is_array($paths))) {
318
-            throw new InvalidDataTypeException(
319
-                '$path',
320
-                is_object($paths) ? get_class($paths) : gettype($paths),
321
-                __('string or array of strings (full server filepath(s))', 'event_espresso')
322
-            );
323
-        }
324
-        $paths = (array)$paths;
325
-        foreach ($paths as $path) {
326
-            if (strpos($path, '*') === false && ! is_readable($path)) {
327
-                throw new RuntimeException(
328
-                    sprintf(
329
-                        __('The following filepath is not readable: "%1$s"', 'event_espresso'),
330
-                        $path
331
-                    )
332
-                );
333
-            }
334
-        }
335
-        $this->paths = array_merge($this->paths, $paths);
336
-    }
27
+	/**
28
+	 * A default Recipe to use if none is specified for a class
29
+	 */
30
+	const DEFAULT_ID = '*';
31
+
32
+	/**
33
+	 * Identifier for the entity class to be constructed.
34
+	 * Typically a Fully Qualified Class Name
35
+	 *
36
+	 * @var string $identifier
37
+	 */
38
+	private $identifier;
39
+
40
+	/**
41
+	 * Fully Qualified Class Name
42
+	 *
43
+	 * @var string $fqcn
44
+	 */
45
+	private $fqcn;
46
+
47
+	/**
48
+	 * a dependency class map array
49
+	 * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
50
+	 * and that class type hints for an interface, then this property allows you to configure what dependencies
51
+	 * get used when instantiating the class.
52
+	 * For example:
53
+	 *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
54
+	 *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
55
+	 *  We want one Coffee object to use HonduranBean for its BeanInterface,
56
+	 *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
57
+	 *  To do this, we need to create two Recipes:
58
+	 *      one with an identifier of 'HonduranCoffee' using the following ingredients :
59
+	 *          array('BeanInterface' => 'HonduranBean')
60
+	 *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
61
+	 *          array('BeanInterface' => 'KenyanBean')
62
+	 *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
63
+	 *  an instance of HonduranBean will get injected for the BeanInterface dependency,
64
+	 *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
65
+	 *  an instance of KenyanBean will get injected for the BeanInterface dependency
66
+	 *
67
+	 * @var array $ingredients
68
+	 */
69
+	private $ingredients = array();
70
+
71
+	/**
72
+	 * one of the class constants from CoffeeShop:
73
+	 *  CoffeeMaker::BREW_NEW - creates a new instance
74
+	 *  CoffeeMaker::BREW_SHARED - creates a shared instance
75
+	 *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
76
+	 *
77
+	 * @var string $type
78
+	 */
79
+	private $type;
80
+
81
+	/**
82
+	 * class name aliases - typically a Fully Qualified Interface that the class implements
83
+	 * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
84
+	 *
85
+	 * @var array $filters
86
+	 */
87
+	private $filters = array();
88
+
89
+	/**
90
+	 * array of full server filepaths to files that may contain the class
91
+	 *
92
+	 * @var array $paths
93
+	 */
94
+	private $paths = array();
95
+
96
+
97
+
98
+	/**
99
+	 * Recipe constructor.
100
+	 *
101
+	 * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
102
+	 * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
103
+	 * @param array  $ingredients   array of dependencies that can not be resolved automatically,
104
+	 *                              used for resolving concrete classes for type hinted interfaces
105
+	 *                              for the dependencies of THIS class
106
+	 * @param string $type          recipe type: one of the class constants on
107
+	 *                              \EventEspresso\core\services\container\CoffeeMaker
108
+	 * @param array  $filters       array of class aliases, or class interfaces
109
+	 *                              this works somewhat opposite to the $ingredients array above,
110
+	 *                              in that this array specifies interfaces or aliases
111
+	 *                              that this Recipe can be used for when resolving OTHER class's dependencies
112
+	 * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
113
+	 *                              then supply a filepath, or array of filepaths, so that it can be included
114
+	 */
115
+	public function __construct(
116
+		$identifier,
117
+		$fqcn = '',
118
+		$filters = array(),
119
+		$ingredients = array(),
120
+		$type = CoffeeMaker::BREW_NEW,
121
+		$paths = array()
122
+	)
123
+	{
124
+		$this->setIdentifier($identifier);
125
+		$this->setFilters((array)$filters);
126
+		$this->setIngredients((array)$ingredients);
127
+		$this->setType($type);
128
+		$this->setPaths($paths);
129
+		$this->setFqcn($fqcn);
130
+	}
131
+
132
+
133
+
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function identifier()
138
+	{
139
+		return $this->identifier;
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @return string
146
+	 */
147
+	public function fqcn()
148
+	{
149
+		return $this->fqcn;
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 * @return array
156
+	 */
157
+	public function filters()
158
+	{
159
+		return (array)$this->filters;
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * @return array
166
+	 */
167
+	public function ingredients()
168
+	{
169
+		return $this->ingredients;
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * @return string
176
+	 */
177
+	public function type()
178
+	{
179
+		return $this->type;
180
+	}
181
+
182
+
183
+
184
+	/**
185
+	 * @return array
186
+	 */
187
+	public function paths()
188
+	{
189
+		return (array)$this->paths;
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * @param  string $identifier Identifier for the entity class that the Recipe applies to
196
+	 *                            Typically a Fully Qualified Class Name
197
+	 */
198
+	public function setIdentifier($identifier)
199
+	{
200
+		if ( ! is_string($identifier) || empty($identifier)) {
201
+			throw new InvalidIdentifierException(
202
+				is_object($identifier) ? get_class($identifier) : gettype($identifier),
203
+				__('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
204
+			);
205
+		}
206
+		$this->identifier = $identifier;
207
+	}
208
+
209
+
210
+
211
+	/**
212
+	 * Ensures incoming string is a valid Fully Qualified Class Name,
213
+	 * except if this is the default wildcard Recipe ( * ),
214
+	 * or it's NOT an actual FQCN because the Recipe is using filepaths
215
+	 * for classes that are not PSR-4 compatible
216
+	 * PLZ NOTE:
217
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
218
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
219
+	 *
220
+	 * @param string $fqcn
221
+	 * @throws InvalidDataTypeException
222
+	 * @throws InvalidClassException
223
+	 * @throws InvalidInterfaceException
224
+	 */
225
+	public function setFqcn($fqcn)
226
+	{
227
+		$fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
228
+		if ( ! is_string($fqcn)) {
229
+			throw new InvalidDataTypeException(
230
+				'$fqcn',
231
+				is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
232
+				__('string (Fully\Qualified\ClassName)', 'event_espresso')
233
+			);
234
+		}
235
+		$fqcn = ltrim($fqcn, '\\');
236
+		if (
237
+			$fqcn !== Recipe::DEFAULT_ID
238
+			&& ! empty($fqcn)
239
+			&& empty($this->paths)
240
+			&& ! (class_exists($fqcn) || interface_exists($fqcn))
241
+		) {
242
+			throw new InvalidClassException($fqcn);
243
+		}
244
+		$this->fqcn = $fqcn;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
251
+	 *                              example:
252
+	 *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
253
+	 */
254
+	public function setIngredients(array $ingredients)
255
+	{
256
+		if (empty($ingredients)) {
257
+			return;
258
+		}
259
+		if ( ! is_array($ingredients)) {
260
+			throw new InvalidDataTypeException(
261
+				'$ingredients',
262
+				is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
263
+				__('array of class dependencies', 'event_espresso')
264
+			);
265
+		}
266
+		$this->ingredients = array_merge($this->ingredients, $ingredients);
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
272
+	 */
273
+	public function setType($type = CoffeeMaker::BREW_NEW)
274
+	{
275
+		$this->type = CoffeeMaker::validateType($type);
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
282
+	 *                          example:
283
+	 *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
284
+	 */
285
+	public function setFilters(array $filters)
286
+	{
287
+		if (empty($filters)) {
288
+			return;
289
+		}
290
+		if ( ! is_array($filters)) {
291
+			throw new InvalidDataTypeException(
292
+				'$filters',
293
+				is_object($filters) ? get_class($filters) : gettype($filters),
294
+				__('array of class aliases', 'event_espresso')
295
+			);
296
+		}
297
+		$this->filters = array_merge($this->filters, $filters);
298
+	}
299
+
300
+
301
+
302
+	/**
303
+	 * Ensures incoming paths is a valid filepath, or array of valid filepaths,
304
+	 * and merges them in with any existing filepaths
305
+	 *
306
+	 * PLZ NOTE:
307
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
308
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
309
+	 *
310
+	 * @param string|array $paths
311
+	 */
312
+	public function setPaths($paths = array())
313
+	{
314
+		if (empty($paths)) {
315
+			return;
316
+		}
317
+		if ( ! (is_string($paths) || is_array($paths))) {
318
+			throw new InvalidDataTypeException(
319
+				'$path',
320
+				is_object($paths) ? get_class($paths) : gettype($paths),
321
+				__('string or array of strings (full server filepath(s))', 'event_espresso')
322
+			);
323
+		}
324
+		$paths = (array)$paths;
325
+		foreach ($paths as $path) {
326
+			if (strpos($path, '*') === false && ! is_readable($path)) {
327
+				throw new RuntimeException(
328
+					sprintf(
329
+						__('The following filepath is not readable: "%1$s"', 'event_espresso'),
330
+						$path
331
+					)
332
+				);
333
+			}
334
+		}
335
+		$this->paths = array_merge($this->paths, $paths);
336
+	}
337 337
 
338 338
 
339 339
 
Please login to merge, or discard this patch.
core/services/container/DependencyInjector.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use UnexpectedValueException;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -22,214 +22,214 @@  discard block
 block discarded – undo
22 22
 class DependencyInjector implements InjectorInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var CoffeePotInterface $coffee_pot
27
-     */
28
-    private $coffee_pot;
29
-
30
-    /**
31
-     * @var \EEH_Array $array_helper
32
-     */
33
-    private $array_helper;
34
-
35
-    /**
36
-     * @var \ReflectionClass[] $reflectors
37
-     */
38
-    private $reflectors;
39
-
40
-    /**
41
-     * @var \ReflectionMethod[] $constructors
42
-     */
43
-    private $constructors;
44
-
45
-    /**
46
-     * @var \ReflectionParameter[] $parameters
47
-     */
48
-    private $parameters;
49
-
50
-
51
-
52
-    /**
53
-     * DependencyInjector constructor
54
-     *
55
-     * @param CoffeePotInterface $coffee_pot
56
-     * @param \EEH_Array         $array_helper
57
-     */
58
-    public function __construct(CoffeePotInterface $coffee_pot, \EEH_Array $array_helper)
59
-    {
60
-        $this->coffee_pot = $coffee_pot;
61
-        $this->array_helper = $array_helper;
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * getReflectionClass
68
-     * checks if a ReflectionClass object has already been generated for a class
69
-     * and returns that instead of creating a new one
70
-     *
71
-     * @param string $class_name
72
-     * @return \ReflectionClass
73
-     */
74
-    public function getReflectionClass($class_name)
75
-    {
76
-        if (
77
-            ! isset($this->reflectors[$class_name])
78
-            || ! $this->reflectors[$class_name] instanceof \ReflectionClass
79
-        ) {
80
-            $this->reflectors[$class_name] = new \ReflectionClass($class_name);
81
-        }
82
-        return $this->reflectors[$class_name];
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * getConstructor
89
-     * checks if a ReflectionMethod object has already been generated for the class constructor
90
-     * and returns that instead of creating a new one
91
-     *
92
-     * @param \ReflectionClass $reflector
93
-     * @return \ReflectionMethod
94
-     */
95
-    protected function getConstructor(\ReflectionClass $reflector)
96
-    {
97
-        if (
98
-            ! isset($this->constructors[$reflector->getName()])
99
-            || ! $this->constructors[$reflector->getName()] instanceof \ReflectionMethod
100
-        ) {
101
-            $this->constructors[$reflector->getName()] = $reflector->getConstructor();
102
-        }
103
-        return $this->constructors[$reflector->getName()];
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * getParameters
110
-     * checks if an array of ReflectionParameter objects has already been generated for the class constructor
111
-     * and returns that instead of creating a new one
112
-     *
113
-     * @param \ReflectionMethod $constructor
114
-     * @return \ReflectionParameter[]
115
-     */
116
-    protected function getParameters(\ReflectionMethod $constructor)
117
-    {
118
-        if ( ! isset($this->parameters[$constructor->class])) {
119
-            $this->parameters[$constructor->class] = $constructor->getParameters();
120
-        }
121
-        return $this->parameters[$constructor->class];
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * resolveDependencies
128
-     * examines the constructor for the requested class to determine
129
-     * if any dependencies exist, and if they can be injected.
130
-     * If so, then those classes will be added to the array of arguments passed to the constructor
131
-     * PLZ NOTE: this is achieved by type hinting the constructor params
132
-     * For example:
133
-     *        if attempting to load a class "Foo" with the following constructor:
134
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
135
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
136
-     *        but only IF they are NOT already present in the incoming arguments array,
137
-     *        and the correct classes can be loaded
138
-     *
139
-     * @param RecipeInterface   $recipe
140
-     * @param \ReflectionClass  $reflector
141
-     * @param array             $arguments
142
-     * @return array
143
-     */
144
-    public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array())
145
-    {
146
-        // if arguments array is numerically and sequentially indexed, then we want it to remain as is,
147
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
148
-        $arguments = $this->array_helper->is_array_numerically_and_sequentially_indexed($arguments)
149
-            ? $arguments
150
-            : array($arguments);
151
-        $resolved_parameters = array();
152
-        // let's examine the constructor
153
-        // let's examine the constructor
154
-        $constructor = $this->getConstructor($reflector);
155
-        // whu? huh? nothing?
156
-        if ( ! $constructor) {
157
-            return $arguments;
158
-        }
159
-        // get constructor parameters
160
-        $params = $this->getParameters($constructor);
161
-        if (empty($params)) {
162
-            return $resolved_parameters;
163
-        }
164
-        $ingredients = $recipe->ingredients();
165
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
166
-        $argument_keys = array_keys($arguments);
167
-        // now loop thru all of the constructors expected parameters
168
-        foreach ($params as $index => $param) {
169
-            if ( ! $param instanceof \ReflectionParameter) {
170
-                continue;
171
-            }
172
-            // is this a dependency for a specific class ?
173
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
174
-            if (
175
-                // param is specified in the list of ingredients for this Recipe
176
-                isset($ingredients[$param_class])
177
-            ) {
178
-                // attempt to inject the dependency
179
-                $resolved_parameters[$index] = $this->injectDependency($ingredients[$param_class]);
180
-            } else if (
181
-                // param is not even a class
182
-                empty($param_class)
183
-                // and something already exists in the incoming arguments for this param
184
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
185
-            ) {
186
-                // add parameter from incoming arguments
187
-                $resolved_parameters[$index] = $arguments[$argument_keys[$index]];
188
-            } else if (
189
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
190
-                ! empty($param_class)
191
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
192
-                && $arguments[$argument_keys[$index]] instanceof $param_class
193
-            ) {
194
-                // add parameter from incoming arguments
195
-                $resolved_parameters[$index] = $arguments[$argument_keys[$index]];
196
-            } else if (
197
-                // parameter is type hinted as a class, and should be injected
198
-            ! empty($param_class)
199
-            ) {
200
-                // attempt to inject the dependency
201
-                $resolved_parameters[$index] = $this->injectDependency($param_class);
202
-            } else if ($param->isOptional()) {
203
-                $resolved_parameters[$index] = $param->getDefaultValue();
204
-            } else {
205
-                $resolved_parameters[$index] = null;
206
-            }
207
-        }
208
-        return $resolved_parameters;
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     * @param string $param_class
215
-     * @return mixed
216
-     */
217
-    private function injectDependency($param_class)
218
-    {
219
-        $dependency = $this->coffee_pot->brew($param_class);
220
-        if ( ! $dependency instanceof $param_class) {
221
-            throw new UnexpectedValueException(
222
-                sprintf(
223
-                    __(
224
-                        'Could not resolve dependency for "%1$s" for the "%2$s" class constructor.',
225
-                        'event_espresso'
226
-                    ),
227
-                    $param_class
228
-                )
229
-            );
230
-        }
231
-        return $dependency;
232
-    }
25
+	/**
26
+	 * @var CoffeePotInterface $coffee_pot
27
+	 */
28
+	private $coffee_pot;
29
+
30
+	/**
31
+	 * @var \EEH_Array $array_helper
32
+	 */
33
+	private $array_helper;
34
+
35
+	/**
36
+	 * @var \ReflectionClass[] $reflectors
37
+	 */
38
+	private $reflectors;
39
+
40
+	/**
41
+	 * @var \ReflectionMethod[] $constructors
42
+	 */
43
+	private $constructors;
44
+
45
+	/**
46
+	 * @var \ReflectionParameter[] $parameters
47
+	 */
48
+	private $parameters;
49
+
50
+
51
+
52
+	/**
53
+	 * DependencyInjector constructor
54
+	 *
55
+	 * @param CoffeePotInterface $coffee_pot
56
+	 * @param \EEH_Array         $array_helper
57
+	 */
58
+	public function __construct(CoffeePotInterface $coffee_pot, \EEH_Array $array_helper)
59
+	{
60
+		$this->coffee_pot = $coffee_pot;
61
+		$this->array_helper = $array_helper;
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * getReflectionClass
68
+	 * checks if a ReflectionClass object has already been generated for a class
69
+	 * and returns that instead of creating a new one
70
+	 *
71
+	 * @param string $class_name
72
+	 * @return \ReflectionClass
73
+	 */
74
+	public function getReflectionClass($class_name)
75
+	{
76
+		if (
77
+			! isset($this->reflectors[$class_name])
78
+			|| ! $this->reflectors[$class_name] instanceof \ReflectionClass
79
+		) {
80
+			$this->reflectors[$class_name] = new \ReflectionClass($class_name);
81
+		}
82
+		return $this->reflectors[$class_name];
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * getConstructor
89
+	 * checks if a ReflectionMethod object has already been generated for the class constructor
90
+	 * and returns that instead of creating a new one
91
+	 *
92
+	 * @param \ReflectionClass $reflector
93
+	 * @return \ReflectionMethod
94
+	 */
95
+	protected function getConstructor(\ReflectionClass $reflector)
96
+	{
97
+		if (
98
+			! isset($this->constructors[$reflector->getName()])
99
+			|| ! $this->constructors[$reflector->getName()] instanceof \ReflectionMethod
100
+		) {
101
+			$this->constructors[$reflector->getName()] = $reflector->getConstructor();
102
+		}
103
+		return $this->constructors[$reflector->getName()];
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * getParameters
110
+	 * checks if an array of ReflectionParameter objects has already been generated for the class constructor
111
+	 * and returns that instead of creating a new one
112
+	 *
113
+	 * @param \ReflectionMethod $constructor
114
+	 * @return \ReflectionParameter[]
115
+	 */
116
+	protected function getParameters(\ReflectionMethod $constructor)
117
+	{
118
+		if ( ! isset($this->parameters[$constructor->class])) {
119
+			$this->parameters[$constructor->class] = $constructor->getParameters();
120
+		}
121
+		return $this->parameters[$constructor->class];
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * resolveDependencies
128
+	 * examines the constructor for the requested class to determine
129
+	 * if any dependencies exist, and if they can be injected.
130
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
131
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
132
+	 * For example:
133
+	 *        if attempting to load a class "Foo" with the following constructor:
134
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
135
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
136
+	 *        but only IF they are NOT already present in the incoming arguments array,
137
+	 *        and the correct classes can be loaded
138
+	 *
139
+	 * @param RecipeInterface   $recipe
140
+	 * @param \ReflectionClass  $reflector
141
+	 * @param array             $arguments
142
+	 * @return array
143
+	 */
144
+	public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array())
145
+	{
146
+		// if arguments array is numerically and sequentially indexed, then we want it to remain as is,
147
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
148
+		$arguments = $this->array_helper->is_array_numerically_and_sequentially_indexed($arguments)
149
+			? $arguments
150
+			: array($arguments);
151
+		$resolved_parameters = array();
152
+		// let's examine the constructor
153
+		// let's examine the constructor
154
+		$constructor = $this->getConstructor($reflector);
155
+		// whu? huh? nothing?
156
+		if ( ! $constructor) {
157
+			return $arguments;
158
+		}
159
+		// get constructor parameters
160
+		$params = $this->getParameters($constructor);
161
+		if (empty($params)) {
162
+			return $resolved_parameters;
163
+		}
164
+		$ingredients = $recipe->ingredients();
165
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
166
+		$argument_keys = array_keys($arguments);
167
+		// now loop thru all of the constructors expected parameters
168
+		foreach ($params as $index => $param) {
169
+			if ( ! $param instanceof \ReflectionParameter) {
170
+				continue;
171
+			}
172
+			// is this a dependency for a specific class ?
173
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
174
+			if (
175
+				// param is specified in the list of ingredients for this Recipe
176
+				isset($ingredients[$param_class])
177
+			) {
178
+				// attempt to inject the dependency
179
+				$resolved_parameters[$index] = $this->injectDependency($ingredients[$param_class]);
180
+			} else if (
181
+				// param is not even a class
182
+				empty($param_class)
183
+				// and something already exists in the incoming arguments for this param
184
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
185
+			) {
186
+				// add parameter from incoming arguments
187
+				$resolved_parameters[$index] = $arguments[$argument_keys[$index]];
188
+			} else if (
189
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
190
+				! empty($param_class)
191
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
192
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
193
+			) {
194
+				// add parameter from incoming arguments
195
+				$resolved_parameters[$index] = $arguments[$argument_keys[$index]];
196
+			} else if (
197
+				// parameter is type hinted as a class, and should be injected
198
+			! empty($param_class)
199
+			) {
200
+				// attempt to inject the dependency
201
+				$resolved_parameters[$index] = $this->injectDependency($param_class);
202
+			} else if ($param->isOptional()) {
203
+				$resolved_parameters[$index] = $param->getDefaultValue();
204
+			} else {
205
+				$resolved_parameters[$index] = null;
206
+			}
207
+		}
208
+		return $resolved_parameters;
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 * @param string $param_class
215
+	 * @return mixed
216
+	 */
217
+	private function injectDependency($param_class)
218
+	{
219
+		$dependency = $this->coffee_pot->brew($param_class);
220
+		if ( ! $dependency instanceof $param_class) {
221
+			throw new UnexpectedValueException(
222
+				sprintf(
223
+					__(
224
+						'Could not resolve dependency for "%1$s" for the "%2$s" class constructor.',
225
+						'event_espresso'
226
+					),
227
+					$param_class
228
+				)
229
+			);
230
+		}
231
+		return $dependency;
232
+	}
233 233
 
234 234
 }
235 235
 // End of file DependencyInjector.php
Please login to merge, or discard this patch.
core/services/container/InjectorInterface.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,39 +17,39 @@  discard block
 block discarded – undo
17 17
 interface InjectorInterface
18 18
 {
19 19
 
20
-    /**
21
-     * getReflectionClass
22
-     * checks if a ReflectionClass object has already been generated for a class
23
-     * and returns that instead of creating a new one
24
-     *
25
-     * @access public
26
-     * @param string $class_name
27
-     * @return \ReflectionClass
28
-     */
29
-    public function getReflectionClass($class_name);
30
-
31
-
32
-
33
-    /**
34
-     * resolveDependencies
35
-     * examines the constructor for the requested class to determine
36
-     * if any dependencies exist, and if they can be injected.
37
-     * If so, then those classes will be added to the array of arguments passed to the constructor
38
-     * PLZ NOTE: this is achieved by type hinting the constructor params
39
-     * For example:
40
-     *        if attempting to load a class "Foo" with the following constructor:
41
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
42
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
43
-     *        but only IF they are NOT already present in the incoming arguments array,
44
-     *        and the correct classes can be loaded
45
-     *
46
-     * @access public
47
-     * @param \EventEspresso\core\services\container\RecipeInterface $recipe
48
-     * @param \ReflectionClass                                       $reflector
49
-     * @param array                                                  $arguments
50
-     * @return array
51
-     */
52
-    public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array());
20
+	/**
21
+	 * getReflectionClass
22
+	 * checks if a ReflectionClass object has already been generated for a class
23
+	 * and returns that instead of creating a new one
24
+	 *
25
+	 * @access public
26
+	 * @param string $class_name
27
+	 * @return \ReflectionClass
28
+	 */
29
+	public function getReflectionClass($class_name);
30
+
31
+
32
+
33
+	/**
34
+	 * resolveDependencies
35
+	 * examines the constructor for the requested class to determine
36
+	 * if any dependencies exist, and if they can be injected.
37
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
38
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
39
+	 * For example:
40
+	 *        if attempting to load a class "Foo" with the following constructor:
41
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
42
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
43
+	 *        but only IF they are NOT already present in the incoming arguments array,
44
+	 *        and the correct classes can be loaded
45
+	 *
46
+	 * @access public
47
+	 * @param \EventEspresso\core\services\container\RecipeInterface $recipe
48
+	 * @param \ReflectionClass                                       $reflector
49
+	 * @param array                                                  $arguments
50
+	 * @return array
51
+	 */
52
+	public function resolveDependencies(RecipeInterface $recipe, \ReflectionClass $reflector, $arguments = array());
53 53
 
54 54
 }
55 55
 // End of file InjectorInterface.php
Please login to merge, or discard this patch.
core/services/container/SharedCoffeeMaker.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -24,46 +24,46 @@  discard block
 block discarded – undo
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @return string
29
-     */
30
-    public function type()
31
-    {
32
-        return CoffeeMaker::BREW_SHARED;
33
-    }
27
+	/**
28
+	 * @return string
29
+	 */
30
+	public function type()
31
+	{
32
+		return CoffeeMaker::BREW_SHARED;
33
+	}
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * @param RecipeInterface $recipe
39
-     * @param array           $arguments
40
-     * @return mixed
41
-     */
42
-    public function brew(RecipeInterface $recipe, $arguments = array())
43
-    {
44
-        $this->resolveClassAndFilepath($recipe);
45
-        $reflector = $this->injector()->getReflectionClass($recipe->fqcn());
46
-        $method = $this->resolveInstantiationMethod($reflector);
47
-        switch ($method) {
48
-            case 'instance' :
49
-            case 'new_instance' :
50
-            case 'new_instance_from_db';
51
-                $service = call_user_func_array(
52
-                    array($reflector->getName(), $method),
53
-                    $this->injector()->resolveDependencies($recipe, $reflector, $arguments)
54
-                );
55
-                break;
56
-            case 'newInstance' :
57
-                $service = $reflector->newInstance();
58
-                break;
59
-            case 'newInstanceArgs' :
60
-            default :
61
-                $service = $reflector->newInstanceArgs(
62
-                    $this->injector()->resolveDependencies($recipe, $reflector, $arguments)
63
-                );
64
-        }
65
-        return $this->coffeePot()->addService($recipe->identifier(), $service);
66
-    }
37
+	/**
38
+	 * @param RecipeInterface $recipe
39
+	 * @param array           $arguments
40
+	 * @return mixed
41
+	 */
42
+	public function brew(RecipeInterface $recipe, $arguments = array())
43
+	{
44
+		$this->resolveClassAndFilepath($recipe);
45
+		$reflector = $this->injector()->getReflectionClass($recipe->fqcn());
46
+		$method = $this->resolveInstantiationMethod($reflector);
47
+		switch ($method) {
48
+			case 'instance' :
49
+			case 'new_instance' :
50
+			case 'new_instance_from_db';
51
+				$service = call_user_func_array(
52
+					array($reflector->getName(), $method),
53
+					$this->injector()->resolveDependencies($recipe, $reflector, $arguments)
54
+				);
55
+				break;
56
+			case 'newInstance' :
57
+				$service = $reflector->newInstance();
58
+				break;
59
+			case 'newInstanceArgs' :
60
+			default :
61
+				$service = $reflector->newInstanceArgs(
62
+					$this->injector()->resolveDependencies($recipe, $reflector, $arguments)
63
+				);
64
+		}
65
+		return $this->coffeePot()->addService($recipe->identifier(), $service);
66
+	}
67 67
 
68 68
 }
69 69
 // End of file SharedCoffeeMaker.php
Please login to merge, or discard this patch.
core/services/container/NewCoffeeMaker.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -25,54 +25,54 @@  discard block
 block discarded – undo
25 25
 {
26 26
 
27 27
 
28
-    /**
29
-     * @return string
30
-     */
31
-    public function type()
32
-    {
33
-        return CoffeeMaker::BREW_NEW;
34
-    }
28
+	/**
29
+	 * @return string
30
+	 */
31
+	public function type()
32
+	{
33
+		return CoffeeMaker::BREW_NEW;
34
+	}
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * @param RecipeInterface $recipe
40
-     * @param array           $arguments
41
-     * @return mixed
42
-     */
43
-    public function brew(RecipeInterface $recipe, $arguments = array())
44
-    {
45
-        $this->resolveClassAndFilepath($recipe);
46
-        $reflector = $this->injector()->getReflectionClass($recipe->fqcn());
47
-        $method = $this->resolveInstantiationMethod($reflector);
48
-        switch ($method) {
49
-            case 'instance' :
50
-            case 'new_instance' :
51
-            case 'new_instance_from_db';
52
-                $injector = $this->injector();
53
-                $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
54
-                    return call_user_func_array(
55
-                        array($reflector->getName(), $method),
56
-                        $injector->resolveDependencies($recipe, $reflector, $arguments)
57
-                    );
58
-                };
59
-                break;
60
-            case 'newInstance' :
61
-                $closure = function () use ($reflector) {
62
-                    return $reflector->newInstance();
63
-                };
64
-                break;
65
-            case 'newInstanceArgs' :
66
-            default :
67
-                $injector = $this->injector();
68
-                $closure = function ($arguments) use ($recipe, $reflector, $injector) {
69
-                    return $reflector->newInstanceArgs(
70
-                        $injector->resolveDependencies($recipe, $reflector, $arguments)
71
-                    );
72
-                };
73
-        }
74
-        return $this->coffeePot()->addClosure($recipe->identifier(), $closure);
75
-    }
38
+	/**
39
+	 * @param RecipeInterface $recipe
40
+	 * @param array           $arguments
41
+	 * @return mixed
42
+	 */
43
+	public function brew(RecipeInterface $recipe, $arguments = array())
44
+	{
45
+		$this->resolveClassAndFilepath($recipe);
46
+		$reflector = $this->injector()->getReflectionClass($recipe->fqcn());
47
+		$method = $this->resolveInstantiationMethod($reflector);
48
+		switch ($method) {
49
+			case 'instance' :
50
+			case 'new_instance' :
51
+			case 'new_instance_from_db';
52
+				$injector = $this->injector();
53
+				$closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
54
+					return call_user_func_array(
55
+						array($reflector->getName(), $method),
56
+						$injector->resolveDependencies($recipe, $reflector, $arguments)
57
+					);
58
+				};
59
+				break;
60
+			case 'newInstance' :
61
+				$closure = function () use ($reflector) {
62
+					return $reflector->newInstance();
63
+				};
64
+				break;
65
+			case 'newInstanceArgs' :
66
+			default :
67
+				$injector = $this->injector();
68
+				$closure = function ($arguments) use ($recipe, $reflector, $injector) {
69
+					return $reflector->newInstanceArgs(
70
+						$injector->resolveDependencies($recipe, $reflector, $arguments)
71
+					);
72
+				};
73
+		}
74
+		return $this->coffeePot()->addClosure($recipe->identifier(), $closure);
75
+	}
76 76
 
77 77
 
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             case 'new_instance' :
51 51
             case 'new_instance_from_db';
52 52
                 $injector = $this->injector();
53
-                $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
53
+                $closure = function($arguments) use ($recipe, $reflector, $method, $injector) {
54 54
                     return call_user_func_array(
55 55
                         array($reflector->getName(), $method),
56 56
                         $injector->resolveDependencies($recipe, $reflector, $arguments)
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
                 };
59 59
                 break;
60 60
             case 'newInstance' :
61
-                $closure = function () use ($reflector) {
61
+                $closure = function() use ($reflector) {
62 62
                     return $reflector->newInstance();
63 63
                 };
64 64
                 break;
65 65
             case 'newInstanceArgs' :
66 66
             default :
67 67
                 $injector = $this->injector();
68
-                $closure = function ($arguments) use ($recipe, $reflector, $injector) {
68
+                $closure = function($arguments) use ($recipe, $reflector, $injector) {
69 69
                     return $reflector->newInstanceArgs(
70 70
                         $injector->resolveDependencies($recipe, $reflector, $arguments)
71 71
                     );
Please login to merge, or discard this patch.
core/services/container/RecipeInterface.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,84 +17,84 @@  discard block
 block discarded – undo
17 17
 interface RecipeInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @return string
22
-     */
23
-    public function identifier();
24
-
25
-    /**
26
-     * @return string
27
-     */
28
-    public function fqcn();
29
-
30
-    /**
31
-     * @return array
32
-     */
33
-    public function ingredients();
34
-
35
-    /**
36
-     * @return string
37
-     */
38
-    public function type();
39
-
40
-    /**
41
-     * @return array
42
-     */
43
-    public function filters();
44
-
45
-    /**
46
-     * @return array
47
-     */
48
-    public function paths();
49
-
50
-    /**
51
-     * @param  string $identifier Identifier for the entity class that the Recipe applies to
52
-     *                            Typically a Fully Qualified Class Name
53
-     */
54
-    public function setIdentifier($identifier);
55
-
56
-    /**
57
-     * Ensures incoming string is a valid Fully Qualified Class Name,
58
-     * except if this is the default wildcard Recipe ( * ),
59
-     * or it's NOT an actual FQCN because the Recipe is using filepaths
60
-     * for classes that are not PSR-4 compatible
61
-     * PLZ NOTE:
62
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
63
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
64
-     *
65
-     * @param string $fqcn
66
-     */
67
-    public function setFqcn($fqcn);
68
-
69
-    /**
70
-     * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
71
-     *                              example:
72
-     *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
73
-     */
74
-    public function setIngredients(array $ingredients);
75
-
76
-    /**
77
-     * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
78
-     */
79
-    public function setType($type = CoffeeMaker::BREW_NEW);
80
-
81
-    /**
82
-     * @param array $filters    an array of filters where keys are the aliases and values are the FQCNs
83
-     *                          example:
84
-     *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
85
-     */
86
-    public function setFilters(array $filters);
87
-
88
-    /**
89
-     * Ensures incoming paths is a valid filepath, or array of valid filepaths,
90
-     * and merges them in with any existing filepaths
91
-     * PLZ NOTE:
92
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
93
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
94
-     *
95
-     * @param string|array $paths
96
-     */
97
-    public function setPaths($paths = array());
20
+	/**
21
+	 * @return string
22
+	 */
23
+	public function identifier();
24
+
25
+	/**
26
+	 * @return string
27
+	 */
28
+	public function fqcn();
29
+
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function ingredients();
34
+
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function type();
39
+
40
+	/**
41
+	 * @return array
42
+	 */
43
+	public function filters();
44
+
45
+	/**
46
+	 * @return array
47
+	 */
48
+	public function paths();
49
+
50
+	/**
51
+	 * @param  string $identifier Identifier for the entity class that the Recipe applies to
52
+	 *                            Typically a Fully Qualified Class Name
53
+	 */
54
+	public function setIdentifier($identifier);
55
+
56
+	/**
57
+	 * Ensures incoming string is a valid Fully Qualified Class Name,
58
+	 * except if this is the default wildcard Recipe ( * ),
59
+	 * or it's NOT an actual FQCN because the Recipe is using filepaths
60
+	 * for classes that are not PSR-4 compatible
61
+	 * PLZ NOTE:
62
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
63
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
64
+	 *
65
+	 * @param string $fqcn
66
+	 */
67
+	public function setFqcn($fqcn);
68
+
69
+	/**
70
+	 * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
71
+	 *                              example:
72
+	 *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
73
+	 */
74
+	public function setIngredients(array $ingredients);
75
+
76
+	/**
77
+	 * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
78
+	 */
79
+	public function setType($type = CoffeeMaker::BREW_NEW);
80
+
81
+	/**
82
+	 * @param array $filters    an array of filters where keys are the aliases and values are the FQCNs
83
+	 *                          example:
84
+	 *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
85
+	 */
86
+	public function setFilters(array $filters);
87
+
88
+	/**
89
+	 * Ensures incoming paths is a valid filepath, or array of valid filepaths,
90
+	 * and merges them in with any existing filepaths
91
+	 * PLZ NOTE:
92
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
93
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
94
+	 *
95
+	 * @param string|array $paths
96
+	 */
97
+	public function setPaths($paths = array());
98 98
 
99 99
 }
100 100
 // End of file RecipeInterface.php
Please login to merge, or discard this patch.
core/EE_Network_Config.core.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function instance() {
60 60
 		// check if class object is instantiated, and instantiated properly
61
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) {
61
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) {
62 62
 			self::$_instance = new self();
63 63
 		}
64 64
 		return self::$_instance;
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
 	 *  @access 	private
74 74
 	 */
75 75
 	private function __construct() {
76
-		do_action( 'AHEE__EE_Network_Config__construct__begin',$this );
76
+		do_action('AHEE__EE_Network_Config__construct__begin', $this);
77 77
 		//set defaults
78
-		$this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() );
78
+		$this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config());
79 79
 		$this->addons = array();
80 80
 
81 81
 		$this->_load_config();
82 82
 
83 83
 		// construct__end hook
84
-		do_action( 'AHEE__EE_Network_Config__construct__end',$this );
84
+		do_action('AHEE__EE_Network_Config__construct__end', $this);
85 85
 	}
86 86
 
87 87
 
@@ -94,25 +94,25 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	private function _load_config() {
96 96
 		//load network config start hook
97
-		do_action( 'AHEE__EE_Network_Config___load_config__start', $this );
97
+		do_action('AHEE__EE_Network_Config___load_config__start', $this);
98 98
 		$config = $this->get_config();
99
-		foreach ( $config as $config_prop => $settings ) {
100
-			if ( is_object( $settings ) && property_exists( $this, $config_prop ) ) {
101
-				$this->{$config_prop} = apply_filters( 'FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this );
102
-				if ( method_exists( $settings, 'populate' ) ) {
99
+		foreach ($config as $config_prop => $settings) {
100
+			if (is_object($settings) && property_exists($this, $config_prop)) {
101
+				$this->{$config_prop} = apply_filters('FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this);
102
+				if (method_exists($settings, 'populate')) {
103 103
 					$this->{$config_prop}->populate();
104 104
 				}
105
-				if ( method_exists( $settings, 'do_hooks' ) ) {
105
+				if (method_exists($settings, 'do_hooks')) {
106 106
 					$this->{$config_prop}->do_hooks();
107 107
 				}
108 108
 			}
109 109
 		}
110
-		if ( apply_filters( 'FHEE__EE_Network_Config___load_config__update_network_config', false ) ) {
110
+		if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) {
111 111
 			$this->update_config();
112 112
 		}
113 113
 
114 114
 		//load network config end hook
115
-		do_action( 'AHEE__EE_Network_Config___load_config__end', $this );
115
+		do_action('AHEE__EE_Network_Config___load_config__end', $this);
116 116
 	}
117 117
 
118 118
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function get_config() {
128 128
 		// grab network configuration
129
-		$CFG = get_site_option( 'ee_network_config', array() );
130
-		$CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG );
129
+		$CFG = get_site_option('ee_network_config', array());
130
+		$CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG);
131 131
 		return $CFG;
132 132
 	}
133 133
 
@@ -141,39 +141,39 @@  discard block
 block discarded – undo
141 141
 	 * @param bool $add_error
142 142
 	 * @return bool success
143 143
 	 */
144
-	public function update_config( $add_success = FALSE, $add_error = TRUE ) {
145
-		do_action( 'AHEE__EE_Network_Config__update_config__begin',$this );
144
+	public function update_config($add_success = FALSE, $add_error = TRUE) {
145
+		do_action('AHEE__EE_Network_Config__update_config__begin', $this);
146 146
 
147 147
 		//need to bust cache for comparing original if this is a multisite install
148
-		if ( is_multisite() ) {
148
+		if (is_multisite()) {
149 149
 			global $current_site;
150
-			$cache_key = $current_site->id . ':ee_network_config';
151
-			wp_cache_delete( $cache_key, 'site-options' );
150
+			$cache_key = $current_site->id.':ee_network_config';
151
+			wp_cache_delete($cache_key, 'site-options');
152 152
 		}
153 153
 
154 154
 		//we have to compare existing saved config with config in memory because if there is no difference that means
155 155
 		//that the method executed fine but there just was no update.  WordPress doesn't distinguish between false because
156 156
 		//there were 0 records updated because of no change vs false because some error produced problems with the update.
157
-		$original = get_site_option( 'ee_network_config' );
157
+		$original = get_site_option('ee_network_config');
158 158
 
159
-		if ( $original == $this ) {
159
+		if ($original == $this) {
160 160
 			return true;
161 161
 		}
162 162
 		// update
163
-		$saved = update_site_option( 'ee_network_config', $this );
163
+		$saved = update_site_option('ee_network_config', $this);
164 164
 
165
-		do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved );
165
+		do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
166 166
 		// if config remains the same or was updated successfully
167
-		if ( $saved ) {
168
-			if ( $add_success ) {
169
-				$msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' );
170
-				EE_Error::add_success( $msg );
167
+		if ($saved) {
168
+			if ($add_success) {
169
+				$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
170
+				EE_Error::add_success($msg);
171 171
 			}
172 172
 			return true;
173 173
 		} else {
174
-			if ( $add_error ) {
175
-				$msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' );
176
-				EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ );
174
+			if ($add_error) {
175
+				$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
176
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
177 177
 			}
178 178
 			return false;
179 179
 		}
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	 *  @return 	array
188 188
 	 */
189 189
 	public function __sleep() {
190
-		return apply_filters( 'FHEE__EE_Network_Config__sleep',array(
190
+		return apply_filters('FHEE__EE_Network_Config__sleep', array(
191 191
 			'core',
192
-		) );
192
+		));
193 193
 	}
194 194
 
195 195
 } //end EE_Network_Config.
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/domain/services/capabilities/PublicCapabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function capability()
27
-    {
28
-        return '';
29
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function capability()
27
+	{
28
+		return '';
29
+	}
30 30
 
31 31
 
32 32
 }
Please login to merge, or discard this patch.