Completed
Pull Request — master (#331)
by Darren
16:18
created
espresso.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.033');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.033');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/services/collections/CollectionLoader.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
 
164 164
     /**
165 165
      * @param        $entity
166
-     * @param  mixed $identifier
166
+     * @param  string $identifier
167 167
      * @return string
168 168
      * @throws InvalidEntityException
169 169
      */
Please login to merge, or discard this patch.
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -27,276 +27,276 @@
 block discarded – undo
27 27
 class CollectionLoader
28 28
 {
29 29
 
30
-    /**
31
-     * possible return value when adding entities to a collection.
32
-     * denotes that the entity was NOT ADDED to the collection
33
-     */
34
-    const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
30
+	/**
31
+	 * possible return value when adding entities to a collection.
32
+	 * denotes that the entity was NOT ADDED to the collection
33
+	 */
34
+	const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
35 35
 
36
-    /**
37
-     * possible return value when adding entities to a collection.
38
-     * denotes that the entity was SUCCESSFULLY ADDED to the collection
39
-     */
40
-    const ENTITY_ADDED = 'entity-added-to-collection';
36
+	/**
37
+	 * possible return value when adding entities to a collection.
38
+	 * denotes that the entity was SUCCESSFULLY ADDED to the collection
39
+	 */
40
+	const ENTITY_ADDED = 'entity-added-to-collection';
41 41
 
42
-    /**
43
-     * possible return value when adding entities to a collection.
44
-     * denotes that the entity was ALREADY ADDED to the collection,
45
-     * and therefore could not be added again.
46
-     */
47
-    const ENTITY_EXISTS = 'entity-already-in-collection';
42
+	/**
43
+	 * possible return value when adding entities to a collection.
44
+	 * denotes that the entity was ALREADY ADDED to the collection,
45
+	 * and therefore could not be added again.
46
+	 */
47
+	const ENTITY_EXISTS = 'entity-already-in-collection';
48 48
 
49 49
 
50
-    /**
51
-     * @var CollectionDetailsInterface $collection_details
52
-     */
53
-    protected $collection_details;
50
+	/**
51
+	 * @var CollectionDetailsInterface $collection_details
52
+	 */
53
+	protected $collection_details;
54 54
 
55
-    /**
56
-     * @var CollectionInterface $collection
57
-     */
58
-    protected $collection;
55
+	/**
56
+	 * @var CollectionInterface $collection
57
+	 */
58
+	protected $collection;
59 59
 
60
-    /**
61
-     * @var FileLocator $file_locator
62
-     */
63
-    protected $file_locator;
60
+	/**
61
+	 * @var FileLocator $file_locator
62
+	 */
63
+	protected $file_locator;
64 64
 
65 65
 
66
-    /**
67
-     * CollectionLoader constructor.
68
-     *
69
-     * @param CollectionDetailsInterface $collection_details
70
-     * @param CollectionInterface        $collection
71
-     * @param LocatorInterface           $file_locator
72
-     * @throws ReflectionException
73
-     * @throws InvalidArgumentException
74
-     * @throws EE_Error
75
-     * @throws InvalidInterfaceException
76
-     * @throws InvalidClassException
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidFilePathException
79
-     * @throws InvalidEntityException
80
-     */
81
-    public function __construct(
82
-        CollectionDetailsInterface $collection_details,
83
-        CollectionInterface $collection = null,
84
-        LocatorInterface $file_locator = null
85
-    ) {
86
-        $this->collection_details = $collection_details;
87
-        if (! $collection instanceof CollectionInterface) {
88
-            $collection = new Collection($this->collection_details->getCollectionInterface());
89
-        }
90
-        $this->collection = $collection;
91
-        $this->file_locator = $file_locator;
92
-        $this->loadAllFromFilepaths();
93
-        $this->loadFromFQCNs();
94
-    }
66
+	/**
67
+	 * CollectionLoader constructor.
68
+	 *
69
+	 * @param CollectionDetailsInterface $collection_details
70
+	 * @param CollectionInterface        $collection
71
+	 * @param LocatorInterface           $file_locator
72
+	 * @throws ReflectionException
73
+	 * @throws InvalidArgumentException
74
+	 * @throws EE_Error
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws InvalidClassException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidFilePathException
79
+	 * @throws InvalidEntityException
80
+	 */
81
+	public function __construct(
82
+		CollectionDetailsInterface $collection_details,
83
+		CollectionInterface $collection = null,
84
+		LocatorInterface $file_locator = null
85
+	) {
86
+		$this->collection_details = $collection_details;
87
+		if (! $collection instanceof CollectionInterface) {
88
+			$collection = new Collection($this->collection_details->getCollectionInterface());
89
+		}
90
+		$this->collection = $collection;
91
+		$this->file_locator = $file_locator;
92
+		$this->loadAllFromFilepaths();
93
+		$this->loadFromFQCNs();
94
+	}
95 95
 
96 96
 
97
-    /**
98
-     * @return CollectionInterface
99
-     */
100
-    public function getCollection()
101
-    {
102
-        return $this->collection;
103
-    }
97
+	/**
98
+	 * @return CollectionInterface
99
+	 */
100
+	public function getCollection()
101
+	{
102
+		return $this->collection;
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @throws InvalidClassException
108
-     * @throws InvalidFilePathException
109
-     * @throws InvalidDataTypeException
110
-     * @throws InvalidEntityException
111
-     */
112
-    protected function loadAllFromFilepaths()
113
-    {
114
-        if (! $this->file_locator instanceof FileLocator) {
115
-            $this->file_locator = new FileLocator();
116
-        }
117
-        $this->file_locator->setFileMask($this->collection_details->getFileMask());
118
-        // find all of the files that match the file mask in the specified folder
119
-        $this->file_locator->locate($this->collection_details->getCollectionPaths());
120
-        // filter the results
121
-        $filepaths = (array) apply_filters(
122
-            'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
123
-            $this->file_locator->getFilePaths(),
124
-            $this->collection_details->collectionName(),
125
-            $this->collection_details
126
-        );
127
-        if (empty($filepaths)) {
128
-            return;
129
-        }
130
-        foreach ($filepaths as $filepath) {
131
-            $this->loadClassFromFilepath($filepath);
132
-        }
133
-    }
106
+	/**
107
+	 * @throws InvalidClassException
108
+	 * @throws InvalidFilePathException
109
+	 * @throws InvalidDataTypeException
110
+	 * @throws InvalidEntityException
111
+	 */
112
+	protected function loadAllFromFilepaths()
113
+	{
114
+		if (! $this->file_locator instanceof FileLocator) {
115
+			$this->file_locator = new FileLocator();
116
+		}
117
+		$this->file_locator->setFileMask($this->collection_details->getFileMask());
118
+		// find all of the files that match the file mask in the specified folder
119
+		$this->file_locator->locate($this->collection_details->getCollectionPaths());
120
+		// filter the results
121
+		$filepaths = (array) apply_filters(
122
+			'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
123
+			$this->file_locator->getFilePaths(),
124
+			$this->collection_details->collectionName(),
125
+			$this->collection_details
126
+		);
127
+		if (empty($filepaths)) {
128
+			return;
129
+		}
130
+		foreach ($filepaths as $filepath) {
131
+			$this->loadClassFromFilepath($filepath);
132
+		}
133
+	}
134 134
 
135 135
 
136
-    /**
137
-     * @param  string $filepath
138
-     * @return string
139
-     * @throws InvalidEntityException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidFilePathException
142
-     * @throws InvalidClassException
143
-     */
144
-    protected function loadClassFromFilepath($filepath)
145
-    {
146
-        if (! is_string($filepath)) {
147
-            throw new InvalidDataTypeException('$filepath', $filepath, 'string');
148
-        }
149
-        if (! is_readable($filepath)) {
150
-            throw new InvalidFilePathException($filepath);
151
-        }
152
-        require_once $filepath;
153
-        // extract filename from path
154
-        $file_name = basename($filepath);
155
-        // now remove any file extensions
156
-        $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
157
-        if (! class_exists($class_name)) {
158
-            throw new InvalidClassException($class_name);
159
-        }
160
-        return $this->addEntityToCollection(new $class_name(), $file_name);
161
-    }
136
+	/**
137
+	 * @param  string $filepath
138
+	 * @return string
139
+	 * @throws InvalidEntityException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidFilePathException
142
+	 * @throws InvalidClassException
143
+	 */
144
+	protected function loadClassFromFilepath($filepath)
145
+	{
146
+		if (! is_string($filepath)) {
147
+			throw new InvalidDataTypeException('$filepath', $filepath, 'string');
148
+		}
149
+		if (! is_readable($filepath)) {
150
+			throw new InvalidFilePathException($filepath);
151
+		}
152
+		require_once $filepath;
153
+		// extract filename from path
154
+		$file_name = basename($filepath);
155
+		// now remove any file extensions
156
+		$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
157
+		if (! class_exists($class_name)) {
158
+			throw new InvalidClassException($class_name);
159
+		}
160
+		return $this->addEntityToCollection(new $class_name(), $file_name);
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * @param        $entity
166
-     * @param  mixed $identifier
167
-     * @return string
168
-     * @throws InvalidEntityException
169
-     */
170
-    protected function addEntityToCollection($entity, $identifier)
171
-    {
172
-        do_action(
173
-            'FHEE__CollectionLoader__addEntityToCollection__entity',
174
-            $entity,
175
-            $this->collection_details->collectionName(),
176
-            $this->collection_details
177
-        );
178
-        $identifier = $this->setIdentifier($entity, $identifier);
179
-        if ($this->collection->has($identifier)) {
180
-            do_action(
181
-                'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
182
-                $this,
183
-                $this->collection_details->collectionName(),
184
-                $this->collection_details
185
-            );
186
-            return CollectionLoader::ENTITY_EXISTS;
187
-        }
188
-        if ($this->collection->add($entity, $identifier)) {
189
-            do_action(
190
-                'FHEE__CollectionLoader__addEntityToCollection__entity_added',
191
-                $this,
192
-                $this->collection_details->collectionName(),
193
-                $this->collection_details
194
-            );
195
-            return CollectionLoader::ENTITY_ADDED;
196
-        }
197
-        do_action(
198
-            'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
199
-            $this,
200
-            $this->collection_details->collectionName(),
201
-            $this->collection_details
202
-        );
203
-        return CollectionLoader::ENTITY_NOT_ADDED;
204
-    }
164
+	/**
165
+	 * @param        $entity
166
+	 * @param  mixed $identifier
167
+	 * @return string
168
+	 * @throws InvalidEntityException
169
+	 */
170
+	protected function addEntityToCollection($entity, $identifier)
171
+	{
172
+		do_action(
173
+			'FHEE__CollectionLoader__addEntityToCollection__entity',
174
+			$entity,
175
+			$this->collection_details->collectionName(),
176
+			$this->collection_details
177
+		);
178
+		$identifier = $this->setIdentifier($entity, $identifier);
179
+		if ($this->collection->has($identifier)) {
180
+			do_action(
181
+				'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
182
+				$this,
183
+				$this->collection_details->collectionName(),
184
+				$this->collection_details
185
+			);
186
+			return CollectionLoader::ENTITY_EXISTS;
187
+		}
188
+		if ($this->collection->add($entity, $identifier)) {
189
+			do_action(
190
+				'FHEE__CollectionLoader__addEntityToCollection__entity_added',
191
+				$this,
192
+				$this->collection_details->collectionName(),
193
+				$this->collection_details
194
+			);
195
+			return CollectionLoader::ENTITY_ADDED;
196
+		}
197
+		do_action(
198
+			'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
199
+			$this,
200
+			$this->collection_details->collectionName(),
201
+			$this->collection_details
202
+		);
203
+		return CollectionLoader::ENTITY_NOT_ADDED;
204
+	}
205 205
 
206 206
 
207
-    /**
208
-     * @param        $entity
209
-     * @param  mixed $identifier
210
-     * @return string
211
-     * @throws InvalidEntityException
212
-     */
213
-    protected function setIdentifier($entity, $identifier)
214
-    {
215
-        switch ($this->collection_details->identifierType()) {
216
-            // every unique object gets added to the collection, but not duplicates of the exact same object
217
-            case CollectionDetails::ID_OBJECT_HASH :
218
-                $identifier = spl_object_hash($entity);
219
-                break;
220
-            // only one entity per class can be added to collection, like a singleton
221
-            case CollectionDetails::ID_CLASS_NAME:
222
-                $identifier = get_class($entity);
223
-                break;
224
-            // objects added to the collection based on entity callback, so the entity itself decides
225
-            case CollectionDetails::ID_CALLBACK_METHOD:
226
-                $identifier_callback = $this->collection_details->identifierCallback();
227
-                if (! method_exists($entity, $identifier_callback)) {
228
-                    throw new InvalidEntityException(
229
-                        $entity,
230
-                        $this->collection_details->getCollectionInterface(),
231
-                        sprintf(
232
-                            __(
233
-                                'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
207
+	/**
208
+	 * @param        $entity
209
+	 * @param  mixed $identifier
210
+	 * @return string
211
+	 * @throws InvalidEntityException
212
+	 */
213
+	protected function setIdentifier($entity, $identifier)
214
+	{
215
+		switch ($this->collection_details->identifierType()) {
216
+			// every unique object gets added to the collection, but not duplicates of the exact same object
217
+			case CollectionDetails::ID_OBJECT_HASH :
218
+				$identifier = spl_object_hash($entity);
219
+				break;
220
+			// only one entity per class can be added to collection, like a singleton
221
+			case CollectionDetails::ID_CLASS_NAME:
222
+				$identifier = get_class($entity);
223
+				break;
224
+			// objects added to the collection based on entity callback, so the entity itself decides
225
+			case CollectionDetails::ID_CALLBACK_METHOD:
226
+				$identifier_callback = $this->collection_details->identifierCallback();
227
+				if (! method_exists($entity, $identifier_callback)) {
228
+					throw new InvalidEntityException(
229
+						$entity,
230
+						$this->collection_details->getCollectionInterface(),
231
+						sprintf(
232
+							__(
233
+								'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
234 234
                                 of "%2$s", but does not contain this method.',
235
-                                'event_espresso'
236
-                            ),
237
-                            $identifier_callback,
238
-                            get_class($entity)
239
-                        )
240
-                    );
241
-                }
242
-                $identifier = $entity->{$identifier_callback}();
243
-                break;
244
-        }
245
-        return apply_filters(
246
-            'FHEE__CollectionLoader__addEntityToCollection__identifier',
247
-            $identifier,
248
-            $this->collection_details->collectionName(),
249
-            $this->collection_details
250
-        );
251
-    }
235
+								'event_espresso'
236
+							),
237
+							$identifier_callback,
238
+							get_class($entity)
239
+						)
240
+					);
241
+				}
242
+				$identifier = $entity->{$identifier_callback}();
243
+				break;
244
+		}
245
+		return apply_filters(
246
+			'FHEE__CollectionLoader__addEntityToCollection__identifier',
247
+			$identifier,
248
+			$this->collection_details->collectionName(),
249
+			$this->collection_details
250
+		);
251
+	}
252 252
 
253 253
 
254
-    /**
255
-     * @throws ReflectionException
256
-     * @throws InvalidArgumentException
257
-     * @throws InvalidInterfaceException
258
-     * @throws EE_Error
259
-     * @throws InvalidClassException
260
-     * @throws InvalidDataTypeException
261
-     * @throws InvalidEntityException
262
-     */
263
-    protected function loadFromFQCNs()
264
-    {
265
-        $FQCNs = $this->collection_details->getCollectionFQCNs();
266
-        $FQCNs = (array) apply_filters(
267
-            'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
268
-            $FQCNs,
269
-            $this->collection_details->collectionName(),
270
-            $this->collection_details
271
-        );
272
-        foreach ($FQCNs as $FQCN) {
273
-            $this->loadClassFromFQCN($FQCN);
274
-        }
275
-    }
254
+	/**
255
+	 * @throws ReflectionException
256
+	 * @throws InvalidArgumentException
257
+	 * @throws InvalidInterfaceException
258
+	 * @throws EE_Error
259
+	 * @throws InvalidClassException
260
+	 * @throws InvalidDataTypeException
261
+	 * @throws InvalidEntityException
262
+	 */
263
+	protected function loadFromFQCNs()
264
+	{
265
+		$FQCNs = $this->collection_details->getCollectionFQCNs();
266
+		$FQCNs = (array) apply_filters(
267
+			'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
268
+			$FQCNs,
269
+			$this->collection_details->collectionName(),
270
+			$this->collection_details
271
+		);
272
+		foreach ($FQCNs as $FQCN) {
273
+			$this->loadClassFromFQCN($FQCN);
274
+		}
275
+	}
276 276
 
277 277
 
278
-    /**
279
-     * @param  string $FQCN Fully Qualified Class Name
280
-     * @return string
281
-     * @throws InvalidArgumentException
282
-     * @throws InvalidInterfaceException
283
-     * @throws ReflectionException
284
-     * @throws EE_Error
285
-     * @throws InvalidEntityException
286
-     * @throws InvalidDataTypeException
287
-     * @throws InvalidClassException
288
-     */
289
-    protected function loadClassFromFQCN($FQCN)
290
-    {
291
-        if (! is_string($FQCN)) {
292
-            throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
293
-        }
294
-        if (! class_exists($FQCN)) {
295
-            throw new InvalidClassException($FQCN);
296
-        }
297
-        return $this->addEntityToCollection(
298
-            EE_Registry::instance()->create($FQCN),
299
-            $FQCN
300
-        );
301
-    }
278
+	/**
279
+	 * @param  string $FQCN Fully Qualified Class Name
280
+	 * @return string
281
+	 * @throws InvalidArgumentException
282
+	 * @throws InvalidInterfaceException
283
+	 * @throws ReflectionException
284
+	 * @throws EE_Error
285
+	 * @throws InvalidEntityException
286
+	 * @throws InvalidDataTypeException
287
+	 * @throws InvalidClassException
288
+	 */
289
+	protected function loadClassFromFQCN($FQCN)
290
+	{
291
+		if (! is_string($FQCN)) {
292
+			throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
293
+		}
294
+		if (! class_exists($FQCN)) {
295
+			throw new InvalidClassException($FQCN);
296
+		}
297
+		return $this->addEntityToCollection(
298
+			EE_Registry::instance()->create($FQCN),
299
+			$FQCN
300
+		);
301
+	}
302 302
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         LocatorInterface $file_locator = null
85 85
     ) {
86 86
         $this->collection_details = $collection_details;
87
-        if (! $collection instanceof CollectionInterface) {
87
+        if ( ! $collection instanceof CollectionInterface) {
88 88
             $collection = new Collection($this->collection_details->getCollectionInterface());
89 89
         }
90 90
         $this->collection = $collection;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function loadAllFromFilepaths()
113 113
     {
114
-        if (! $this->file_locator instanceof FileLocator) {
114
+        if ( ! $this->file_locator instanceof FileLocator) {
115 115
             $this->file_locator = new FileLocator();
116 116
         }
117 117
         $this->file_locator->setFileMask($this->collection_details->getFileMask());
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
      */
144 144
     protected function loadClassFromFilepath($filepath)
145 145
     {
146
-        if (! is_string($filepath)) {
146
+        if ( ! is_string($filepath)) {
147 147
             throw new InvalidDataTypeException('$filepath', $filepath, 'string');
148 148
         }
149
-        if (! is_readable($filepath)) {
149
+        if ( ! is_readable($filepath)) {
150 150
             throw new InvalidFilePathException($filepath);
151 151
         }
152 152
         require_once $filepath;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $file_name = basename($filepath);
155 155
         // now remove any file extensions
156 156
         $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
157
-        if (! class_exists($class_name)) {
157
+        if ( ! class_exists($class_name)) {
158 158
             throw new InvalidClassException($class_name);
159 159
         }
160 160
         return $this->addEntityToCollection(new $class_name(), $file_name);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // objects added to the collection based on entity callback, so the entity itself decides
225 225
             case CollectionDetails::ID_CALLBACK_METHOD:
226 226
                 $identifier_callback = $this->collection_details->identifierCallback();
227
-                if (! method_exists($entity, $identifier_callback)) {
227
+                if ( ! method_exists($entity, $identifier_callback)) {
228 228
                     throw new InvalidEntityException(
229 229
                         $entity,
230 230
                         $this->collection_details->getCollectionInterface(),
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
      */
289 289
     protected function loadClassFromFQCN($FQCN)
290 290
     {
291
-        if (! is_string($FQCN)) {
291
+        if ( ! is_string($FQCN)) {
292 292
             throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
293 293
         }
294
-        if (! class_exists($FQCN)) {
294
+        if ( ! class_exists($FQCN)) {
295 295
             throw new InvalidClassException($FQCN);
296 296
         }
297 297
         return $this->addEntityToCollection(
Please login to merge, or discard this patch.
core/exceptions/InvalidEntityException.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,30 +16,30 @@
 block discarded – undo
16 16
 class InvalidEntityException extends InvalidArgumentException
17 17
 {
18 18
 
19
-    /**
20
-     * InvalidEntityException constructor.
21
-     *
22
-     * @param mixed     $actual   the actual object (or thing) we got
23
-     * @param string    $expected classname of the entity we wanted
24
-     * @param string    $message
25
-     * @param int       $code
26
-     * @param Exception $previous
27
-     */
28
-    public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null)
29
-    {
30
-        if (empty($message)) {
31
-            $message = sprintf(
32
-                __(
33
-                    'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s',
34
-                    'event_espresso'
35
-                ),
36
-                is_object($actual)
37
-                    ? get_class($actual)
38
-                    : gettype($actual),
39
-                $expected,
40
-                var_export($actual, true)
41
-            );
42
-        }
43
-        parent::__construct($message, $code, $previous);
44
-    }
19
+	/**
20
+	 * InvalidEntityException constructor.
21
+	 *
22
+	 * @param mixed     $actual   the actual object (or thing) we got
23
+	 * @param string    $expected classname of the entity we wanted
24
+	 * @param string    $message
25
+	 * @param int       $code
26
+	 * @param Exception $previous
27
+	 */
28
+	public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null)
29
+	{
30
+		if (empty($message)) {
31
+			$message = sprintf(
32
+				__(
33
+					'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s',
34
+					'event_espresso'
35
+				),
36
+				is_object($actual)
37
+					? get_class($actual)
38
+					: gettype($actual),
39
+				$expected,
40
+				var_export($actual, true)
41
+			);
42
+		}
43
+		parent::__construct($message, $code, $previous);
44
+	}
45 45
 }
Please login to merge, or discard this patch.