Completed
Branch BUG/required-message-fields (8f9492)
by
unknown
10:53 queued 20s
created
core/services/collections/CollectionLoader.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     ) {
88 88
         try {
89 89
             $this->collection_details = $collection_details;
90
-            if (! $collection instanceof CollectionInterface) {
90
+            if ( ! $collection instanceof CollectionInterface) {
91 91
                 $collection = new Collection($this->collection_details->getCollectionInterface());
92 92
             }
93 93
             $this->collection = $collection;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function loadAllFromFilepaths()
121 121
     {
122
-        if (! $this->file_locator instanceof FileLocator) {
122
+        if ( ! $this->file_locator instanceof FileLocator) {
123 123
             $this->file_locator = new FileLocator();
124 124
         }
125 125
         $this->file_locator->setFileMask($this->collection_details->getFileMask());
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      */
153 153
     protected function loadClassFromFilepath($filepath)
154 154
     {
155
-        if (! is_string($filepath)) {
155
+        if ( ! is_string($filepath)) {
156 156
             throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157 157
         }
158
-        if (! is_readable($filepath)) {
158
+        if ( ! is_readable($filepath)) {
159 159
             throw new InvalidFilePathException($filepath);
160 160
         }
161 161
         require_once $filepath;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $file_name = basename($filepath);
164 164
         // now remove any file extensions
165 165
         $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
-        if (! class_exists($class_name)) {
166
+        if ( ! class_exists($class_name)) {
167 167
             throw new InvalidClassException($class_name);
168 168
         }
169 169
         $entity = $this->entity_factory instanceof FactoryInterface
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             // objects added to the collection based on entity callback, so the entity itself decides
238 238
             case CollectionDetails::ID_CALLBACK_METHOD:
239 239
                 $identifier_callback = $this->collection_details->identifierCallback();
240
-                if (! method_exists($entity, $identifier_callback)) {
240
+                if ( ! method_exists($entity, $identifier_callback)) {
241 241
                     throw new InvalidEntityException(
242 242
                         $entity,
243 243
                         $this->collection_details->getCollectionInterface(),
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     protected function loadClassFromFQCN($FQCN)
305 305
     {
306
-        if (! is_string($FQCN)) {
306
+        if ( ! is_string($FQCN)) {
307 307
             throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308 308
         }
309
-        if (! class_exists($FQCN)) {
309
+        if ( ! class_exists($FQCN)) {
310 310
             throw new InvalidClassException($FQCN);
311 311
         }
312 312
         do_action(
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -28,295 +28,295 @@
 block discarded – undo
28 28
  */
29 29
 class CollectionLoader
30 30
 {
31
-    /**
32
-     * possible return value when adding entities to a collection.
33
-     * denotes that the entity was NOT ADDED to the collection
34
-     */
35
-    const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
31
+	/**
32
+	 * possible return value when adding entities to a collection.
33
+	 * denotes that the entity was NOT ADDED to the collection
34
+	 */
35
+	const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
36 36
 
37
-    /**
38
-     * possible return value when adding entities to a collection.
39
-     * denotes that the entity was SUCCESSFULLY ADDED to the collection
40
-     */
41
-    const ENTITY_ADDED = 'entity-added-to-collection';
37
+	/**
38
+	 * possible return value when adding entities to a collection.
39
+	 * denotes that the entity was SUCCESSFULLY ADDED to the collection
40
+	 */
41
+	const ENTITY_ADDED = 'entity-added-to-collection';
42 42
 
43
-    /**
44
-     * possible return value when adding entities to a collection.
45
-     * denotes that the entity was ALREADY ADDED to the collection,
46
-     * and therefore could not be added again.
47
-     */
48
-    const ENTITY_EXISTS = 'entity-already-in-collection';
43
+	/**
44
+	 * possible return value when adding entities to a collection.
45
+	 * denotes that the entity was ALREADY ADDED to the collection,
46
+	 * and therefore could not be added again.
47
+	 */
48
+	const ENTITY_EXISTS = 'entity-already-in-collection';
49 49
 
50 50
 
51
-    /**
52
-     * @var CollectionDetailsInterface $collection_details
53
-     */
54
-    protected $collection_details;
51
+	/**
52
+	 * @var CollectionDetailsInterface $collection_details
53
+	 */
54
+	protected $collection_details;
55 55
 
56
-    /**
57
-     * @var CollectionInterface $collection
58
-     */
59
-    protected $collection;
56
+	/**
57
+	 * @var CollectionInterface $collection
58
+	 */
59
+	protected $collection;
60 60
 
61
-    /**
62
-     * @var FactoryInterface $entity_factory
63
-     */
64
-    protected $entity_factory;
61
+	/**
62
+	 * @var FactoryInterface $entity_factory
63
+	 */
64
+	protected $entity_factory;
65 65
 
66
-    /**
67
-     * @var FileLocator $file_locator
68
-     */
69
-    protected $file_locator;
66
+	/**
67
+	 * @var FileLocator $file_locator
68
+	 */
69
+	protected $file_locator;
70 70
 
71 71
 
72
-    /**
73
-     * CollectionLoader constructor.
74
-     *
75
-     * @param CollectionDetailsInterface $collection_details
76
-     * @param CollectionInterface        $collection
77
-     * @param LocatorInterface           $file_locator
78
-     * @param FactoryInterface|null      $entity_factory
79
-     * @throws CollectionLoaderException
80
-     */
81
-    public function __construct(
82
-        CollectionDetailsInterface $collection_details,
83
-        CollectionInterface $collection = null,
84
-        LocatorInterface $file_locator = null,
85
-        FactoryInterface $entity_factory = null
86
-    ) {
87
-        try {
88
-            $this->collection_details = $collection_details;
89
-            if (! $collection instanceof CollectionInterface) {
90
-                $collection = new Collection($this->collection_details->getCollectionInterface());
91
-            }
92
-            $this->collection = $collection;
93
-            $this->file_locator = $file_locator;
94
-            $this->entity_factory = $entity_factory;
95
-            $this->loadAllFromFilepaths();
96
-            $this->loadFromFQCNs();
97
-        } catch (Exception $exception) {
98
-            throw new CollectionLoaderException($exception);
99
-        }
100
-    }
72
+	/**
73
+	 * CollectionLoader constructor.
74
+	 *
75
+	 * @param CollectionDetailsInterface $collection_details
76
+	 * @param CollectionInterface        $collection
77
+	 * @param LocatorInterface           $file_locator
78
+	 * @param FactoryInterface|null      $entity_factory
79
+	 * @throws CollectionLoaderException
80
+	 */
81
+	public function __construct(
82
+		CollectionDetailsInterface $collection_details,
83
+		CollectionInterface $collection = null,
84
+		LocatorInterface $file_locator = null,
85
+		FactoryInterface $entity_factory = null
86
+	) {
87
+		try {
88
+			$this->collection_details = $collection_details;
89
+			if (! $collection instanceof CollectionInterface) {
90
+				$collection = new Collection($this->collection_details->getCollectionInterface());
91
+			}
92
+			$this->collection = $collection;
93
+			$this->file_locator = $file_locator;
94
+			$this->entity_factory = $entity_factory;
95
+			$this->loadAllFromFilepaths();
96
+			$this->loadFromFQCNs();
97
+		} catch (Exception $exception) {
98
+			throw new CollectionLoaderException($exception);
99
+		}
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * @return CollectionInterface
105
-     */
106
-    public function getCollection()
107
-    {
108
-        return $this->collection;
109
-    }
103
+	/**
104
+	 * @return CollectionInterface
105
+	 */
106
+	public function getCollection()
107
+	{
108
+		return $this->collection;
109
+	}
110 110
 
111 111
 
112
-    /**
113
-     * @throws InvalidClassException
114
-     * @throws InvalidFilePathException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidEntityException
117
-     * @throws DuplicateCollectionIdentifierException
118
-     */
119
-    protected function loadAllFromFilepaths()
120
-    {
121
-        if (! $this->file_locator instanceof FileLocator) {
122
-            $this->file_locator = new FileLocator();
123
-        }
124
-        $this->file_locator->setFileMask($this->collection_details->getFileMask());
125
-        // find all of the files that match the file mask in the specified folder
126
-        $this->file_locator->locate($this->collection_details->getCollectionPaths());
127
-        // filter the results
128
-        $filepaths = (array) apply_filters(
129
-            'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
130
-            $this->file_locator->getFilePaths(),
131
-            $this->collection_details->collectionName(),
132
-            $this->collection_details
133
-        );
134
-        if (empty($filepaths)) {
135
-            return;
136
-        }
137
-        foreach ($filepaths as $filepath) {
138
-            $this->loadClassFromFilepath($filepath);
139
-        }
140
-    }
112
+	/**
113
+	 * @throws InvalidClassException
114
+	 * @throws InvalidFilePathException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidEntityException
117
+	 * @throws DuplicateCollectionIdentifierException
118
+	 */
119
+	protected function loadAllFromFilepaths()
120
+	{
121
+		if (! $this->file_locator instanceof FileLocator) {
122
+			$this->file_locator = new FileLocator();
123
+		}
124
+		$this->file_locator->setFileMask($this->collection_details->getFileMask());
125
+		// find all of the files that match the file mask in the specified folder
126
+		$this->file_locator->locate($this->collection_details->getCollectionPaths());
127
+		// filter the results
128
+		$filepaths = (array) apply_filters(
129
+			'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
130
+			$this->file_locator->getFilePaths(),
131
+			$this->collection_details->collectionName(),
132
+			$this->collection_details
133
+		);
134
+		if (empty($filepaths)) {
135
+			return;
136
+		}
137
+		foreach ($filepaths as $filepath) {
138
+			$this->loadClassFromFilepath($filepath);
139
+		}
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * @param  string $filepath
145
-     * @return string
146
-     * @throws InvalidEntityException
147
-     * @throws InvalidDataTypeException
148
-     * @throws InvalidFilePathException
149
-     * @throws InvalidClassException
150
-     * @throws DuplicateCollectionIdentifierException
151
-     */
152
-    protected function loadClassFromFilepath($filepath)
153
-    {
154
-        if (! is_string($filepath)) {
155
-            throw new InvalidDataTypeException('$filepath', $filepath, 'string');
156
-        }
157
-        if (! is_readable($filepath)) {
158
-            throw new InvalidFilePathException($filepath);
159
-        }
160
-        require_once $filepath;
161
-        // extract filename from path
162
-        $file_name = basename($filepath);
163
-        // now remove any file extensions
164
-        $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
165
-        if (! class_exists($class_name)) {
166
-            throw new InvalidClassException($class_name);
167
-        }
168
-        $entity = $this->entity_factory instanceof FactoryInterface
169
-            ? call_user_func(array($this->entity_factory, 'create'), $class_name)
170
-            : new $class_name();
171
-        return $this->addEntityToCollection($entity, $file_name);
172
-    }
143
+	/**
144
+	 * @param  string $filepath
145
+	 * @return string
146
+	 * @throws InvalidEntityException
147
+	 * @throws InvalidDataTypeException
148
+	 * @throws InvalidFilePathException
149
+	 * @throws InvalidClassException
150
+	 * @throws DuplicateCollectionIdentifierException
151
+	 */
152
+	protected function loadClassFromFilepath($filepath)
153
+	{
154
+		if (! is_string($filepath)) {
155
+			throw new InvalidDataTypeException('$filepath', $filepath, 'string');
156
+		}
157
+		if (! is_readable($filepath)) {
158
+			throw new InvalidFilePathException($filepath);
159
+		}
160
+		require_once $filepath;
161
+		// extract filename from path
162
+		$file_name = basename($filepath);
163
+		// now remove any file extensions
164
+		$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
165
+		if (! class_exists($class_name)) {
166
+			throw new InvalidClassException($class_name);
167
+		}
168
+		$entity = $this->entity_factory instanceof FactoryInterface
169
+			? call_user_func(array($this->entity_factory, 'create'), $class_name)
170
+			: new $class_name();
171
+		return $this->addEntityToCollection($entity, $file_name);
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * @param        $entity
177
-     * @param  mixed $identifier
178
-     * @return string
179
-     * @throws InvalidEntityException
180
-     * @throws DuplicateCollectionIdentifierException
181
-     */
182
-    protected function addEntityToCollection($entity, $identifier)
183
-    {
184
-        do_action(
185
-            'FHEE__CollectionLoader__addEntityToCollection__entity',
186
-            $entity,
187
-            $this->collection_details->collectionName(),
188
-            $this->collection_details
189
-        );
190
-        $identifier = $this->setIdentifier($entity, $identifier);
191
-        if ($this->collection->has($identifier)) {
192
-            do_action(
193
-                'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
194
-                $this,
195
-                $this->collection_details->collectionName(),
196
-                $this->collection_details
197
-            );
198
-            return CollectionLoader::ENTITY_EXISTS;
199
-        }
200
-        if ($this->collection->add($entity, $identifier)) {
201
-            do_action(
202
-                'FHEE__CollectionLoader__addEntityToCollection__entity_added',
203
-                $this,
204
-                $this->collection_details->collectionName(),
205
-                $this->collection_details
206
-            );
207
-            return CollectionLoader::ENTITY_ADDED;
208
-        }
209
-        do_action(
210
-            'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
211
-            $this,
212
-            $this->collection_details->collectionName(),
213
-            $this->collection_details
214
-        );
215
-        return CollectionLoader::ENTITY_NOT_ADDED;
216
-    }
175
+	/**
176
+	 * @param        $entity
177
+	 * @param  mixed $identifier
178
+	 * @return string
179
+	 * @throws InvalidEntityException
180
+	 * @throws DuplicateCollectionIdentifierException
181
+	 */
182
+	protected function addEntityToCollection($entity, $identifier)
183
+	{
184
+		do_action(
185
+			'FHEE__CollectionLoader__addEntityToCollection__entity',
186
+			$entity,
187
+			$this->collection_details->collectionName(),
188
+			$this->collection_details
189
+		);
190
+		$identifier = $this->setIdentifier($entity, $identifier);
191
+		if ($this->collection->has($identifier)) {
192
+			do_action(
193
+				'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
194
+				$this,
195
+				$this->collection_details->collectionName(),
196
+				$this->collection_details
197
+			);
198
+			return CollectionLoader::ENTITY_EXISTS;
199
+		}
200
+		if ($this->collection->add($entity, $identifier)) {
201
+			do_action(
202
+				'FHEE__CollectionLoader__addEntityToCollection__entity_added',
203
+				$this,
204
+				$this->collection_details->collectionName(),
205
+				$this->collection_details
206
+			);
207
+			return CollectionLoader::ENTITY_ADDED;
208
+		}
209
+		do_action(
210
+			'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
211
+			$this,
212
+			$this->collection_details->collectionName(),
213
+			$this->collection_details
214
+		);
215
+		return CollectionLoader::ENTITY_NOT_ADDED;
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * @param        $entity
221
-     * @param  mixed $identifier
222
-     * @return string
223
-     * @throws InvalidEntityException
224
-     */
225
-    protected function setIdentifier($entity, $identifier)
226
-    {
227
-        switch ($this->collection_details->identifierType()) {
228
-            // every unique object gets added to the collection, but not duplicates of the exact same object
229
-            case CollectionDetails::ID_OBJECT_HASH:
230
-                $identifier = spl_object_hash($entity);
231
-                break;
232
-            // only one entity per class can be added to collection, like a singleton
233
-            case CollectionDetails::ID_CLASS_NAME:
234
-                $identifier = get_class($entity);
235
-                break;
236
-            // objects added to the collection based on entity callback, so the entity itself decides
237
-            case CollectionDetails::ID_CALLBACK_METHOD:
238
-                $identifier_callback = $this->collection_details->identifierCallback();
239
-                if (! method_exists($entity, $identifier_callback)) {
240
-                    throw new InvalidEntityException(
241
-                        $entity,
242
-                        $this->collection_details->getCollectionInterface(),
243
-                        sprintf(
244
-                            esc_html__(
245
-                                'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
219
+	/**
220
+	 * @param        $entity
221
+	 * @param  mixed $identifier
222
+	 * @return string
223
+	 * @throws InvalidEntityException
224
+	 */
225
+	protected function setIdentifier($entity, $identifier)
226
+	{
227
+		switch ($this->collection_details->identifierType()) {
228
+			// every unique object gets added to the collection, but not duplicates of the exact same object
229
+			case CollectionDetails::ID_OBJECT_HASH:
230
+				$identifier = spl_object_hash($entity);
231
+				break;
232
+			// only one entity per class can be added to collection, like a singleton
233
+			case CollectionDetails::ID_CLASS_NAME:
234
+				$identifier = get_class($entity);
235
+				break;
236
+			// objects added to the collection based on entity callback, so the entity itself decides
237
+			case CollectionDetails::ID_CALLBACK_METHOD:
238
+				$identifier_callback = $this->collection_details->identifierCallback();
239
+				if (! method_exists($entity, $identifier_callback)) {
240
+					throw new InvalidEntityException(
241
+						$entity,
242
+						$this->collection_details->getCollectionInterface(),
243
+						sprintf(
244
+							esc_html__(
245
+								'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
246 246
                                 of "%2$s", but does not contain this method.',
247
-                                'event_espresso'
248
-                            ),
249
-                            $identifier_callback,
250
-                            get_class($entity)
251
-                        )
252
-                    );
253
-                }
254
-                $identifier = $entity->{$identifier_callback}();
255
-                break;
256
-        }
257
-        return apply_filters(
258
-            'FHEE__CollectionLoader__addEntityToCollection__identifier',
259
-            $identifier,
260
-            $this->collection_details->collectionName(),
261
-            $this->collection_details
262
-        );
263
-    }
247
+								'event_espresso'
248
+							),
249
+							$identifier_callback,
250
+							get_class($entity)
251
+						)
252
+					);
253
+				}
254
+				$identifier = $entity->{$identifier_callback}();
255
+				break;
256
+		}
257
+		return apply_filters(
258
+			'FHEE__CollectionLoader__addEntityToCollection__identifier',
259
+			$identifier,
260
+			$this->collection_details->collectionName(),
261
+			$this->collection_details
262
+		);
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * @throws ReflectionException
268
-     * @throws InvalidArgumentException
269
-     * @throws InvalidInterfaceException
270
-     * @throws EE_Error
271
-     * @throws InvalidClassException
272
-     * @throws InvalidDataTypeException
273
-     * @throws InvalidEntityException
274
-     * @throws DuplicateCollectionIdentifierException
275
-     */
276
-    protected function loadFromFQCNs()
277
-    {
278
-        $FQCNs = $this->collection_details->getCollectionFQCNs();
279
-        $FQCNs = (array) apply_filters(
280
-            'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
281
-            $FQCNs,
282
-            $this->collection_details->collectionName(),
283
-            $this->collection_details
284
-        );
285
-        foreach ($FQCNs as $FQCN) {
286
-            $this->loadClassFromFQCN($FQCN);
287
-        }
288
-    }
266
+	/**
267
+	 * @throws ReflectionException
268
+	 * @throws InvalidArgumentException
269
+	 * @throws InvalidInterfaceException
270
+	 * @throws EE_Error
271
+	 * @throws InvalidClassException
272
+	 * @throws InvalidDataTypeException
273
+	 * @throws InvalidEntityException
274
+	 * @throws DuplicateCollectionIdentifierException
275
+	 */
276
+	protected function loadFromFQCNs()
277
+	{
278
+		$FQCNs = $this->collection_details->getCollectionFQCNs();
279
+		$FQCNs = (array) apply_filters(
280
+			'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
281
+			$FQCNs,
282
+			$this->collection_details->collectionName(),
283
+			$this->collection_details
284
+		);
285
+		foreach ($FQCNs as $FQCN) {
286
+			$this->loadClassFromFQCN($FQCN);
287
+		}
288
+	}
289 289
 
290 290
 
291
-    /**
292
-     * @param  string $FQCN Fully Qualified Class Name
293
-     * @return string
294
-     * @throws InvalidArgumentException
295
-     * @throws InvalidInterfaceException
296
-     * @throws ReflectionException
297
-     * @throws EE_Error
298
-     * @throws InvalidEntityException
299
-     * @throws InvalidDataTypeException
300
-     * @throws InvalidClassException
301
-     * @throws DuplicateCollectionIdentifierException
302
-     */
303
-    protected function loadClassFromFQCN($FQCN)
304
-    {
305
-        if (! is_string($FQCN)) {
306
-            throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
307
-        }
308
-        if (! class_exists($FQCN)) {
309
-            throw new InvalidClassException($FQCN);
310
-        }
311
-        do_action(
312
-            'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
313
-            $FQCN,
314
-            $this->collection_details->collectionName(),
315
-            $this->collection_details
316
-        );
317
-        $entity = $this->entity_factory instanceof FactoryInterface
318
-            ? call_user_func(array($this->entity_factory, 'create'), $FQCN)
319
-            : EE_Registry::instance()->create($FQCN);
320
-        return $this->addEntityToCollection($entity, $FQCN);
321
-    }
291
+	/**
292
+	 * @param  string $FQCN Fully Qualified Class Name
293
+	 * @return string
294
+	 * @throws InvalidArgumentException
295
+	 * @throws InvalidInterfaceException
296
+	 * @throws ReflectionException
297
+	 * @throws EE_Error
298
+	 * @throws InvalidEntityException
299
+	 * @throws InvalidDataTypeException
300
+	 * @throws InvalidClassException
301
+	 * @throws DuplicateCollectionIdentifierException
302
+	 */
303
+	protected function loadClassFromFQCN($FQCN)
304
+	{
305
+		if (! is_string($FQCN)) {
306
+			throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
307
+		}
308
+		if (! class_exists($FQCN)) {
309
+			throw new InvalidClassException($FQCN);
310
+		}
311
+		do_action(
312
+			'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
313
+			$FQCN,
314
+			$this->collection_details->collectionName(),
315
+			$this->collection_details
316
+		);
317
+		$entity = $this->entity_factory instanceof FactoryInterface
318
+			? call_user_func(array($this->entity_factory, 'create'), $FQCN)
319
+			: EE_Registry::instance()->create($FQCN);
320
+		return $this->addEntityToCollection($entity, $FQCN);
321
+	}
322 322
 }
Please login to merge, or discard this patch.
core/services/session/SessionStartHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
         // If not, then attempt to deal with any errors,
101 101
         // otherwise, try to hobble along without the session
102
-        if (! $this->handleSessionSaveHandlerErrors()) {
102
+        if ( ! $this->handleSessionSaveHandlerErrors()) {
103 103
             return;
104 104
         }
105 105
         // there is no record of a fatal error while trying to start the session
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                     ),
250 250
                     '<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
251 251
                     '</a>',
252
-                    '<a href="' . $retry_session_url . '">'
252
+                    '<a href="'.$retry_session_url.'">'
253 253
                 ),
254 254
                 __FILE__,
255 255
                 __FUNCTION__,
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -27,237 +27,237 @@
 block discarded – undo
27 27
  */
28 28
 class SessionStartHandler
29 29
 {
30
-    const OPTION_NAME_SESSION_SAVE_HANDLER_STATUS = 'ee_session_save_handler_status';
31
-    const REQUEST_PARAM_RETRY_SESSION = 'ee_retry_session';
32
-    const SESSION_SAVE_HANDLER_STATUS_FAILED = 'session_save_handler_failed';
33
-    const SESSION_SAVE_HANDLER_STATUS_SUCCESS = 'session_save_handler_success';
34
-    const SESSION_SAVE_HANDLER_STATUS_UNKNOWN = 'session_save_handler_untested';
30
+	const OPTION_NAME_SESSION_SAVE_HANDLER_STATUS = 'ee_session_save_handler_status';
31
+	const REQUEST_PARAM_RETRY_SESSION = 'ee_retry_session';
32
+	const SESSION_SAVE_HANDLER_STATUS_FAILED = 'session_save_handler_failed';
33
+	const SESSION_SAVE_HANDLER_STATUS_SUCCESS = 'session_save_handler_success';
34
+	const SESSION_SAVE_HANDLER_STATUS_UNKNOWN = 'session_save_handler_untested';
35 35
 
36
-    /**
37
-     * @var RequestInterface $request
38
-     */
39
-    protected $request;
36
+	/**
37
+	 * @var RequestInterface $request
38
+	 */
39
+	protected $request;
40 40
 
41
-    /**
42
-     * StartSession constructor.
43
-     *
44
-     * @param RequestInterface $request
45
-     */
46
-    public function __construct(RequestInterface $request)
47
-    {
48
-        $this->request = $request;
49
-    }
41
+	/**
42
+	 * StartSession constructor.
43
+	 *
44
+	 * @param RequestInterface $request
45
+	 */
46
+	public function __construct(RequestInterface $request)
47
+	{
48
+		$this->request = $request;
49
+	}
50 50
 
51
-    /**
52
-     * Check if a custom session save handler is in play
53
-     * and attempt to start the PHP session
54
-     *
55
-     * @since 4.9.68.p
56
-     */
57
-    public function startSession()
58
-    {
59
-        // check that session has started
60
-        if (session_id() === '') {
61
-            // starts a new session if one doesn't already exist, or re-initiates an existing one
62
-            if ($this->hasKnownCustomSessionSaveHandler()) {
63
-                $this->checkCustomSessionSaveHandler();
64
-            } else {
65
-                session_start();
66
-                session_write_close();
67
-            }
68
-        }
69
-    }
51
+	/**
52
+	 * Check if a custom session save handler is in play
53
+	 * and attempt to start the PHP session
54
+	 *
55
+	 * @since 4.9.68.p
56
+	 */
57
+	public function startSession()
58
+	{
59
+		// check that session has started
60
+		if (session_id() === '') {
61
+			// starts a new session if one doesn't already exist, or re-initiates an existing one
62
+			if ($this->hasKnownCustomSessionSaveHandler()) {
63
+				$this->checkCustomSessionSaveHandler();
64
+			} else {
65
+				session_start();
66
+				session_write_close();
67
+			}
68
+		}
69
+	}
70 70
 
71
-    /**
72
-     * Returns `true` if the 'session.save_handler' ini setting matches a known custom handler
73
-     *
74
-     * @since 4.9.68.p
75
-     * @return bool
76
-     */
77
-    private function hasKnownCustomSessionSaveHandler()
78
-    {
79
-        return in_array(
80
-            ini_get('session.save_handler'),
81
-            array(
82
-                'user',
83
-            ),
84
-            true
85
-        );
86
-    }
71
+	/**
72
+	 * Returns `true` if the 'session.save_handler' ini setting matches a known custom handler
73
+	 *
74
+	 * @since 4.9.68.p
75
+	 * @return bool
76
+	 */
77
+	private function hasKnownCustomSessionSaveHandler()
78
+	{
79
+		return in_array(
80
+			ini_get('session.save_handler'),
81
+			array(
82
+				'user',
83
+			),
84
+			true
85
+		);
86
+	}
87 87
 
88
-    /**
89
-     * Attempt to start the PHP session when a custom Session Save Handler is known to be set.
90
-     *
91
-     * @since 4.9.68.p
92
-     */
93
-    private function checkCustomSessionSaveHandler()
94
-    {
95
-        // If we've already successfully tested the session save handler
96
-        // on a previous request then just start the session
97
-        if ($this->sessionSaveHandlerIsValid()) {
98
-            session_start();
99
-            session_write_close();
100
-            return;
101
-        }
102
-        // If not, then attempt to deal with any errors,
103
-        // otherwise, try to hobble along without the session
104
-        if (! $this->handleSessionSaveHandlerErrors()) {
105
-            return;
106
-        }
107
-        // there is no record of a fatal error while trying to start the session
108
-        // so let's see if there's a custom session save handler. Proceed with caution
109
-        $this->initializeSessionSaveHandlerStatus();
110
-        // hold your breath, the custom session save handler might cause a fatal here...
111
-        session_start();
112
-        session_write_close();
113
-        // phew! we made it! the custom session handler is a-ok
114
-        $this->setSessionSaveHandlerStatusToValid();
115
-    }
88
+	/**
89
+	 * Attempt to start the PHP session when a custom Session Save Handler is known to be set.
90
+	 *
91
+	 * @since 4.9.68.p
92
+	 */
93
+	private function checkCustomSessionSaveHandler()
94
+	{
95
+		// If we've already successfully tested the session save handler
96
+		// on a previous request then just start the session
97
+		if ($this->sessionSaveHandlerIsValid()) {
98
+			session_start();
99
+			session_write_close();
100
+			return;
101
+		}
102
+		// If not, then attempt to deal with any errors,
103
+		// otherwise, try to hobble along without the session
104
+		if (! $this->handleSessionSaveHandlerErrors()) {
105
+			return;
106
+		}
107
+		// there is no record of a fatal error while trying to start the session
108
+		// so let's see if there's a custom session save handler. Proceed with caution
109
+		$this->initializeSessionSaveHandlerStatus();
110
+		// hold your breath, the custom session save handler might cause a fatal here...
111
+		session_start();
112
+		session_write_close();
113
+		// phew! we made it! the custom session handler is a-ok
114
+		$this->setSessionSaveHandlerStatusToValid();
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * retrieves the value for the 'ee_session_save_handler_status' WP option.
120
-     * default value = 'session_save_handler_untested'
121
-     *
122
-     * @since 4.9.68.p
123
-     * @return string
124
-     */
125
-    private function getSessionSaveHandlerStatus()
126
-    {
127
-        return get_option(
128
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
129
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
130
-        );
131
-    }
118
+	/**
119
+	 * retrieves the value for the 'ee_session_save_handler_status' WP option.
120
+	 * default value = 'session_save_handler_untested'
121
+	 *
122
+	 * @since 4.9.68.p
123
+	 * @return string
124
+	 */
125
+	private function getSessionSaveHandlerStatus()
126
+	{
127
+		return get_option(
128
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
129
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
130
+		);
131
+	}
132 132
 
133
-    /**
134
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_failed'
135
-     * which can then be upgraded is everything works correctly
136
-     *
137
-     * @since 4.9.68.p
138
-     * @return bool
139
-     */
140
-    private function initializeSessionSaveHandlerStatus()
141
-    {
142
-        return update_option(
143
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
144
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED
145
-        );
146
-    }
133
+	/**
134
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_failed'
135
+	 * which can then be upgraded is everything works correctly
136
+	 *
137
+	 * @since 4.9.68.p
138
+	 * @return bool
139
+	 */
140
+	private function initializeSessionSaveHandlerStatus()
141
+	{
142
+		return update_option(
143
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
144
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED
145
+		);
146
+	}
147 147
 
148
-    /**
149
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_success'
150
-     *
151
-     * @since 4.9.68.p
152
-     * @return bool
153
-     */
154
-    private function setSessionSaveHandlerStatusToValid()
155
-    {
156
-        return update_option(
157
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
158
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS
159
-        );
160
-    }
148
+	/**
149
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_success'
150
+	 *
151
+	 * @since 4.9.68.p
152
+	 * @return bool
153
+	 */
154
+	private function setSessionSaveHandlerStatusToValid()
155
+	{
156
+		return update_option(
157
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
158
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS
159
+		);
160
+	}
161 161
 
162
-    /**
163
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_untested'
164
-     *
165
-     * @since 4.9.68.p
166
-     * @return bool
167
-     */
168
-    private function resetSessionSaveHandlerStatus()
169
-    {
170
-        return update_option(
171
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
172
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
173
-        );
174
-    }
162
+	/**
163
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_untested'
164
+	 *
165
+	 * @since 4.9.68.p
166
+	 * @return bool
167
+	 */
168
+	private function resetSessionSaveHandlerStatus()
169
+	{
170
+		return update_option(
171
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
172
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
173
+		);
174
+	}
175 175
 
176
-    /**
177
-     * Returns `true` if the 'ee_session_save_handler_status' WP option value
178
-     * is equal to 'session_save_handler_success'
179
-     *
180
-     * @since 4.9.68.p
181
-     * @return bool
182
-     */
183
-    private function sessionSaveHandlerIsValid()
184
-    {
185
-        return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS;
186
-    }
176
+	/**
177
+	 * Returns `true` if the 'ee_session_save_handler_status' WP option value
178
+	 * is equal to 'session_save_handler_success'
179
+	 *
180
+	 * @since 4.9.68.p
181
+	 * @return bool
182
+	 */
183
+	private function sessionSaveHandlerIsValid()
184
+	{
185
+		return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS;
186
+	}
187 187
 
188
-    /**
189
-     * Returns `true` if the 'ee_session_save_handler_status' WP option value
190
-     * is equal to 'session_save_handler_failed'
191
-     *
192
-     * @since 4.9.68.p
193
-     * @return bool
194
-     */
195
-    private function sessionSaveHandlerFailed()
196
-    {
197
-        return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED;
198
-    }
188
+	/**
189
+	 * Returns `true` if the 'ee_session_save_handler_status' WP option value
190
+	 * is equal to 'session_save_handler_failed'
191
+	 *
192
+	 * @since 4.9.68.p
193
+	 * @return bool
194
+	 */
195
+	private function sessionSaveHandlerFailed()
196
+	{
197
+		return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED;
198
+	}
199 199
 
200
-    /**
201
-     * Returns `true` if no errors were detected with the session save handler,
202
-     * otherwise attempts to work notify the appropriate authorities
203
-     * with a suggestion for how to fix the issue, and returns `false`.
204
-     *
205
-     *
206
-     * @since 4.9.68.p
207
-     * @return bool
208
-     */
209
-    private function handleSessionSaveHandlerErrors()
210
-    {
211
-        // Check if we had a fatal error last time while trying to start the session
212
-        if ($this->sessionSaveHandlerFailed()) {
213
-            // apparently, last time we tried using the custom session save handler there was a fatal
214
-            if ($this->request->requestParamIsSet(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION)) {
215
-                $this->resetSessionSaveHandlerStatus();
216
-                // remove "ee_retry_session", otherwise if the problem still isn't fixed,
217
-                // we'll just keep getting the fatal error over and over.
218
-                // Better to remove it and redirect, and try on the next request
219
-                EEH_URL::safeRedirectAndExit(
220
-                    remove_query_arg(
221
-                        array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION),
222
-                        EEH_URL::current_url()
223
-                    )
224
-                );
225
-            }
226
-            // so the session is broken, don't try it again,
227
-            // just show a message to users that can fix it
228
-            $this->displaySessionSaveHandlerErrorNotice();
229
-            return false;
230
-        }
231
-        return true;
232
-    }
200
+	/**
201
+	 * Returns `true` if no errors were detected with the session save handler,
202
+	 * otherwise attempts to work notify the appropriate authorities
203
+	 * with a suggestion for how to fix the issue, and returns `false`.
204
+	 *
205
+	 *
206
+	 * @since 4.9.68.p
207
+	 * @return bool
208
+	 */
209
+	private function handleSessionSaveHandlerErrors()
210
+	{
211
+		// Check if we had a fatal error last time while trying to start the session
212
+		if ($this->sessionSaveHandlerFailed()) {
213
+			// apparently, last time we tried using the custom session save handler there was a fatal
214
+			if ($this->request->requestParamIsSet(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION)) {
215
+				$this->resetSessionSaveHandlerStatus();
216
+				// remove "ee_retry_session", otherwise if the problem still isn't fixed,
217
+				// we'll just keep getting the fatal error over and over.
218
+				// Better to remove it and redirect, and try on the next request
219
+				EEH_URL::safeRedirectAndExit(
220
+					remove_query_arg(
221
+						array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION),
222
+						EEH_URL::current_url()
223
+					)
224
+				);
225
+			}
226
+			// so the session is broken, don't try it again,
227
+			// just show a message to users that can fix it
228
+			$this->displaySessionSaveHandlerErrorNotice();
229
+			return false;
230
+		}
231
+		return true;
232
+	}
233 233
 
234
-    /**
235
-     * Generates an EE_Error notice regarding the current session woes
236
-     * but only if the current user is an admin with permission to 'install_plugins'.
237
-     *
238
-     * @since 4.9.68.p
239
-     */
240
-    private function displaySessionSaveHandlerErrorNotice()
241
-    {
242
-        if (current_user_can('install_plugins')) {
243
-            $retry_session_url = add_query_arg(
244
-                array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION => true),
245
-                EEH_URL::current_url()
246
-            );
247
-            EE_Error::add_error(
248
-                sprintf(
249
-                    esc_html__(
250
-                        'It appears there was a fatal error while starting the session, so Event Espresso is not able to process registrations normally. Some hosting companies, like Pantheon, require an extra plugin for Event Espresso to work. Please install the %1$sWordPress Native PHP Sessions plugin%2$s, then %3$sclick here to check if the problem is resolved.%2$s',
251
-                        'event_espresso'
252
-                    ),
253
-                    '<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
254
-                    '</a>',
255
-                    '<a href="' . $retry_session_url . '">'
256
-                ),
257
-                __FILE__,
258
-                __FUNCTION__,
259
-                __LINE__
260
-            );
261
-        }
262
-    }
234
+	/**
235
+	 * Generates an EE_Error notice regarding the current session woes
236
+	 * but only if the current user is an admin with permission to 'install_plugins'.
237
+	 *
238
+	 * @since 4.9.68.p
239
+	 */
240
+	private function displaySessionSaveHandlerErrorNotice()
241
+	{
242
+		if (current_user_can('install_plugins')) {
243
+			$retry_session_url = add_query_arg(
244
+				array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION => true),
245
+				EEH_URL::current_url()
246
+			);
247
+			EE_Error::add_error(
248
+				sprintf(
249
+					esc_html__(
250
+						'It appears there was a fatal error while starting the session, so Event Espresso is not able to process registrations normally. Some hosting companies, like Pantheon, require an extra plugin for Event Espresso to work. Please install the %1$sWordPress Native PHP Sessions plugin%2$s, then %3$sclick here to check if the problem is resolved.%2$s',
251
+						'event_espresso'
252
+					),
253
+					'<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
254
+					'</a>',
255
+					'<a href="' . $retry_session_url . '">'
256
+				),
257
+				__FILE__,
258
+				__FUNCTION__,
259
+				__LINE__
260
+			);
261
+		}
262
+	}
263 263
 }
Please login to merge, or discard this patch.
core/services/dependencies/ClassAlias.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      */
35 35
     public function __construct($alias, $fqcn)
36 36
     {
37
-        if (! is_subclass_of($fqcn, $alias)) {
37
+        if ( ! is_subclass_of($fqcn, $alias)) {
38 38
             throw new InvalidAliasException($fqcn, $alias);
39 39
         }
40 40
         $this->alias = $alias;
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,46 +16,46 @@
 block discarded – undo
16 16
  */
17 17
 class ClassAlias
18 18
 {
19
-    /**
20
-     * @var string $alias   an interface or base class representing what object
21
-     *                      can be utilized by another object and/or function
22
-     */
23
-    private $alias;
19
+	/**
20
+	 * @var string $alias   an interface or base class representing what object
21
+	 *                      can be utilized by another object and/or function
22
+	 */
23
+	private $alias;
24 24
 
25
-    /**
26
-     * @var string $fqcn the actual class that should be substituted for the alias above
27
-     */
28
-    private $fqcn;
25
+	/**
26
+	 * @var string $fqcn the actual class that should be substituted for the alias above
27
+	 */
28
+	private $fqcn;
29 29
 
30
-    /**
31
-     * ClassAlias constructor.
32
-     *
33
-     * @param string $alias Interface specified by implementing class
34
-     * @param string $fqcn  Concrete class that satisfies interface
35
-     * @throws InvalidAliasException
36
-     */
37
-    public function __construct($alias, $fqcn)
38
-    {
39
-        if (! is_subclass_of($fqcn, $alias)) {
40
-            throw new InvalidAliasException($fqcn, $alias);
41
-        }
42
-        $this->alias = $alias;
43
-        $this->fqcn = $fqcn;
44
-    }
30
+	/**
31
+	 * ClassAlias constructor.
32
+	 *
33
+	 * @param string $alias Interface specified by implementing class
34
+	 * @param string $fqcn  Concrete class that satisfies interface
35
+	 * @throws InvalidAliasException
36
+	 */
37
+	public function __construct($alias, $fqcn)
38
+	{
39
+		if (! is_subclass_of($fqcn, $alias)) {
40
+			throw new InvalidAliasException($fqcn, $alias);
41
+		}
42
+		$this->alias = $alias;
43
+		$this->fqcn = $fqcn;
44
+	}
45 45
 
46
-    /**
47
-     * @return string
48
-     */
49
-    public function alias()
50
-    {
51
-        return $this->alias;
52
-    }
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function alias()
50
+	{
51
+		return $this->alias;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function fqcn()
58
-    {
59
-        return $this->fqcn;
60
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function fqcn()
58
+	{
59
+		return $this->fqcn;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
core/services/factory/FactoryWithDependencyResolver.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
  */
19 19
 abstract class FactoryWithDependencyResolver implements FactoryInterface
20 20
 {
21
-    /**
22
-     * @var DependencyResolverInterface $dependency_resolver
23
-     */
24
-    private $dependency_resolver;
21
+	/**
22
+	 * @var DependencyResolverInterface $dependency_resolver
23
+	 */
24
+	private $dependency_resolver;
25 25
 
26
-    /**
27
-     * @var LoaderInterface $loader
28
-     */
29
-    private $loader;
26
+	/**
27
+	 * @var LoaderInterface $loader
28
+	 */
29
+	private $loader;
30 30
 
31
-    /**
32
-     * FactoryWithDependencyResolver constructor.
33
-     *
34
-     * @param DependencyResolverInterface $dependency_resolver
35
-     * @param LoaderInterface             $loader
36
-     */
37
-    public function __construct(DependencyResolverInterface $dependency_resolver, LoaderInterface $loader)
38
-    {
39
-        $this->dependency_resolver = $dependency_resolver;
40
-        $this->loader = $loader;
41
-    }
31
+	/**
32
+	 * FactoryWithDependencyResolver constructor.
33
+	 *
34
+	 * @param DependencyResolverInterface $dependency_resolver
35
+	 * @param LoaderInterface             $loader
36
+	 */
37
+	public function __construct(DependencyResolverInterface $dependency_resolver, LoaderInterface $loader)
38
+	{
39
+		$this->dependency_resolver = $dependency_resolver;
40
+		$this->loader = $loader;
41
+	}
42 42
 
43
-    /**
44
-     * @return DependencyResolverInterface
45
-     */
46
-    public function dependencyResolver()
47
-    {
48
-        return $this->dependency_resolver;
49
-    }
43
+	/**
44
+	 * @return DependencyResolverInterface
45
+	 */
46
+	public function dependencyResolver()
47
+	{
48
+		return $this->dependency_resolver;
49
+	}
50 50
 
51
-    /**
52
-     * @return LoaderInterface
53
-     */
54
-    public function loader()
55
-    {
56
-        return $this->loader;
57
-    }
51
+	/**
52
+	 * @return LoaderInterface
53
+	 */
54
+	public function loader()
55
+	{
56
+		return $this->loader;
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/domain/services/pue/Config.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,131 +16,131 @@
 block discarded – undo
16 16
  */
17 17
 class Config
18 18
 {
19
-    /**
20
-     * @var EE_Network_Config
21
-     */
22
-    private $network_config;
23
-
24
-
25
-    /**
26
-     * @var EE_Config
27
-     */
28
-    private $ee_config;
29
-
30
-
31
-    public function __construct(EE_Network_Config $network_config, EE_Config $ee_config)
32
-    {
33
-        $this->network_config = $network_config;
34
-        $this->ee_config = $ee_config;
35
-    }
36
-
37
-
38
-    /**
39
-     * Get the site license key for the site.
40
-     */
41
-    public function siteLicenseKey()
42
-    {
43
-        return $this->network_config->core->site_license_key;
44
-    }
45
-
46
-
47
-    public function i18nDomain()
48
-    {
49
-        return 'event_espresso';
50
-    }
51
-
52
-
53
-    public function checkPeriod()
54
-    {
55
-        return 24;
56
-    }
57
-
58
-
59
-    public function optionKey()
60
-    {
61
-        return 'ee_site_license_key';
62
-    }
63
-
64
-
65
-    public function optionsPageSlug()
66
-    {
67
-        return 'espresso_general_settings';
68
-    }
69
-
70
-
71
-    public function hostServerUrl()
72
-    {
73
-        return defined('PUE_UPDATES_ENDPOINT')
74
-            ? PUE_UPDATES_ENDPOINT
75
-            : 'https://eventespresso.com';
76
-    }
77
-
78
-
79
-    public function pluginSlug()
80
-    {
81
-        // Note: PUE uses a simple preg_match to determine what type is currently installed based on version number.
82
-        //  So it's important that you use a key for the version type that is unique and not found in another key.
83
-        // For example:
84
-        // $plugin_slug['premium']['p'] = 'some-premium-slug';
85
-        // $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug';
86
-        // The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr )
87
-        // so doing something like:
88
-        // $plugin_slug['premium']['p'] = 'some-premium-slug';
89
-        // $plugin_slug['prerelease']['b'] = 'some-pre-release-slug';
90
-        // ..WOULD work!
91
-        return array(
92
-            'free'       => array('decaf' => 'event-espresso-core-decaf'),
93
-            'premium'    => array('p' => 'event-espresso-core-reg'),
94
-            'prerelease' => array('beta' => 'event-espresso-core-pr'),
95
-        );
96
-    }
97
-
98
-
99
-    /**
100
-     * Return whether the site is opted in for UXIP or not.
101
-     *
102
-     * @return bool
103
-     */
104
-    public function isOptedInForUxip()
105
-    {
106
-        return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN);
107
-    }
108
-
109
-
110
-    /**
111
-     * Return whether the site has been notified about UXIP or not.
112
-     *
113
-     * @return bool
114
-     */
115
-    public function hasNotifiedForUxip()
116
-    {
117
-        return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN);
118
-    }
119
-
120
-
121
-    /**
122
-     * Set the site opted in for UXIP.
123
-     */
124
-    public function setHasOptedInForUxip()
125
-    {
126
-        $this->ee_config->core->ee_ueip_optin = true;
127
-        $this->ee_config->update_espresso_config(false, false);
128
-    }
129
-
130
-
131
-    /**
132
-     * Set the site opted out for UXIP
133
-     */
134
-    public function setHasOptedOutForUxip()
135
-    {
136
-        $this->ee_config->core->ee_ueip_optin = false;
137
-        $this->ee_config->update_espresso_config(false, false);
138
-    }
139
-
140
-
141
-    public function setHasNotifiedAboutUxip()
142
-    {
143
-        $this->ee_config->core->ee_ueip_has_notified = true;
144
-        $this->ee_config->update_espresso_config(false, false);
145
-    }
19
+	/**
20
+	 * @var EE_Network_Config
21
+	 */
22
+	private $network_config;
23
+
24
+
25
+	/**
26
+	 * @var EE_Config
27
+	 */
28
+	private $ee_config;
29
+
30
+
31
+	public function __construct(EE_Network_Config $network_config, EE_Config $ee_config)
32
+	{
33
+		$this->network_config = $network_config;
34
+		$this->ee_config = $ee_config;
35
+	}
36
+
37
+
38
+	/**
39
+	 * Get the site license key for the site.
40
+	 */
41
+	public function siteLicenseKey()
42
+	{
43
+		return $this->network_config->core->site_license_key;
44
+	}
45
+
46
+
47
+	public function i18nDomain()
48
+	{
49
+		return 'event_espresso';
50
+	}
51
+
52
+
53
+	public function checkPeriod()
54
+	{
55
+		return 24;
56
+	}
57
+
58
+
59
+	public function optionKey()
60
+	{
61
+		return 'ee_site_license_key';
62
+	}
63
+
64
+
65
+	public function optionsPageSlug()
66
+	{
67
+		return 'espresso_general_settings';
68
+	}
69
+
70
+
71
+	public function hostServerUrl()
72
+	{
73
+		return defined('PUE_UPDATES_ENDPOINT')
74
+			? PUE_UPDATES_ENDPOINT
75
+			: 'https://eventespresso.com';
76
+	}
77
+
78
+
79
+	public function pluginSlug()
80
+	{
81
+		// Note: PUE uses a simple preg_match to determine what type is currently installed based on version number.
82
+		//  So it's important that you use a key for the version type that is unique and not found in another key.
83
+		// For example:
84
+		// $plugin_slug['premium']['p'] = 'some-premium-slug';
85
+		// $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug';
86
+		// The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr )
87
+		// so doing something like:
88
+		// $plugin_slug['premium']['p'] = 'some-premium-slug';
89
+		// $plugin_slug['prerelease']['b'] = 'some-pre-release-slug';
90
+		// ..WOULD work!
91
+		return array(
92
+			'free'       => array('decaf' => 'event-espresso-core-decaf'),
93
+			'premium'    => array('p' => 'event-espresso-core-reg'),
94
+			'prerelease' => array('beta' => 'event-espresso-core-pr'),
95
+		);
96
+	}
97
+
98
+
99
+	/**
100
+	 * Return whether the site is opted in for UXIP or not.
101
+	 *
102
+	 * @return bool
103
+	 */
104
+	public function isOptedInForUxip()
105
+	{
106
+		return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN);
107
+	}
108
+
109
+
110
+	/**
111
+	 * Return whether the site has been notified about UXIP or not.
112
+	 *
113
+	 * @return bool
114
+	 */
115
+	public function hasNotifiedForUxip()
116
+	{
117
+		return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN);
118
+	}
119
+
120
+
121
+	/**
122
+	 * Set the site opted in for UXIP.
123
+	 */
124
+	public function setHasOptedInForUxip()
125
+	{
126
+		$this->ee_config->core->ee_ueip_optin = true;
127
+		$this->ee_config->update_espresso_config(false, false);
128
+	}
129
+
130
+
131
+	/**
132
+	 * Set the site opted out for UXIP
133
+	 */
134
+	public function setHasOptedOutForUxip()
135
+	{
136
+		$this->ee_config->core->ee_ueip_optin = false;
137
+		$this->ee_config->update_espresso_config(false, false);
138
+	}
139
+
140
+
141
+	public function setHasNotifiedAboutUxip()
142
+	{
143
+		$this->ee_config->core->ee_ueip_has_notified = true;
144
+		$this->ee_config->update_espresso_config(false, false);
145
+	}
146 146
 }
Please login to merge, or discard this patch.
core/entities/models/JsonModelSchema.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
     public function getModelSchemaForFields(array $model_fields, array $schema)
77 77
     {
78 78
         foreach ($model_fields as $field => $model_field) {
79
-            if (! $model_field instanceof EE_Model_Field_Base) {
79
+            if ( ! $model_field instanceof EE_Model_Field_Base) {
80 80
                 continue;
81 81
             }
82
-            $schema['properties'][ $field ] = $model_field->getSchema();
82
+            $schema['properties'][$field] = $model_field->getSchema();
83 83
 
84 84
             // if this is a primary key field add the primary key item
85 85
             if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
-                $schema['properties'][ $field ]['primary_key'] = true;
86
+                $schema['properties'][$field]['primary_key'] = true;
87 87
                 if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
-                    $schema['properties'][ $field ]['readonly'] = true;
88
+                    $schema['properties'][$field]['readonly'] = true;
89 89
                 }
90 90
             }
91 91
 
92 92
             // if this is a foreign key field add the foreign key item
93 93
             if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
-                $schema['properties'][ $field ]['foreign_key'] = array(
94
+                $schema['properties'][$field]['foreign_key'] = array(
95 95
                     'description' => esc_html__(
96 96
                         'This is a foreign key the points to the given models.',
97 97
                         'event_espresso'
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
     public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116 116
     {
117 117
         foreach ($relations_on_model as $model_name => $relation) {
118
-            if (! $relation instanceof EE_Model_Relation_Base) {
118
+            if ( ! $relation instanceof EE_Model_Relation_Base) {
119 119
                 continue;
120 120
             }
121 121
             $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122 122
                 ? strtolower($model_name)
123 123
                 : EEH_Inflector::pluralize_and_lower($model_name);
124
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
124
+            $schema['properties'][$model_name_for_schema] = $relation->getSchema();
125
+            $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name;
126 126
 
127 127
             // links schema
128
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
128
+            $links_key = 'https://api.eventespresso.com/'.strtolower($model_name);
129
+            $schema['properties']['_links']['properties'][$links_key] = array(
130 130
                 'description' => esc_html__(
131 131
                     'Array of objects describing the link(s) for this relation resource.',
132 132
                     'event_espresso'
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -24,256 +24,256 @@
 block discarded – undo
24 24
  */
25 25
 class JsonModelSchema
26 26
 {
27
-    /**
28
-     * @var EEM_Base
29
-     */
30
-    protected $model;
27
+	/**
28
+	 * @var EEM_Base
29
+	 */
30
+	protected $model;
31 31
 
32
-    /**
33
-     * @var CalculatedModelFields
34
-     */
35
-    protected $fields_calculator;
32
+	/**
33
+	 * @var CalculatedModelFields
34
+	 */
35
+	protected $fields_calculator;
36 36
 
37 37
 
38
-    /**
39
-     * JsonModelSchema constructor.
40
-     *
41
-     * @param EEM_Base              $model
42
-     * @param CalculatedModelFields $fields_calculator
43
-     */
44
-    public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
45
-    {
46
-        $this->model = $model;
47
-        $this->fields_calculator = $fields_calculator;
48
-    }
38
+	/**
39
+	 * JsonModelSchema constructor.
40
+	 *
41
+	 * @param EEM_Base              $model
42
+	 * @param CalculatedModelFields $fields_calculator
43
+	 */
44
+	public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
45
+	{
46
+		$this->model = $model;
47
+		$this->fields_calculator = $fields_calculator;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Return the schema for a given model from a given model.
53
-     *
54
-     * @return array
55
-     */
56
-    public function getModelSchema()
57
-    {
58
-        return $this->getModelSchemaForRelations(
59
-            $this->model->relation_settings(),
60
-            $this->getModelSchemaForFields(
61
-                $this->model->field_settings(),
62
-                $this->getInitialSchemaStructure()
63
-            )
64
-        );
65
-    }
51
+	/**
52
+	 * Return the schema for a given model from a given model.
53
+	 *
54
+	 * @return array
55
+	 */
56
+	public function getModelSchema()
57
+	{
58
+		return $this->getModelSchemaForRelations(
59
+			$this->model->relation_settings(),
60
+			$this->getModelSchemaForFields(
61
+				$this->model->field_settings(),
62
+				$this->getInitialSchemaStructure()
63
+			)
64
+		);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Get the schema for a given set of model fields.
70
-     *
71
-     * @param EE_Model_Field_Base[] $model_fields
72
-     * @param array                  $schema
73
-     * @return array
74
-     */
75
-    public function getModelSchemaForFields(array $model_fields, array $schema)
76
-    {
77
-        foreach ($model_fields as $field => $model_field) {
78
-            if (! $model_field instanceof EE_Model_Field_Base) {
79
-                continue;
80
-            }
81
-            $schema['properties'][ $field ] = $model_field->getSchema();
68
+	/**
69
+	 * Get the schema for a given set of model fields.
70
+	 *
71
+	 * @param EE_Model_Field_Base[] $model_fields
72
+	 * @param array                  $schema
73
+	 * @return array
74
+	 */
75
+	public function getModelSchemaForFields(array $model_fields, array $schema)
76
+	{
77
+		foreach ($model_fields as $field => $model_field) {
78
+			if (! $model_field instanceof EE_Model_Field_Base) {
79
+				continue;
80
+			}
81
+			$schema['properties'][ $field ] = $model_field->getSchema();
82 82
 
83
-            // if this is a primary key field add the primary key item
84
-            if ($model_field instanceof EE_Primary_Key_Field_Base) {
85
-                $schema['properties'][ $field ]['primary_key'] = true;
86
-                if ($model_field instanceof EE_Primary_Key_Int_Field) {
87
-                    $schema['properties'][ $field ]['readonly'] = true;
88
-                }
89
-            }
83
+			// if this is a primary key field add the primary key item
84
+			if ($model_field instanceof EE_Primary_Key_Field_Base) {
85
+				$schema['properties'][ $field ]['primary_key'] = true;
86
+				if ($model_field instanceof EE_Primary_Key_Int_Field) {
87
+					$schema['properties'][ $field ]['readonly'] = true;
88
+				}
89
+			}
90 90
 
91
-            // if this is a foreign key field add the foreign key item
92
-            if ($model_field instanceof EE_Foreign_Key_Field_Base) {
93
-                $schema['properties'][ $field ]['foreign_key'] = array(
94
-                    'description' => esc_html__(
95
-                        'This is a foreign key the points to the given models.',
96
-                        'event_espresso'
97
-                    ),
98
-                    'type'        => 'array',
99
-                    'enum'        => $model_field->get_model_class_names_pointed_to(),
100
-                );
101
-            }
102
-        }
103
-        return $schema;
104
-    }
91
+			// if this is a foreign key field add the foreign key item
92
+			if ($model_field instanceof EE_Foreign_Key_Field_Base) {
93
+				$schema['properties'][ $field ]['foreign_key'] = array(
94
+					'description' => esc_html__(
95
+						'This is a foreign key the points to the given models.',
96
+						'event_espresso'
97
+					),
98
+					'type'        => 'array',
99
+					'enum'        => $model_field->get_model_class_names_pointed_to(),
100
+				);
101
+			}
102
+		}
103
+		return $schema;
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * Get the schema for a given set of model relations
109
-     *
110
-     * @param EE_Model_Relation_Base[] $relations_on_model
111
-     * @param array                    $schema
112
-     * @return array
113
-     */
114
-    public function getModelSchemaForRelations(array $relations_on_model, array $schema)
115
-    {
116
-        foreach ($relations_on_model as $model_name => $relation) {
117
-            if (! $relation instanceof EE_Model_Relation_Base) {
118
-                continue;
119
-            }
120
-            $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
121
-                ? strtolower($model_name)
122
-                : EEH_Inflector::pluralize_and_lower($model_name);
123
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
124
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
107
+	/**
108
+	 * Get the schema for a given set of model relations
109
+	 *
110
+	 * @param EE_Model_Relation_Base[] $relations_on_model
111
+	 * @param array                    $schema
112
+	 * @return array
113
+	 */
114
+	public function getModelSchemaForRelations(array $relations_on_model, array $schema)
115
+	{
116
+		foreach ($relations_on_model as $model_name => $relation) {
117
+			if (! $relation instanceof EE_Model_Relation_Base) {
118
+				continue;
119
+			}
120
+			$model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
121
+				? strtolower($model_name)
122
+				: EEH_Inflector::pluralize_and_lower($model_name);
123
+			$schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
124
+			$schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
125 125
 
126
-            // links schema
127
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
128
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
129
-                'description' => esc_html__(
130
-                    'Array of objects describing the link(s) for this relation resource.',
131
-                    'event_espresso'
132
-                ),
133
-                'type' => 'array',
134
-                'readonly' => true,
135
-                'items' => array(
136
-                    'type' => 'object',
137
-                    'properties' => array(
138
-                        'href' => array(
139
-                            'type' => 'string',
140
-                            'description' => sprintf(
141
-                                // translators: placeholder is the model name for the relation.
142
-                                esc_html__(
143
-                                    'The link to the resource for the %s relation(s) to this entity',
144
-                                    'event_espresso'
145
-                                ),
146
-                                $model_name
147
-                            ),
148
-                        ),
149
-                        'single' => array(
150
-                            'type' => 'boolean',
151
-                            'description' => sprintf(
152
-                                // translators: placeholder is the model name for the relation.
153
-                                esc_html__(
154
-                                    'Whether or not there is only a single %s relation to this entity',
155
-                                    'event_espresso'
156
-                                ),
157
-                                $model_name
158
-                            ),
159
-                        ),
160
-                    ),
161
-                    'additionalProperties' => false
162
-                ),
163
-            );
164
-        }
165
-        return $schema;
166
-    }
126
+			// links schema
127
+			$links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
128
+			$schema['properties']['_links']['properties'][ $links_key ] = array(
129
+				'description' => esc_html__(
130
+					'Array of objects describing the link(s) for this relation resource.',
131
+					'event_espresso'
132
+				),
133
+				'type' => 'array',
134
+				'readonly' => true,
135
+				'items' => array(
136
+					'type' => 'object',
137
+					'properties' => array(
138
+						'href' => array(
139
+							'type' => 'string',
140
+							'description' => sprintf(
141
+								// translators: placeholder is the model name for the relation.
142
+								esc_html__(
143
+									'The link to the resource for the %s relation(s) to this entity',
144
+									'event_espresso'
145
+								),
146
+								$model_name
147
+							),
148
+						),
149
+						'single' => array(
150
+							'type' => 'boolean',
151
+							'description' => sprintf(
152
+								// translators: placeholder is the model name for the relation.
153
+								esc_html__(
154
+									'Whether or not there is only a single %s relation to this entity',
155
+									'event_espresso'
156
+								),
157
+								$model_name
158
+							),
159
+						),
160
+					),
161
+					'additionalProperties' => false
162
+				),
163
+			);
164
+		}
165
+		return $schema;
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * Outputs the schema header for a model.
171
-     *
172
-     * @return array
173
-     */
174
-    public function getInitialSchemaStructure()
175
-    {
176
-        return array(
177
-            '$schema'    => 'http://json-schema.org/draft-04/schema#',
178
-            'title'      => $this->model->get_this_model_name(),
179
-            'type'       => 'object',
180
-            'properties' => array(
181
-                'link' => array(
182
-                    'description' => esc_html__(
183
-                        'Link to event on WordPress site hosting events.',
184
-                        'event_espresso'
185
-                    ),
186
-                    'type' => 'string',
187
-                    'readonly' => true,
188
-                ),
189
-                '_links' => array(
190
-                    'description' => esc_html__(
191
-                        'Various links for resources related to the entity.',
192
-                        'event_espresso'
193
-                    ),
194
-                    'type' => 'object',
195
-                    'readonly' => true,
196
-                    'properties' => array(
197
-                        'self' => array(
198
-                            'description' => esc_html__(
199
-                                'Link to this entities resource.',
200
-                                'event_espresso'
201
-                            ),
202
-                            'type' => 'array',
203
-                            'items' => array(
204
-                                'type' => 'object',
205
-                                'properties' => array(
206
-                                    'href' => array(
207
-                                        'type' => 'string',
208
-                                    ),
209
-                                ),
210
-                                'additionalProperties' => false
211
-                            ),
212
-                            'readonly' => true
213
-                        ),
214
-                        'collection' => array(
215
-                            'description' => esc_html__(
216
-                                'Link to this entities collection resource.',
217
-                                'event_espresso'
218
-                            ),
219
-                            'type' => 'array',
220
-                            'items' => array(
221
-                                'type' => 'object',
222
-                                'properties' => array(
223
-                                    'href' => array(
224
-                                        'type' => 'string'
225
-                                    ),
226
-                                ),
227
-                                'additionalProperties' => false
228
-                            ),
229
-                            'readonly' => true
230
-                        ),
231
-                    ),
232
-                    'additionalProperties' => false,
233
-                ),
234
-                '_calculated_fields' => array_merge(
235
-                    $this->fields_calculator->getJsonSchemaForModel($this->model),
236
-                    array(
237
-                        '_protected' => $this->getProtectedFieldsSchema()
238
-                    )
239
-                ),
240
-                '_protected' => $this->getProtectedFieldsSchema()
241
-            ),
242
-            'additionalProperties' => false,
243
-        );
244
-    }
169
+	/**
170
+	 * Outputs the schema header for a model.
171
+	 *
172
+	 * @return array
173
+	 */
174
+	public function getInitialSchemaStructure()
175
+	{
176
+		return array(
177
+			'$schema'    => 'http://json-schema.org/draft-04/schema#',
178
+			'title'      => $this->model->get_this_model_name(),
179
+			'type'       => 'object',
180
+			'properties' => array(
181
+				'link' => array(
182
+					'description' => esc_html__(
183
+						'Link to event on WordPress site hosting events.',
184
+						'event_espresso'
185
+					),
186
+					'type' => 'string',
187
+					'readonly' => true,
188
+				),
189
+				'_links' => array(
190
+					'description' => esc_html__(
191
+						'Various links for resources related to the entity.',
192
+						'event_espresso'
193
+					),
194
+					'type' => 'object',
195
+					'readonly' => true,
196
+					'properties' => array(
197
+						'self' => array(
198
+							'description' => esc_html__(
199
+								'Link to this entities resource.',
200
+								'event_espresso'
201
+							),
202
+							'type' => 'array',
203
+							'items' => array(
204
+								'type' => 'object',
205
+								'properties' => array(
206
+									'href' => array(
207
+										'type' => 'string',
208
+									),
209
+								),
210
+								'additionalProperties' => false
211
+							),
212
+							'readonly' => true
213
+						),
214
+						'collection' => array(
215
+							'description' => esc_html__(
216
+								'Link to this entities collection resource.',
217
+								'event_espresso'
218
+							),
219
+							'type' => 'array',
220
+							'items' => array(
221
+								'type' => 'object',
222
+								'properties' => array(
223
+									'href' => array(
224
+										'type' => 'string'
225
+									),
226
+								),
227
+								'additionalProperties' => false
228
+							),
229
+							'readonly' => true
230
+						),
231
+					),
232
+					'additionalProperties' => false,
233
+				),
234
+				'_calculated_fields' => array_merge(
235
+					$this->fields_calculator->getJsonSchemaForModel($this->model),
236
+					array(
237
+						'_protected' => $this->getProtectedFieldsSchema()
238
+					)
239
+				),
240
+				'_protected' => $this->getProtectedFieldsSchema()
241
+			),
242
+			'additionalProperties' => false,
243
+		);
244
+	}
245 245
 
246
-    /**
247
-     * Returns an array of JSON schema to describe the _protected property on responses
248
-     * @since 4.9.74.p
249
-     * @return array
250
-     */
251
-    protected function getProtectedFieldsSchema()
252
-    {
253
-        return array(
254
-            'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
255
-            'type' => 'array',
256
-            'items' => array(
257
-                'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
258
-                'type' => 'string',
259
-                'readonly' => true,
260
-            ),
261
-            'readonly' => true
262
-        );
263
-    }
246
+	/**
247
+	 * Returns an array of JSON schema to describe the _protected property on responses
248
+	 * @since 4.9.74.p
249
+	 * @return array
250
+	 */
251
+	protected function getProtectedFieldsSchema()
252
+	{
253
+		return array(
254
+			'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
255
+			'type' => 'array',
256
+			'items' => array(
257
+				'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
258
+				'type' => 'string',
259
+				'readonly' => true,
260
+			),
261
+			'readonly' => true
262
+		);
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * Allows one to just use the object as a string to get the json.
268
-     * eg.
269
-     * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
270
-     * // if echoed, would convert schema to a json formatted string.
271
-     *
272
-     * @return string
273
-     */
274
-    public function __toString()
275
-    {
276
-        $schema = wp_json_encode($this->getModelSchema());
277
-        return is_string($schema) ? $schema : '';
278
-    }
266
+	/**
267
+	 * Allows one to just use the object as a string to get the json.
268
+	 * eg.
269
+	 * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
270
+	 * // if echoed, would convert schema to a json formatted string.
271
+	 *
272
+	 * @return string
273
+	 */
274
+	public function __toString()
275
+	{
276
+		$schema = wp_json_encode($this->getModelSchema());
277
+		return is_string($schema) ? $schema : '';
278
+	}
279 279
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/CalculatedModelFieldsFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function createFromModel($model_name)
42 42
     {
43
-        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
43
+        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\'.$model_name);
44 44
     }
45 45
 
46 46
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function createFromClassname($calculator_classname)
52 52
     {
53 53
         $calculator = $this->loader->getShared($calculator_classname);
54
-        if (!$calculator instanceof Base) {
54
+        if ( ! $calculator instanceof Base) {
55 55
             throw new UnexpectedEntityException(
56 56
                 $calculator_classname,
57 57
                 'EventEspresso\core\libraries\rest_api\calculations\Base'
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
  */
19 19
 class CalculatedModelFieldsFactory
20 20
 {
21
-    private $loader;
21
+	private $loader;
22 22
 
23
-    /**
24
-     * CalculatedModelFieldsFactory constructor.
25
-     * @param LoaderInterface $loader
26
-     */
27
-    public function __construct(LoaderInterface $loader)
28
-    {
29
-        $this->loader = $loader;
30
-    }
23
+	/**
24
+	 * CalculatedModelFieldsFactory constructor.
25
+	 * @param LoaderInterface $loader
26
+	 */
27
+	public function __construct(LoaderInterface $loader)
28
+	{
29
+		$this->loader = $loader;
30
+	}
31 31
 
32
-    /**
33
-     * Creates the calculator class that corresponds to that particular model
34
-     * @since 4.9.68.p
35
-     * @param string $model_name
36
-     * @return Base
37
-     * @throws UnexpectedEntityException
38
-     */
39
-    public function createFromModel($model_name)
40
-    {
41
-        return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
42
-    }
32
+	/**
33
+	 * Creates the calculator class that corresponds to that particular model
34
+	 * @since 4.9.68.p
35
+	 * @param string $model_name
36
+	 * @return Base
37
+	 * @throws UnexpectedEntityException
38
+	 */
39
+	public function createFromModel($model_name)
40
+	{
41
+		return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name);
42
+	}
43 43
 
44
-    /**
45
-     * Creates the calculator class that corresponds to that classname and verifies it's of the correct type
46
-     * @param string $calculator_classname
47
-     * @return Base
48
-     * @throws UnexpectedEntityException
49
-     */
50
-    public function createFromClassname($calculator_classname)
51
-    {
52
-        $calculator = $this->loader->getShared($calculator_classname);
53
-        if (!$calculator instanceof Base) {
54
-            throw new UnexpectedEntityException(
55
-                $calculator_classname,
56
-                'EventEspresso\core\libraries\rest_api\calculations\Base'
57
-            );
58
-        }
59
-        return $calculator;
60
-    }
44
+	/**
45
+	 * Creates the calculator class that corresponds to that classname and verifies it's of the correct type
46
+	 * @param string $calculator_classname
47
+	 * @return Base
48
+	 * @throws UnexpectedEntityException
49
+	 */
50
+	public function createFromClassname($calculator_classname)
51
+	{
52
+		$calculator = $this->loader->getShared($calculator_classname);
53
+		if (!$calculator instanceof Base) {
54
+			throw new UnexpectedEntityException(
55
+				$calculator_classname,
56
+				'EventEspresso\core\libraries\rest_api\calculations\Base'
57
+			);
58
+		}
59
+		return $calculator;
60
+	}
61 61
 }
62 62
 // End of file CalculationsFactory.php
63 63
 // Location: EventEspresso\core\libraries\rest_api\calculations/CalculationsFactory.php
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Base.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
25 25
     {
26
-        if (! current_user_can($required_permission)) {
26
+        if ( ! current_user_can($required_permission)) {
27 27
             throw new RestException(
28 28
                 'permission_denied',
29 29
                 sprintf(
@@ -75,6 +75,6 @@  discard block
 block discarded – undo
75 75
     public function schemaForCalculation($calculation_index)
76 76
     {
77 77
         $schema_map = $this->schemaForCalculations();
78
-        return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
78
+        return isset($schema_map[$calculation_index]) ? $schema_map[$calculation_index] : array();
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@
 block discarded – undo
15 15
  */
16 16
 class Base
17 17
 {
18
-    /**
19
-     * @param $required_permission
20
-     * @param $attempted_calculation
21
-     * @throws RestException
22
-     */
23
-    protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
24
-    {
25
-        if (! current_user_can($required_permission)) {
26
-            throw new RestException(
27
-                'permission_denied',
28
-                sprintf(
29
-                    esc_html__(
30
-                    // @codingStandardsIgnoreStart
31
-                        'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
32
-                        // @codingStandardsIgnoreEnd
33
-                        'event_espresso'
34
-                    ),
35
-                    $attempted_calculation,
36
-                    EEH_Inflector::pluralize_and_lower($this->getResourceName()),
37
-                    $required_permission
38
-                )
39
-            );
40
-        }
41
-    }
18
+	/**
19
+	 * @param $required_permission
20
+	 * @param $attempted_calculation
21
+	 * @throws RestException
22
+	 */
23
+	protected function verifyCurrentUserCan($required_permission, $attempted_calculation)
24
+	{
25
+		if (! current_user_can($required_permission)) {
26
+			throw new RestException(
27
+				'permission_denied',
28
+				sprintf(
29
+					esc_html__(
30
+					// @codingStandardsIgnoreStart
31
+						'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"',
32
+						// @codingStandardsIgnoreEnd
33
+						'event_espresso'
34
+					),
35
+					$attempted_calculation,
36
+					EEH_Inflector::pluralize_and_lower($this->getResourceName()),
37
+					$required_permission
38
+				)
39
+			);
40
+		}
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Gets the name of the resource of the called class
46
-     *
47
-     * @return string
48
-     */
49
-    public function getResourceName()
50
-    {
51
-        return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1);
52
-    }
44
+	/**
45
+	 * Gets the name of the resource of the called class
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function getResourceName()
50
+	{
51
+		return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1);
52
+	}
53 53
 
54
-    /**
55
-     * Returns an array to be used for the schema for the calculated fields.
56
-     * @since 4.9.68.p
57
-     * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays {
58
-     * @type string $description
59
-     * @type string $type, eg "string", "int", "boolean", "object", "array", etc
60
-     * }
61
-     */
62
-    public function schemaForCalculations()
63
-    {
64
-        return array();
65
-    }
54
+	/**
55
+	 * Returns an array to be used for the schema for the calculated fields.
56
+	 * @since 4.9.68.p
57
+	 * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays {
58
+	 * @type string $description
59
+	 * @type string $type, eg "string", "int", "boolean", "object", "array", etc
60
+	 * }
61
+	 */
62
+	public function schemaForCalculations()
63
+	{
64
+		return array();
65
+	}
66 66
 
67
-    /**
68
-     * Returns the json schema for the given calculation index.
69
-     *
70
-     * @since 4.9.68.p
71
-     * @param $calculation_index
72
-     * @return array
73
-     */
74
-    public function schemaForCalculation($calculation_index)
75
-    {
76
-        $schema_map = $this->schemaForCalculations();
77
-        return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
78
-    }
67
+	/**
68
+	 * Returns the json schema for the given calculation index.
69
+	 *
70
+	 * @since 4.9.68.p
71
+	 * @param $calculation_index
72
+	 * @return array
73
+	 */
74
+	public function schemaForCalculation($calculation_index)
75
+	{
76
+		$schema_map = $this->schemaForCalculations();
77
+		return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array();
78
+	}
79 79
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoTicketSelector.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
         extract($attributes, EXTR_OVERWRITE);
81 81
         $event_id = isset($event_id) ? $event_id : 0;
82 82
         $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
83
-        if (! $event instanceof EE_Event) {
83
+        if ( ! $event instanceof EE_Event) {
84 84
             if (WP_DEBUG === true && current_user_can('edit_pages')) {
85 85
                 new ExceptionStackTraceDisplay(
86 86
                     new InvalidArgumentException(
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -22,92 +22,92 @@
 block discarded – undo
22 22
  */
23 23
 class EspressoTicketSelector extends EspressoShortcode
24 24
 {
25
-    /**
26
-     * the actual shortcode tag that gets registered with WordPress
27
-     *
28
-     * @return string
29
-     */
30
-    public function getTag()
31
-    {
32
-        return 'ESPRESSO_TICKET_SELECTOR';
33
-    }
25
+	/**
26
+	 * the actual shortcode tag that gets registered with WordPress
27
+	 *
28
+	 * @return string
29
+	 */
30
+	public function getTag()
31
+	{
32
+		return 'ESPRESSO_TICKET_SELECTOR';
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * the time in seconds to cache the results of the processShortcode() method
38
-     * 0 means the processShortcode() results will NOT be cached at all
39
-     *
40
-     * @return int
41
-     */
42
-    public function cacheExpiration()
43
-    {
44
-        return 0;
45
-    }
36
+	/**
37
+	 * the time in seconds to cache the results of the processShortcode() method
38
+	 * 0 means the processShortcode() results will NOT be cached at all
39
+	 *
40
+	 * @return int
41
+	 */
42
+	public function cacheExpiration()
43
+	{
44
+		return 0;
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * a place for adding any initialization code that needs to run prior to wp_header().
50
-     * this may be required for shortcodes that utilize a corresponding module,
51
-     * and need to enqueue assets for that module
52
-     *
53
-     * @return void
54
-     */
55
-    public function initializeShortcode()
56
-    {
57
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
58
-        $this->shortcodeHasBeenInitialized();
59
-    }
48
+	/**
49
+	 * a place for adding any initialization code that needs to run prior to wp_header().
50
+	 * this may be required for shortcodes that utilize a corresponding module,
51
+	 * and need to enqueue assets for that module
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function initializeShortcode()
56
+	{
57
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
58
+		$this->shortcodeHasBeenInitialized();
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * callback that runs when the shortcode is encountered in post content.
64
-     * IMPORTANT !!!
65
-     * remember that shortcode content should be RETURNED and NOT echoed out
66
-     *
67
-     * @param array $attributes
68
-     * @return string
69
-     * @throws InvalidArgumentException
70
-     * @throws EE_Error
71
-     * @throws InvalidDataTypeException
72
-     * @throws InvalidInterfaceException
73
-     * @throws ReflectionException
74
-     * @throws Exception
75
-     */
76
-    public function processShortcode($attributes = array())
77
-    {
78
-        extract($attributes, EXTR_OVERWRITE);
79
-        $event_id = isset($event_id) ? $event_id : 0;
80
-        $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
81
-        if (! $event instanceof EE_Event) {
82
-            if (WP_DEBUG === true && current_user_can('edit_pages')) {
83
-                new ExceptionStackTraceDisplay(
84
-                    new InvalidArgumentException(
85
-                        sprintf(
86
-                            esc_html__(
87
-                                'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.',
88
-                                'event_espresso'
89
-                            ),
90
-                            $this->getTag(),
91
-                            $event_id,
92
-                            'event_id',
93
-                            '<br />'
94
-                        )
95
-                    )
96
-                );
97
-                return '';
98
-            }
99
-            return sprintf(
100
-                esc_html__(
101
-                    'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.',
102
-                    'event_espresso'
103
-                ),
104
-                $event_id
105
-            );
106
-        }
107
-        ob_start();
108
-        do_action('AHEE_event_details_before_post', $event_id);
109
-        espresso_ticket_selector($event);
110
-        do_action('AHEE_event_details_after_post');
111
-        return ob_get_clean();
112
-    }
62
+	/**
63
+	 * callback that runs when the shortcode is encountered in post content.
64
+	 * IMPORTANT !!!
65
+	 * remember that shortcode content should be RETURNED and NOT echoed out
66
+	 *
67
+	 * @param array $attributes
68
+	 * @return string
69
+	 * @throws InvalidArgumentException
70
+	 * @throws EE_Error
71
+	 * @throws InvalidDataTypeException
72
+	 * @throws InvalidInterfaceException
73
+	 * @throws ReflectionException
74
+	 * @throws Exception
75
+	 */
76
+	public function processShortcode($attributes = array())
77
+	{
78
+		extract($attributes, EXTR_OVERWRITE);
79
+		$event_id = isset($event_id) ? $event_id : 0;
80
+		$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id);
81
+		if (! $event instanceof EE_Event) {
82
+			if (WP_DEBUG === true && current_user_can('edit_pages')) {
83
+				new ExceptionStackTraceDisplay(
84
+					new InvalidArgumentException(
85
+						sprintf(
86
+							esc_html__(
87
+								'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.',
88
+								'event_espresso'
89
+							),
90
+							$this->getTag(),
91
+							$event_id,
92
+							'event_id',
93
+							'<br />'
94
+						)
95
+					)
96
+				);
97
+				return '';
98
+			}
99
+			return sprintf(
100
+				esc_html__(
101
+					'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.',
102
+					'event_espresso'
103
+				),
104
+				$event_id
105
+			);
106
+		}
107
+		ob_start();
108
+		do_action('AHEE_event_details_before_post', $event_id);
109
+		espresso_ticket_selector($event);
110
+		do_action('AHEE_event_details_after_post');
111
+		return ob_get_clean();
112
+	}
113 113
 }
Please login to merge, or discard this patch.