Completed
Branch FET-9795-new-interfaces (ea072c)
by
unknown
51:56 queued 35:16
created
core/services/container/OpenCoffeeShop.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * OpenCoffeeShop constructor.
34 34
 	 */
35 35
 	public function __construct()
36
-    {
36
+	{
37 37
 		// instantiate the container
38 38
 		$this->CoffeeShop = new CoffeeShop();
39 39
 		// create a dependency injector class for resolving class constructor arguments
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 			new Recipe(
84 84
 				'CommandHandlerManager',
85 85
 				'EventEspresso\core\services\commands\CommandHandlerManager',
86
-                array(
87
-                    'CommandHandlerManagerInterface',
88
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
89
-                ),
90
-                array(),
86
+				array(
87
+					'CommandHandlerManagerInterface',
88
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
89
+				),
90
+				array(),
91 91
 				CoffeeMaker::BREW_SHARED
92 92
 			)
93 93
 		);
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 			new Recipe(
97 97
 				'CommandBus',
98 98
 				'EventEspresso\core\services\commands\CommandBus',
99
-                array(
100
-                    'CommandBusInterface',
101
-                    'EventEspresso\core\services\commands\CommandBusInterface',
102
-                ),
103
-                array(),
99
+				array(
100
+					'CommandBusInterface',
101
+					'EventEspresso\core\services\commands\CommandBusInterface',
102
+				),
103
+				array(),
104 104
 				CoffeeMaker::BREW_SHARED
105 105
 			)
106 106
 		);
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 			new Recipe(
111 111
 				'EEI_*',
112 112
 				'',
113
-                array(),
114
-                array(),
113
+				array(),
114
+				array(),
115 115
 				CoffeeMaker::BREW_LOAD_ONLY,
116
-                array(
117
-                    EE_INTERFACES . '*.php',
118
-                    EE_INTERFACES . '*.interfaces.php',
119
-                )
116
+				array(
117
+					EE_INTERFACES . '*.php',
118
+					EE_INTERFACES . '*.interfaces.php',
119
+				)
120 120
 			)
121 121
 		);
122 122
 		// add a wildcard recipe for loading models
123 123
 		$this->CoffeeShop->addRecipe(
124 124
 			new Recipe(
125 125
 				'EEM_*',
126
-                '',
127
-                array(),
128
-                array(),
126
+				'',
127
+				array(),
128
+				array(),
129 129
 				CoffeeMaker::BREW_SHARED,
130 130
 				EE_MODELS . '*.model.php'
131 131
 			)
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 		$this->CoffeeShop->addRecipe(
135 135
 			new Recipe(
136 136
 				'EE_*',
137
-                '',
138
-                array(),
139
-                array(),
140
-                CoffeeMaker::BREW_SHARED,
137
+				'',
138
+				array(),
139
+				array(),
140
+				CoffeeMaker::BREW_SHARED,
141 141
 				array(
142 142
 					EE_CORE . '*.core.php',
143 143
 					EE_ADMIN . '*.core.php',
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 		$this->CoffeeShop->addRecipe(
153 153
 			new Recipe(
154 154
 				'EE_Admin_Page*',
155
-                '',
156
-                array(),
157
-                array(),
158
-                CoffeeMaker::BREW_LOAD_ONLY,
155
+				'',
156
+				array(),
157
+				array(),
158
+				CoffeeMaker::BREW_LOAD_ONLY,
159 159
 				array( EE_ADMIN . '*.core.php' )
160 160
 			)
161 161
 		);
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		// $this->CoffeeShop->addRecipe(
164 164
 		// 	new Recipe(
165 165
 		// 		'*_Admin_Page',
166
-        //      '',
167
-        //      array(),
168
-        // 		array(),
169
-        // 		CoffeeMaker::BREW_SHARED,
166
+		//      '',
167
+		//      array(),
168
+		// 		array(),
169
+		// 		CoffeeMaker::BREW_SHARED,
170 170
 		// 		array(
171 171
 		// 			EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php',
172 172
 		// 		)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\container;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 		);
44 44
 		// and some coffeemakers, one for creating new instances
45 45
 		$this->CoffeeShop->addCoffeeMaker(
46
-			new NewCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
46
+			new NewCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
47 47
 			CoffeeMaker::BREW_NEW
48 48
 		);
49 49
 		// one for shared services
50 50
 		$this->CoffeeShop->addCoffeeMaker(
51
-			new SharedCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
51
+			new SharedCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
52 52
 			CoffeeMaker::BREW_SHARED
53 53
 		);
54 54
 		// and one for classes that only get loaded
55 55
 		$this->CoffeeShop->addCoffeeMaker(
56
-			new LoadOnlyCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ),
56
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $this->DependencyInjector),
57 57
 			CoffeeMaker::BREW_LOAD_ONLY
58 58
 		);
59 59
 		// add default recipe, which should handle loading for most PSR-4 compatible classes
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
                 array(),
115 115
 				CoffeeMaker::BREW_LOAD_ONLY,
116 116
                 array(
117
-                    EE_INTERFACES . '*.php',
118
-                    EE_INTERFACES . '*.interfaces.php',
117
+                    EE_INTERFACES.'*.php',
118
+                    EE_INTERFACES.'*.interfaces.php',
119 119
                 )
120 120
 			)
121 121
 		);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 array(),
128 128
                 array(),
129 129
 				CoffeeMaker::BREW_SHARED,
130
-				EE_MODELS . '*.model.php'
130
+				EE_MODELS.'*.model.php'
131 131
 			)
132 132
 		);
133 133
 		// add a wildcard recipe for loading core classes
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
                 array(),
140 140
                 CoffeeMaker::BREW_SHARED,
141 141
 				array(
142
-					EE_CORE . '*.core.php',
143
-					EE_ADMIN . '*.core.php',
144
-					EE_CPTS . '*.core.php',
145
-					EE_CORE . 'data_migration_scripts' . DS . '*.core.php',
146
-					EE_CORE . 'request_stack' . DS . '*.core.php',
147
-					EE_CORE . 'middleware' . DS . '*.core.php',
142
+					EE_CORE.'*.core.php',
143
+					EE_ADMIN.'*.core.php',
144
+					EE_CPTS.'*.core.php',
145
+					EE_CORE.'data_migration_scripts'.DS.'*.core.php',
146
+					EE_CORE.'request_stack'.DS.'*.core.php',
147
+					EE_CORE.'middleware'.DS.'*.core.php',
148 148
 				)
149 149
 			)
150 150
 		);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 array(),
157 157
                 array(),
158 158
                 CoffeeMaker::BREW_LOAD_ONLY,
159
-				array( EE_ADMIN . '*.core.php' )
159
+				array(EE_ADMIN.'*.core.php')
160 160
 			)
161 161
 		);
162 162
 		// add a wildcard recipe for loading core classes
Please login to merge, or discard this patch.
core/services/container/Recipe.php 2 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use RuntimeException;
8 8
 
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -23,313 +23,313 @@  discard block
 block discarded – undo
23 23
 class Recipe implements RecipeInterface
24 24
 {
25 25
 
26
-    /**
27
-     * A default Recipe to use if none is specified for a class
28
-     */
29
-    const DEFAULT_ID = '*';
30
-
31
-    /**
32
-     * Identifier for the entity class to be constructed.
33
-     * Typically a Fully Qualified Class Name
34
-     *
35
-     * @var string $identifier
36
-     */
37
-    private $identifier;
38
-
39
-    /**
40
-     * Fully Qualified Class Name
41
-     *
42
-     * @var string $fqcn
43
-     */
44
-    private $fqcn;
45
-
46
-    /**
47
-     * a dependency class map array
48
-     * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
49
-     * and that class type hints for an interface, then this property allows you to configure what dependencies
50
-     * get used when instantiating the class.
51
-     * For example:
52
-     *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
53
-     *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
54
-     *  We want one Coffee object to use HonduranBean for its BeanInterface,
55
-     *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
56
-     *  To do this, we need to create two Recipes:
57
-     *      one with an identifier of 'HonduranCoffee' using the following ingredients :
58
-     *          array('BeanInterface' => 'HonduranBean')
59
-     *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
60
-     *          array('BeanInterface' => 'KenyanBean')
61
-     *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
62
-     *  an instance of HonduranBean will get injected for the BeanInterface dependency,
63
-     *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
64
-     *  an instance of KenyanBean will get injected for the BeanInterface dependency
65
-     *
66
-     * @var array $ingredients
67
-     */
68
-    private $ingredients = array();
69
-
70
-    /**
71
-     * one of the class constants from CoffeeShop:
72
-     *  CoffeeMaker::BREW_NEW - creates a new instance
73
-     *  CoffeeMaker::BREW_SHARED - creates a shared instance
74
-     *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
75
-     *
76
-     * @var string $type
77
-     */
78
-    private $type;
79
-
80
-    /**
81
-     * class name aliases - typically a Fully Qualified Interface that the class implements
82
-     * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
83
-     *
84
-     * @var array $filters
85
-     */
86
-    private $filters = array();
87
-
88
-    /**
89
-     * array of full server filepaths to files that may contain the class
90
-     *
91
-     * @var array $paths
92
-     */
93
-    private $paths = array();
94
-
95
-
96
-
97
-    /**
98
-     * Recipe constructor.
99
-     *
100
-     * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
101
-     * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
102
-     * @param array  $ingredients   array of dependencies that can not be resolved automatically,
103
-     *                              used for resolving concrete classes for type hinted interfaces
104
-     *                              for the dependencies of THIS class
105
-     * @param string $type          recipe type: one of the class constants on
106
-     *                              \EventEspresso\core\services\container\CoffeeMaker
107
-     * @param array  $filters       array of class aliases, or class interfaces
108
-     *                              this works somewhat opposite to the $ingredients array above,
109
-     *                              in that this array specifies interfaces or aliases
110
-     *                              that this Recipe can be used for when resolving OTHER class's dependencies
111
-     * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
112
-     *                              then supply a filepath, or array of filepaths, so that it can be included
113
-     */
114
-    public function __construct(
115
-	    $identifier,
116
-        $fqcn = '',
117
-        $filters = array(),
118
-        $ingredients = array(),
119
-	    $type = CoffeeMaker::BREW_NEW,
120
-	    $paths = array()
121
-    )
122
-    {
123
-        $this->setIdentifier($identifier);
124
-        $this->setFilters((array)$filters);
125
-        $this->setIngredients((array)$ingredients);
126
-        $this->setType($type);
127
-        $this->setPaths($paths);
128
-        $this->setFqcn($fqcn);
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public function identifier()
137
-    {
138
-        return $this->identifier;
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * @return string
145
-     */
146
-    public function fqcn()
147
-    {
148
-        return $this->fqcn;
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * @return array
155
-     */
156
-    public function filters()
157
-    {
158
-        return (array)$this->filters;
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * @return array
165
-     */
166
-    public function ingredients()
167
-    {
168
-        return $this->ingredients;
169
-    }
170
-
171
-
172
-
173
-    /**
174
-     * @return string
175
-     */
176
-    public function type()
177
-    {
178
-        return $this->type;
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @return array
185
-     */
186
-    public function paths()
187
-    {
188
-        return (array)$this->paths;
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * @param  string $identifier Identifier for the entity class that the Recipe applies to
195
-     *                            Typically a Fully Qualified Class Name
196
-     */
197
-    public function setIdentifier($identifier)
198
-    {
199
-        if ( ! is_string($identifier) || empty($identifier)) {
200
-            throw new InvalidIdentifierException(
201
-                is_object($identifier) ? get_class($identifier) : gettype($identifier),
202
-                __('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
203
-            );
204
-        }
205
-        $this->identifier = $identifier;
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * Ensures incoming string is a valid Fully Qualified Class Name,
212
-     * except if this is the default wildcard Recipe ( * ),
213
-     * or it's NOT an actual FQCN because the Recipe is using filepaths
214
-     * for classes that are not PSR-4 compatible
215
-     * PLZ NOTE:
216
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
217
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
218
-     *
219
-     * @param string $fqcn
220
-     */
221
-    public function setFqcn($fqcn)
222
-    {
223
-	    $fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
224
-        if ( ! is_string($fqcn)) {
225
-            throw new InvalidDataTypeException(
226
-                '$fqcn',
227
-                is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
228
-                __('string (Fully\Qualified\ClassName)', 'event_espresso')
229
-            );
230
-        }
231
-        $fqcn = ltrim($fqcn, '\\');
232
-        if (
233
-            $fqcn !== Recipe::DEFAULT_ID
234
-            && ! empty($fqcn)
235
-            && empty($this->paths)
236
-            && ! class_exists($fqcn)
237
-        ) {
238
-            throw new InvalidClassException($fqcn);
239
-        }
240
-        $this->fqcn = $fqcn;
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
247
-     *                              example:
248
-     *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
249
-     */
250
-    public function setIngredients(array $ingredients)
251
-    {
252
-        if (empty($ingredients)) {
253
-            return;
254
-        }
255
-        if ( ! is_array($ingredients)) {
256
-            throw new InvalidDataTypeException(
257
-                '$ingredients',
258
-                is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
259
-                __('array of class dependencies', 'event_espresso')
260
-            );
261
-        }
262
-        $this->ingredients = array_merge($this->ingredients, $ingredients);
263
-    }
264
-
265
-
266
-    /**
267
-     * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
268
-     */
269
-    public function setType($type = CoffeeMaker::BREW_NEW)
270
-    {
271
-        $this->type = CoffeeMaker::validateType($type);
272
-    }
273
-
274
-
275
-
276
-    /**
277
-     * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
278
-     *                          example:
279
-     *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
280
-     */
281
-    public function setFilters(array $filters)
282
-    {
283
-        if (empty($filters)) {
284
-            return;
285
-        }
286
-        if ( ! is_array($filters)) {
287
-            throw new InvalidDataTypeException(
288
-                '$filters',
289
-                is_object($filters) ? get_class($filters) : gettype($filters),
290
-                __('array of class aliases', 'event_espresso')
291
-            );
292
-        }
293
-        $this->filters = array_merge($this->filters, $filters);
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * Ensures incoming paths is a valid filepath, or array of valid filepaths,
300
-     * and merges them in with any existing filepaths
301
-     *
302
-     * PLZ NOTE:
303
-     *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
304
-     *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
305
-     *
306
-     * @param string|array $paths
307
-     */
308
-    public function setPaths($paths = array())
309
-    {
310
-        if (empty($paths)) {
311
-            return;
312
-        }
313
-        if ( ! (is_string($paths) || is_array($paths))) {
314
-            throw new InvalidDataTypeException(
315
-                '$path',
316
-                is_object($paths) ? get_class($paths) : gettype($paths),
317
-                __('string or array of strings (full server filepath(s))', 'event_espresso')
318
-            );
319
-        }
320
-        $paths = (array)$paths;
321
-        foreach ($paths as $path) {
322
-            if (strpos($path, '*') === false && ! is_readable($path)) {
323
-                throw new RuntimeException(
324
-                    sprintf(
325
-                        __('The following filepath is not readable: "%1$s"', 'event_espresso'),
326
-                        $path
327
-                    )
328
-                );
329
-            }
330
-        }
331
-        $this->paths = array_merge($this->paths, $paths);
332
-    }
26
+	/**
27
+	 * A default Recipe to use if none is specified for a class
28
+	 */
29
+	const DEFAULT_ID = '*';
30
+
31
+	/**
32
+	 * Identifier for the entity class to be constructed.
33
+	 * Typically a Fully Qualified Class Name
34
+	 *
35
+	 * @var string $identifier
36
+	 */
37
+	private $identifier;
38
+
39
+	/**
40
+	 * Fully Qualified Class Name
41
+	 *
42
+	 * @var string $fqcn
43
+	 */
44
+	private $fqcn;
45
+
46
+	/**
47
+	 * a dependency class map array
48
+	 * If a Recipe is for a single class (or group of classes that shares the EXACT SAME constructor arguments),
49
+	 * and that class type hints for an interface, then this property allows you to configure what dependencies
50
+	 * get used when instantiating the class.
51
+	 * For example:
52
+	 *  There's a class called Coffee, and one of its constructor arguments is BeanInterface
53
+	 *  There are two implementations of BeanInterface: HonduranBean, and KenyanBean
54
+	 *  We want one Coffee object to use HonduranBean for its BeanInterface,
55
+	 *  and the 2nd Coffee object to use KenyanBean for its BeanInterface.
56
+	 *  To do this, we need to create two Recipes:
57
+	 *      one with an identifier of 'HonduranCoffee' using the following ingredients :
58
+	 *          array('BeanInterface' => 'HonduranBean')
59
+	 *      and the other with an identifier of 'KenyanCoffee' using the following ingredients :
60
+	 *          array('BeanInterface' => 'KenyanBean')
61
+	 *  Then, whenever the CoffeeShop brews an instance of HonduranCoffee,
62
+	 *  an instance of HonduranBean will get injected for the BeanInterface dependency,
63
+	 *  and whenever the CoffeeShop brews an instance of KenyanCoffee,
64
+	 *  an instance of KenyanBean will get injected for the BeanInterface dependency
65
+	 *
66
+	 * @var array $ingredients
67
+	 */
68
+	private $ingredients = array();
69
+
70
+	/**
71
+	 * one of the class constants from CoffeeShop:
72
+	 *  CoffeeMaker::BREW_NEW - creates a new instance
73
+	 *  CoffeeMaker::BREW_SHARED - creates a shared instance
74
+	 *  CoffeeMaker::BREW_LOAD_ONLY - loads but does not instantiate
75
+	 *
76
+	 * @var string $type
77
+	 */
78
+	private $type;
79
+
80
+	/**
81
+	 * class name aliases - typically a Fully Qualified Interface that the class implements
82
+	 * identifiers passed to the CoffeeShop will be run through the filters to find the correct class name
83
+	 *
84
+	 * @var array $filters
85
+	 */
86
+	private $filters = array();
87
+
88
+	/**
89
+	 * array of full server filepaths to files that may contain the class
90
+	 *
91
+	 * @var array $paths
92
+	 */
93
+	private $paths = array();
94
+
95
+
96
+
97
+	/**
98
+	 * Recipe constructor.
99
+	 *
100
+	 * @param string $identifier    class identifier, can be an alias, or FQCN, or whatever
101
+	 * @param string $fqcn          \Fully\Qualified\ClassName, optional if $identifier is FQCN
102
+	 * @param array  $ingredients   array of dependencies that can not be resolved automatically,
103
+	 *                              used for resolving concrete classes for type hinted interfaces
104
+	 *                              for the dependencies of THIS class
105
+	 * @param string $type          recipe type: one of the class constants on
106
+	 *                              \EventEspresso\core\services\container\CoffeeMaker
107
+	 * @param array  $filters       array of class aliases, or class interfaces
108
+	 *                              this works somewhat opposite to the $ingredients array above,
109
+	 *                              in that this array specifies interfaces or aliases
110
+	 *                              that this Recipe can be used for when resolving OTHER class's dependencies
111
+	 * @param array  $paths         if class can not be loaded via PSR-4 autoloading,
112
+	 *                              then supply a filepath, or array of filepaths, so that it can be included
113
+	 */
114
+	public function __construct(
115
+		$identifier,
116
+		$fqcn = '',
117
+		$filters = array(),
118
+		$ingredients = array(),
119
+		$type = CoffeeMaker::BREW_NEW,
120
+		$paths = array()
121
+	)
122
+	{
123
+		$this->setIdentifier($identifier);
124
+		$this->setFilters((array)$filters);
125
+		$this->setIngredients((array)$ingredients);
126
+		$this->setType($type);
127
+		$this->setPaths($paths);
128
+		$this->setFqcn($fqcn);
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public function identifier()
137
+	{
138
+		return $this->identifier;
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * @return string
145
+	 */
146
+	public function fqcn()
147
+	{
148
+		return $this->fqcn;
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * @return array
155
+	 */
156
+	public function filters()
157
+	{
158
+		return (array)$this->filters;
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * @return array
165
+	 */
166
+	public function ingredients()
167
+	{
168
+		return $this->ingredients;
169
+	}
170
+
171
+
172
+
173
+	/**
174
+	 * @return string
175
+	 */
176
+	public function type()
177
+	{
178
+		return $this->type;
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @return array
185
+	 */
186
+	public function paths()
187
+	{
188
+		return (array)$this->paths;
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * @param  string $identifier Identifier for the entity class that the Recipe applies to
195
+	 *                            Typically a Fully Qualified Class Name
196
+	 */
197
+	public function setIdentifier($identifier)
198
+	{
199
+		if ( ! is_string($identifier) || empty($identifier)) {
200
+			throw new InvalidIdentifierException(
201
+				is_object($identifier) ? get_class($identifier) : gettype($identifier),
202
+				__('class identifier (typically a \Fully\Qualified\ClassName)', 'event_espresso')
203
+			);
204
+		}
205
+		$this->identifier = $identifier;
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * Ensures incoming string is a valid Fully Qualified Class Name,
212
+	 * except if this is the default wildcard Recipe ( * ),
213
+	 * or it's NOT an actual FQCN because the Recipe is using filepaths
214
+	 * for classes that are not PSR-4 compatible
215
+	 * PLZ NOTE:
216
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
217
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
218
+	 *
219
+	 * @param string $fqcn
220
+	 */
221
+	public function setFqcn($fqcn)
222
+	{
223
+		$fqcn = ! empty($fqcn) ? $fqcn : $this->identifier;
224
+		if ( ! is_string($fqcn)) {
225
+			throw new InvalidDataTypeException(
226
+				'$fqcn',
227
+				is_object($fqcn) ? get_class($fqcn) : gettype($fqcn),
228
+				__('string (Fully\Qualified\ClassName)', 'event_espresso')
229
+			);
230
+		}
231
+		$fqcn = ltrim($fqcn, '\\');
232
+		if (
233
+			$fqcn !== Recipe::DEFAULT_ID
234
+			&& ! empty($fqcn)
235
+			&& empty($this->paths)
236
+			&& ! class_exists($fqcn)
237
+		) {
238
+			throw new InvalidClassException($fqcn);
239
+		}
240
+		$this->fqcn = $fqcn;
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * @param array $ingredients    an array of dependencies where keys are the aliases and values are the FQCNs
247
+	 *                              example:
248
+	 *                              array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
249
+	 */
250
+	public function setIngredients(array $ingredients)
251
+	{
252
+		if (empty($ingredients)) {
253
+			return;
254
+		}
255
+		if ( ! is_array($ingredients)) {
256
+			throw new InvalidDataTypeException(
257
+				'$ingredients',
258
+				is_object($ingredients) ? get_class($ingredients) : gettype($ingredients),
259
+				__('array of class dependencies', 'event_espresso')
260
+			);
261
+		}
262
+		$this->ingredients = array_merge($this->ingredients, $ingredients);
263
+	}
264
+
265
+
266
+	/**
267
+	 * @param string $type one of the class constants returned from CoffeeMaker::getTypes()
268
+	 */
269
+	public function setType($type = CoffeeMaker::BREW_NEW)
270
+	{
271
+		$this->type = CoffeeMaker::validateType($type);
272
+	}
273
+
274
+
275
+
276
+	/**
277
+	 * @param array $filters an array of filters where keys are the aliases and values are the FQCNs
278
+	 *                          example:
279
+	 *                          array( 'ClassInterface' => 'Fully\Qualified\ClassName' )
280
+	 */
281
+	public function setFilters(array $filters)
282
+	{
283
+		if (empty($filters)) {
284
+			return;
285
+		}
286
+		if ( ! is_array($filters)) {
287
+			throw new InvalidDataTypeException(
288
+				'$filters',
289
+				is_object($filters) ? get_class($filters) : gettype($filters),
290
+				__('array of class aliases', 'event_espresso')
291
+			);
292
+		}
293
+		$this->filters = array_merge($this->filters, $filters);
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * Ensures incoming paths is a valid filepath, or array of valid filepaths,
300
+	 * and merges them in with any existing filepaths
301
+	 *
302
+	 * PLZ NOTE:
303
+	 *  Recipe::setFqcn() has a check to see if Recipe::$paths is empty or not,
304
+	 *  therefore you should always call Recipe::setPaths() before Recipe::setFqcn()
305
+	 *
306
+	 * @param string|array $paths
307
+	 */
308
+	public function setPaths($paths = array())
309
+	{
310
+		if (empty($paths)) {
311
+			return;
312
+		}
313
+		if ( ! (is_string($paths) || is_array($paths))) {
314
+			throw new InvalidDataTypeException(
315
+				'$path',
316
+				is_object($paths) ? get_class($paths) : gettype($paths),
317
+				__('string or array of strings (full server filepath(s))', 'event_espresso')
318
+			);
319
+		}
320
+		$paths = (array)$paths;
321
+		foreach ($paths as $path) {
322
+			if (strpos($path, '*') === false && ! is_readable($path)) {
323
+				throw new RuntimeException(
324
+					sprintf(
325
+						__('The following filepath is not readable: "%1$s"', 'event_espresso'),
326
+						$path
327
+					)
328
+				);
329
+			}
330
+		}
331
+		$this->paths = array_merge($this->paths, $paths);
332
+	}
333 333
 
334 334
 
335 335
 
Please login to merge, or discard this patch.
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.
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/domain/services/capabilities/CapCheck.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
 
40 40
     /**
41
-     * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations',
41
+     * @param string $capability - the capability to be checked, like: 'ee_edit_registrations',
42 42
      *                                   or an array of capability strings
43 43
      * @param string       $context    - what the user is attempting to do, like: 'Edit Registration'
44 44
      * @param int          $ID         - (optional) ID for item where current_user_can is being called from
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\exceptions\InvalidDataTypeException;
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
 
@@ -20,71 +20,71 @@  discard block
 block discarded – undo
20 20
 class CapCheck implements CapCheckInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var string|array $capability
25
-     */
26
-    private $capability;
27
-
28
-    /**
29
-     * @var string $context
30
-     */
31
-    private $context;
32
-
33
-    /**
34
-     * @var int|string $ID
35
-     */
36
-    private $ID;
37
-
38
-
39
-
40
-    /**
41
-     * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations',
42
-     *                                   or an array of capability strings
43
-     * @param string       $context    - what the user is attempting to do, like: 'Edit Registration'
44
-     * @param int          $ID         - (optional) ID for item where current_user_can is being called from
45
-     */
46
-    public function __construct($capability, $context, $ID = 0)
47
-    {
48
-        if ( ! is_string($capability)) {
49
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
50
-        }
51
-        if ( ! is_string($context)) {
52
-            throw new InvalidDataTypeException('$context', $context, 'string');
53
-        }
54
-        $this->capability = $capability;
55
-        $this->context = strtolower(str_replace(' ', '_', $context));
56
-        $this->ID = $ID;
57
-    }
58
-
59
-
60
-
61
-    /**
62
-     * @return string|array
63
-     */
64
-    public function capability()
65
-    {
66
-        return $this->capability;
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     * @return string
73
-     */
74
-    public function context()
75
-    {
76
-        return $this->context;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * @return int|string
83
-     */
84
-    public function ID()
85
-    {
86
-        return $this->ID;
87
-    }
23
+	/**
24
+	 * @var string|array $capability
25
+	 */
26
+	private $capability;
27
+
28
+	/**
29
+	 * @var string $context
30
+	 */
31
+	private $context;
32
+
33
+	/**
34
+	 * @var int|string $ID
35
+	 */
36
+	private $ID;
37
+
38
+
39
+
40
+	/**
41
+	 * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations',
42
+	 *                                   or an array of capability strings
43
+	 * @param string       $context    - what the user is attempting to do, like: 'Edit Registration'
44
+	 * @param int          $ID         - (optional) ID for item where current_user_can is being called from
45
+	 */
46
+	public function __construct($capability, $context, $ID = 0)
47
+	{
48
+		if ( ! is_string($capability)) {
49
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
50
+		}
51
+		if ( ! is_string($context)) {
52
+			throw new InvalidDataTypeException('$context', $context, 'string');
53
+		}
54
+		$this->capability = $capability;
55
+		$this->context = strtolower(str_replace(' ', '_', $context));
56
+		$this->ID = $ID;
57
+	}
58
+
59
+
60
+
61
+	/**
62
+	 * @return string|array
63
+	 */
64
+	public function capability()
65
+	{
66
+		return $this->capability;
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 * @return string
73
+	 */
74
+	public function context()
75
+	{
76
+		return $this->context;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * @return int|string
83
+	 */
84
+	public function ID()
85
+	{
86
+		return $this->ID;
87
+	}
88 88
 
89 89
 
90 90
 }
Please login to merge, or discard this patch.
core/EE_Network_Config.core.php 1 patch
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.