Completed
Branch Gutenberg/components-datetime-... (6bb5d2)
by
unknown
91:35 queued 70:47
created
core/services/assets/BlockAssetManager.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use EventEspresso\core\domain\entities\editor\BlockInterface;
6 6
 use EventEspresso\core\domain\services\assets\CoreAssetManager;
7
-use EventEspresso\core\domain\values\assets\Asset;
8 7
 use EventEspresso\core\domain\values\assets\BrowserAsset;
9 8
 use EventEspresso\core\domain\values\assets\JavascriptAsset;
10 9
 use EventEspresso\core\domain\values\assets\StylesheetAsset;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function setEditorScriptHandle($editor_script_handle)
60 60
     {
61
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
62
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
61
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
62
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
63 63
         }
64 64
         $this->editor_script_handle = $editor_script_handle;
65 65
     }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function setEditorStyleHandle($editor_style_handle)
81 81
     {
82
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
83
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
82
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
83
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
84 84
         }
85 85
         $this->editor_style_handle = $editor_style_handle;
86 86
     }
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function setScriptHandle($script_handle)
102 102
     {
103
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
104
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
103
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
104
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
105 105
         }
106 106
         $this->script_handle = $script_handle;
107 107
     }
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function setStyleHandle($style_handle)
123 123
     {
124
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
125
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
124
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
125
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
126 126
         }
127 127
         $this->style_handle = $style_handle;
128 128
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function addEditorScript($handle, array $dependencies = array())
155 155
     {
156
-        if($this->assets->hasJavascriptAsset($handle)){
156
+        if ($this->assets->hasJavascriptAsset($handle)) {
157 157
             return $this->assets->getJavascriptAsset($handle);
158 158
         }
159 159
         return parent::addJavascript(
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
     protected function addDefaultBlockScriptDependencies(array $dependencies)
252 252
     {
253 253
         $dependencies += array(
254
-                'wp-blocks',    // Provides useful functions and components for extending the editor
255
-                'wp-i18n',      // Provides localization functions
256
-                'wp-element',   // Provides React.Component
254
+                'wp-blocks', // Provides useful functions and components for extending the editor
255
+                'wp-i18n', // Provides localization functions
256
+                'wp-element', // Provides React.Component
257 257
                 'wp-components', // Provides many prebuilt components and controls
258 258
                 CoreAssetManager::JS_HANDLE_EE_COMPONENTS
259 259
             );
Please login to merge, or discard this patch.
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -23,296 +23,296 @@
 block discarded – undo
23 23
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var string $editor_script_handle
28
-     */
29
-    private $editor_script_handle;
30
-
31
-    /**
32
-     * @var string $editor_style_handle
33
-     */
34
-    private $editor_style_handle;
35
-
36
-    /**
37
-     * @var string $script_handle
38
-     */
39
-    private $script_handle;
40
-
41
-    /**
42
-     * @var string $style_handle
43
-     */
44
-    private $style_handle;
45
-
46
-
47
-    /**
48
-     * @return string
49
-     */
50
-    public function getEditorScriptHandle()
51
-    {
52
-        return $this->editor_script_handle;
53
-    }
54
-
55
-
56
-    /**
57
-     * @param string $editor_script_handle
58
-     */
59
-    public function setEditorScriptHandle($editor_script_handle)
60
-    {
61
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
62
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
63
-        }
64
-        $this->editor_script_handle = $editor_script_handle;
65
-    }
66
-
67
-
68
-    /**
69
-     * @return string
70
-     */
71
-    public function getEditorStyleHandle()
72
-    {
73
-        return $this->editor_style_handle;
74
-    }
75
-
76
-
77
-    /**
78
-     * @param string $editor_style_handle
79
-     */
80
-    public function setEditorStyleHandle($editor_style_handle)
81
-    {
82
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
83
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
84
-        }
85
-        $this->editor_style_handle = $editor_style_handle;
86
-    }
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public function getScriptHandle()
93
-    {
94
-        return $this->script_handle;
95
-    }
96
-
97
-
98
-    /**
99
-     * @param string $script_handle
100
-     */
101
-    public function setScriptHandle($script_handle)
102
-    {
103
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
104
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
105
-        }
106
-        $this->script_handle = $script_handle;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return string
112
-     */
113
-    public function getStyleHandle()
114
-    {
115
-        return $this->style_handle;
116
-    }
117
-
118
-
119
-    /**
120
-     * @param string $style_handle
121
-     */
122
-    public function setStyleHandle($style_handle)
123
-    {
124
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
125
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
126
-        }
127
-        $this->style_handle = $style_handle;
128
-    }
129
-
130
-    /**
131
-     * @since $VID:$
132
-     * @throws InvalidDataTypeException
133
-     * @throws InvalidEntityException
134
-     * @throws DuplicateCollectionIdentifierException
135
-     */
136
-    public function addAssets()
137
-    {
138
-        $this->addEditorScript($this->getEditorScriptHandle());
139
-        $this->addEditorStyle($this->getEditorStyleHandle());
140
-        $this->setScriptHandle($this->getScriptHandle());
141
-        $this->setStyleHandle($this->getStyleHandle());
142
-    }
143
-
144
-
145
-    /**
146
-     * @param       $handle
147
-     * @param array $dependencies
148
-     * @since $VID:$
149
-     * @return JavascriptAsset
150
-     * @throws InvalidDataTypeException
151
-     * @throws InvalidEntityException
152
-     * @throws DuplicateCollectionIdentifierException
153
-     */
154
-    public function addEditorScript($handle, array $dependencies = array())
155
-    {
156
-        if($this->assets->hasJavascriptAsset($handle)){
157
-            return $this->assets->getJavascriptAsset($handle);
158
-        }
159
-        return parent::addJavascript(
160
-            $handle,
161
-            $this->registry->getJsUrl(
162
-                $this->domain->assetNamespace(),
163
-                $handle
164
-            ),
165
-            $this->addDefaultBlockScriptDependencies($dependencies)
166
-        )
167
-        ->setRequiresTranslation();
168
-    }
169
-
170
-
171
-    /**
172
-     * @param        $handle
173
-     * @param array  $dependencies
174
-     * @since $VID:$
175
-     * @return StylesheetAsset
176
-     * @throws InvalidDataTypeException
177
-     * @throws InvalidEntityException
178
-     * @throws DuplicateCollectionIdentifierException
179
-     */
180
-    public function addEditorStyle($handle, array $dependencies = array())
181
-    {
182
-        if ($this->assets->hasStylesheetAsset($handle)) {
183
-            return $this->assets->getStylesheetAsset($handle);
184
-        }
185
-        return parent::addStylesheet(
186
-            $handle,
187
-            $this->registry->getCssUrl(
188
-                $this->domain->assetNamespace(),
189
-                $handle
190
-            ),
191
-            $dependencies
192
-        );
193
-    }
194
-
195
-
196
-    /**
197
-     * @param       $handle
198
-     * @param array $dependencies
199
-     * @since $VID:$
200
-     * @return JavascriptAsset
201
-     * @throws InvalidDataTypeException
202
-     * @throws InvalidEntityException
203
-     * @throws DuplicateCollectionIdentifierException
204
-     */
205
-    public function addScript($handle, array $dependencies = array())
206
-    {
207
-        if ($this->assets->hasJavascriptAsset($handle)) {
208
-            return $this->assets->getJavascriptAsset($handle);
209
-        }
210
-        return parent::addJavascript(
211
-            $handle,
212
-            $this->registry->getJsUrl(
213
-                $this->domain->assetNamespace(),
214
-                $handle
215
-            ),
216
-            $this->addDefaultBlockScriptDependencies($dependencies)
217
-        )
218
-        ->setRequiresTranslation();
219
-    }
220
-
221
-
222
-    /**
223
-     * @param        $handle
224
-     * @param array  $dependencies
225
-     * @since $VID:$
226
-     * @return StylesheetAsset
227
-     * @throws InvalidDataTypeException
228
-     * @throws InvalidEntityException
229
-     * @throws DuplicateCollectionIdentifierException
230
-     */
231
-    public function addStyle($handle, array $dependencies = array())
232
-    {
233
-        if ($this->assets->hasStylesheetAsset($handle)) {
234
-            return $this->assets->getStylesheetAsset($handle);
235
-        }
236
-        return parent::addStylesheet(
237
-            $handle,
238
-            $this->registry->getCssUrl(
239
-                $this->domain->assetNamespace(),
240
-                $handle
241
-            ),
242
-            $dependencies
243
-        );
244
-    }
245
-
246
-
247
-    /**
248
-     * @param array $dependencies
249
-     * @return array
250
-     */
251
-    protected function addDefaultBlockScriptDependencies(array $dependencies)
252
-    {
253
-        $dependencies += array(
254
-                'wp-blocks',    // Provides useful functions and components for extending the editor
255
-                'wp-i18n',      // Provides localization functions
256
-                'wp-element',   // Provides React.Component
257
-                'wp-components', // Provides many prebuilt components and controls
258
-                CoreAssetManager::JS_HANDLE_EE_COMPONENTS
259
-            );
260
-        return $dependencies;
261
-    }
262
-
263
-
264
-    /**
265
-     * @return JavascriptAsset|null
266
-     */
267
-    public function getEditorScript()
268
-    {
269
-        return $this->assets->getJavascriptAsset($this->editor_script_handle);
270
-    }
271
-
272
-
273
-    /**
274
-     * @return StylesheetAsset|null
275
-     */
276
-    public function getEditorStyle()
277
-    {
278
-        return $this->assets->getStylesheetAsset($this->editor_style_handle);
279
-    }
280
-
281
-
282
-    /**
283
-     * @return JavascriptAsset|null
284
-     */
285
-    public function getScript()
286
-    {
287
-        return $this->assets->getJavascriptAsset($this->script_handle);
288
-    }
289
-
290
-
291
-    /**
292
-     * @return StylesheetAsset|null
293
-     */
294
-    public function getStyle()
295
-    {
296
-        return $this->assets->getStylesheetAsset($this->style_handle);
297
-    }
298
-
299
-
300
-    /**
301
-     * @return  void
302
-     */
303
-    public function enqueueAssets()
304
-    {
305
-        $assets = array(
306
-            $this->getEditorScript(),
307
-            $this->getEditorStyle(),
308
-            $this->getScript(),
309
-            $this->getStyle(),
310
-        );
311
-        foreach ($assets as $asset) {
312
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
313
-                $asset->enqueueAsset();
314
-            }
315
-        }
316
-    }
26
+	/**
27
+	 * @var string $editor_script_handle
28
+	 */
29
+	private $editor_script_handle;
30
+
31
+	/**
32
+	 * @var string $editor_style_handle
33
+	 */
34
+	private $editor_style_handle;
35
+
36
+	/**
37
+	 * @var string $script_handle
38
+	 */
39
+	private $script_handle;
40
+
41
+	/**
42
+	 * @var string $style_handle
43
+	 */
44
+	private $style_handle;
45
+
46
+
47
+	/**
48
+	 * @return string
49
+	 */
50
+	public function getEditorScriptHandle()
51
+	{
52
+		return $this->editor_script_handle;
53
+	}
54
+
55
+
56
+	/**
57
+	 * @param string $editor_script_handle
58
+	 */
59
+	public function setEditorScriptHandle($editor_script_handle)
60
+	{
61
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
62
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
63
+		}
64
+		$this->editor_script_handle = $editor_script_handle;
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function getEditorStyleHandle()
72
+	{
73
+		return $this->editor_style_handle;
74
+	}
75
+
76
+
77
+	/**
78
+	 * @param string $editor_style_handle
79
+	 */
80
+	public function setEditorStyleHandle($editor_style_handle)
81
+	{
82
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
83
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
84
+		}
85
+		$this->editor_style_handle = $editor_style_handle;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public function getScriptHandle()
93
+	{
94
+		return $this->script_handle;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param string $script_handle
100
+	 */
101
+	public function setScriptHandle($script_handle)
102
+	{
103
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
104
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
105
+		}
106
+		$this->script_handle = $script_handle;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return string
112
+	 */
113
+	public function getStyleHandle()
114
+	{
115
+		return $this->style_handle;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param string $style_handle
121
+	 */
122
+	public function setStyleHandle($style_handle)
123
+	{
124
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
125
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
126
+		}
127
+		$this->style_handle = $style_handle;
128
+	}
129
+
130
+	/**
131
+	 * @since $VID:$
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws InvalidEntityException
134
+	 * @throws DuplicateCollectionIdentifierException
135
+	 */
136
+	public function addAssets()
137
+	{
138
+		$this->addEditorScript($this->getEditorScriptHandle());
139
+		$this->addEditorStyle($this->getEditorStyleHandle());
140
+		$this->setScriptHandle($this->getScriptHandle());
141
+		$this->setStyleHandle($this->getStyleHandle());
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param       $handle
147
+	 * @param array $dependencies
148
+	 * @since $VID:$
149
+	 * @return JavascriptAsset
150
+	 * @throws InvalidDataTypeException
151
+	 * @throws InvalidEntityException
152
+	 * @throws DuplicateCollectionIdentifierException
153
+	 */
154
+	public function addEditorScript($handle, array $dependencies = array())
155
+	{
156
+		if($this->assets->hasJavascriptAsset($handle)){
157
+			return $this->assets->getJavascriptAsset($handle);
158
+		}
159
+		return parent::addJavascript(
160
+			$handle,
161
+			$this->registry->getJsUrl(
162
+				$this->domain->assetNamespace(),
163
+				$handle
164
+			),
165
+			$this->addDefaultBlockScriptDependencies($dependencies)
166
+		)
167
+		->setRequiresTranslation();
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param        $handle
173
+	 * @param array  $dependencies
174
+	 * @since $VID:$
175
+	 * @return StylesheetAsset
176
+	 * @throws InvalidDataTypeException
177
+	 * @throws InvalidEntityException
178
+	 * @throws DuplicateCollectionIdentifierException
179
+	 */
180
+	public function addEditorStyle($handle, array $dependencies = array())
181
+	{
182
+		if ($this->assets->hasStylesheetAsset($handle)) {
183
+			return $this->assets->getStylesheetAsset($handle);
184
+		}
185
+		return parent::addStylesheet(
186
+			$handle,
187
+			$this->registry->getCssUrl(
188
+				$this->domain->assetNamespace(),
189
+				$handle
190
+			),
191
+			$dependencies
192
+		);
193
+	}
194
+
195
+
196
+	/**
197
+	 * @param       $handle
198
+	 * @param array $dependencies
199
+	 * @since $VID:$
200
+	 * @return JavascriptAsset
201
+	 * @throws InvalidDataTypeException
202
+	 * @throws InvalidEntityException
203
+	 * @throws DuplicateCollectionIdentifierException
204
+	 */
205
+	public function addScript($handle, array $dependencies = array())
206
+	{
207
+		if ($this->assets->hasJavascriptAsset($handle)) {
208
+			return $this->assets->getJavascriptAsset($handle);
209
+		}
210
+		return parent::addJavascript(
211
+			$handle,
212
+			$this->registry->getJsUrl(
213
+				$this->domain->assetNamespace(),
214
+				$handle
215
+			),
216
+			$this->addDefaultBlockScriptDependencies($dependencies)
217
+		)
218
+		->setRequiresTranslation();
219
+	}
220
+
221
+
222
+	/**
223
+	 * @param        $handle
224
+	 * @param array  $dependencies
225
+	 * @since $VID:$
226
+	 * @return StylesheetAsset
227
+	 * @throws InvalidDataTypeException
228
+	 * @throws InvalidEntityException
229
+	 * @throws DuplicateCollectionIdentifierException
230
+	 */
231
+	public function addStyle($handle, array $dependencies = array())
232
+	{
233
+		if ($this->assets->hasStylesheetAsset($handle)) {
234
+			return $this->assets->getStylesheetAsset($handle);
235
+		}
236
+		return parent::addStylesheet(
237
+			$handle,
238
+			$this->registry->getCssUrl(
239
+				$this->domain->assetNamespace(),
240
+				$handle
241
+			),
242
+			$dependencies
243
+		);
244
+	}
245
+
246
+
247
+	/**
248
+	 * @param array $dependencies
249
+	 * @return array
250
+	 */
251
+	protected function addDefaultBlockScriptDependencies(array $dependencies)
252
+	{
253
+		$dependencies += array(
254
+				'wp-blocks',    // Provides useful functions and components for extending the editor
255
+				'wp-i18n',      // Provides localization functions
256
+				'wp-element',   // Provides React.Component
257
+				'wp-components', // Provides many prebuilt components and controls
258
+				CoreAssetManager::JS_HANDLE_EE_COMPONENTS
259
+			);
260
+		return $dependencies;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @return JavascriptAsset|null
266
+	 */
267
+	public function getEditorScript()
268
+	{
269
+		return $this->assets->getJavascriptAsset($this->editor_script_handle);
270
+	}
271
+
272
+
273
+	/**
274
+	 * @return StylesheetAsset|null
275
+	 */
276
+	public function getEditorStyle()
277
+	{
278
+		return $this->assets->getStylesheetAsset($this->editor_style_handle);
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return JavascriptAsset|null
284
+	 */
285
+	public function getScript()
286
+	{
287
+		return $this->assets->getJavascriptAsset($this->script_handle);
288
+	}
289
+
290
+
291
+	/**
292
+	 * @return StylesheetAsset|null
293
+	 */
294
+	public function getStyle()
295
+	{
296
+		return $this->assets->getStylesheetAsset($this->style_handle);
297
+	}
298
+
299
+
300
+	/**
301
+	 * @return  void
302
+	 */
303
+	public function enqueueAssets()
304
+	{
305
+		$assets = array(
306
+			$this->getEditorScript(),
307
+			$this->getEditorStyle(),
308
+			$this->getScript(),
309
+			$this->getStyle(),
310
+		);
311
+		foreach ($assets as $asset) {
312
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
313
+				$asset->enqueueAsset();
314
+			}
315
+		}
316
+	}
317 317
 
318 318
 }
Please login to merge, or discard this patch.
core/services/assets/AssetCollection.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -21,192 +21,192 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * AssetCollection constructor
26
-     *
27
-     * @throws InvalidInterfaceException
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
-    }
33
-
34
-
35
-    /**
36
-     * @return StylesheetAsset[]
37
-     * @since 4.9.62.p
38
-     */
39
-    public function getStylesheetAssets()
40
-    {
41
-        return $this->getAssetsOfType(Asset::TYPE_CSS);
42
-    }
43
-
44
-
45
-    /**
46
-     * @return JavascriptAsset[]
47
-     * @since 4.9.62.p
48
-     */
49
-    public function getJavascriptAssets()
50
-    {
51
-        return $this->getAssetsOfType(Asset::TYPE_JS);
52
-    }
53
-
54
-
55
-    /**
56
-     * @return ManifestFile[]
57
-     * @since 4.9.62.p
58
-     */
59
-    public function getManifestFiles()
60
-    {
61
-        return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
-    }
63
-
64
-
65
-    /**
66
-     * @param $type
67
-     * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
-     * @since 4.9.62.p
69
-     */
70
-    protected function getAssetsOfType($type)
71
-    {
72
-        $files = array();
73
-        $this->rewind();
74
-        while ($this->valid()) {
75
-            /** @var Asset $asset */
76
-            $asset = $this->current();
77
-            if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
79
-            }
80
-            $this->next();
81
-        }
82
-        $this->rewind();
83
-        return $files;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return JavascriptAsset[]
89
-     * @since 4.9.62.p
90
-     */
91
-    public function getJavascriptAssetsWithData()
92
-    {
93
-        $files = array();
94
-        $this->rewind();
95
-        while ($this->valid()) {
96
-            /** @var JavascriptAsset $asset */
97
-            $asset = $this->current();
98
-            if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
100
-            }
101
-            $this->next();
102
-        }
103
-        $this->rewind();
104
-        return $files;
105
-    }
106
-
107
-
108
-    /**
109
-     * returns TRUE or FALSE
110
-     * depending on whether the object is within the Collection
111
-     * based on the supplied $identifier and type
112
-     *
113
-     * @param  mixed $identifier
114
-     * @param string $type
115
-     * @return bool
116
-     * @since $VID:$
117
-     */
118
-    public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
-    {
120
-        $this->rewind();
121
-        while ($this->valid()) {
122
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
-                $this->rewind();
124
-                return true;
125
-            }
126
-            $this->next();
127
-        }
128
-        return false;
129
-    }
130
-
131
-
132
-    /**
133
-     * returns TRUE or FALSE
134
-     * depending on whether the Javascript Asset is within the Collection
135
-     * based on the supplied $identifier
136
-     *
137
-     * @param  mixed $identifier
138
-     * @return bool
139
-     * @since $VID:$
140
-     */
141
-    public function hasJavascriptAsset($identifier)
142
-    {
143
-        return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
-    }
145
-
146
-
147
-    /**
148
-     * returns TRUE or FALSE
149
-     * depending on whether the Stylesheet Asset is within the Collection
150
-     * based on the supplied $identifier
151
-     *
152
-     * @param  mixed $identifier
153
-     * @return bool
154
-     * @since $VID:$
155
-     */
156
-    public function hasStylesheetAsset($identifier)
157
-    {
158
-        return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
-    }
160
-
161
-    /**
162
-     * returns the object from the Collection
163
-     * based on the supplied $identifier and type
164
-     *
165
-     * @param  mixed $identifier
166
-     * @param string $type
167
-     * @return JavascriptAsset|StylesheetAsset
168
-     * @since $VID:$
169
-     */
170
-    public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
-    {
172
-        $this->rewind();
173
-        while ($this->valid()) {
174
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
-                /** @var JavascriptAsset|StylesheetAsset $object */
176
-                $object = $this->current();
177
-                $this->rewind();
178
-                return $object;
179
-            }
180
-            $this->next();
181
-        }
182
-        return null;
183
-    }
184
-
185
-
186
-    /**
187
-     * returns the Stylesheet Asset from the Collection
188
-     * based on the supplied $identifier
189
-     *
190
-     * @param  mixed $identifier
191
-     * @return StylesheetAsset
192
-     * @since $VID:$
193
-     */
194
-    public function getStylesheetAsset($identifier)
195
-    {
196
-        return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
-    }
198
-
199
-
200
-    /**
201
-     * returns the Javascript Asset from the Collection
202
-     * based on the supplied $identifier
203
-     *
204
-     * @param  mixed $identifier
205
-     * @return JavascriptAsset
206
-     * @since $VID:$
207
-     */
208
-    public function getJavascriptAsset($identifier)
209
-    {
210
-        return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
-    }
24
+	/**
25
+	 * AssetCollection constructor
26
+	 *
27
+	 * @throws InvalidInterfaceException
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return StylesheetAsset[]
37
+	 * @since 4.9.62.p
38
+	 */
39
+	public function getStylesheetAssets()
40
+	{
41
+		return $this->getAssetsOfType(Asset::TYPE_CSS);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @return JavascriptAsset[]
47
+	 * @since 4.9.62.p
48
+	 */
49
+	public function getJavascriptAssets()
50
+	{
51
+		return $this->getAssetsOfType(Asset::TYPE_JS);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return ManifestFile[]
57
+	 * @since 4.9.62.p
58
+	 */
59
+	public function getManifestFiles()
60
+	{
61
+		return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param $type
67
+	 * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
+	 * @since 4.9.62.p
69
+	 */
70
+	protected function getAssetsOfType($type)
71
+	{
72
+		$files = array();
73
+		$this->rewind();
74
+		while ($this->valid()) {
75
+			/** @var Asset $asset */
76
+			$asset = $this->current();
77
+			if ($asset->type() === $type) {
78
+				$files[ $asset->handle() ] = $asset;
79
+			}
80
+			$this->next();
81
+		}
82
+		$this->rewind();
83
+		return $files;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return JavascriptAsset[]
89
+	 * @since 4.9.62.p
90
+	 */
91
+	public function getJavascriptAssetsWithData()
92
+	{
93
+		$files = array();
94
+		$this->rewind();
95
+		while ($this->valid()) {
96
+			/** @var JavascriptAsset $asset */
97
+			$asset = $this->current();
98
+			if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
+				$files[ $asset->handle() ] = $asset;
100
+			}
101
+			$this->next();
102
+		}
103
+		$this->rewind();
104
+		return $files;
105
+	}
106
+
107
+
108
+	/**
109
+	 * returns TRUE or FALSE
110
+	 * depending on whether the object is within the Collection
111
+	 * based on the supplied $identifier and type
112
+	 *
113
+	 * @param  mixed $identifier
114
+	 * @param string $type
115
+	 * @return bool
116
+	 * @since $VID:$
117
+	 */
118
+	public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
+	{
120
+		$this->rewind();
121
+		while ($this->valid()) {
122
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
+				$this->rewind();
124
+				return true;
125
+			}
126
+			$this->next();
127
+		}
128
+		return false;
129
+	}
130
+
131
+
132
+	/**
133
+	 * returns TRUE or FALSE
134
+	 * depending on whether the Javascript Asset is within the Collection
135
+	 * based on the supplied $identifier
136
+	 *
137
+	 * @param  mixed $identifier
138
+	 * @return bool
139
+	 * @since $VID:$
140
+	 */
141
+	public function hasJavascriptAsset($identifier)
142
+	{
143
+		return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
+	}
145
+
146
+
147
+	/**
148
+	 * returns TRUE or FALSE
149
+	 * depending on whether the Stylesheet Asset is within the Collection
150
+	 * based on the supplied $identifier
151
+	 *
152
+	 * @param  mixed $identifier
153
+	 * @return bool
154
+	 * @since $VID:$
155
+	 */
156
+	public function hasStylesheetAsset($identifier)
157
+	{
158
+		return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
+	}
160
+
161
+	/**
162
+	 * returns the object from the Collection
163
+	 * based on the supplied $identifier and type
164
+	 *
165
+	 * @param  mixed $identifier
166
+	 * @param string $type
167
+	 * @return JavascriptAsset|StylesheetAsset
168
+	 * @since $VID:$
169
+	 */
170
+	public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
+	{
172
+		$this->rewind();
173
+		while ($this->valid()) {
174
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
+				/** @var JavascriptAsset|StylesheetAsset $object */
176
+				$object = $this->current();
177
+				$this->rewind();
178
+				return $object;
179
+			}
180
+			$this->next();
181
+		}
182
+		return null;
183
+	}
184
+
185
+
186
+	/**
187
+	 * returns the Stylesheet Asset from the Collection
188
+	 * based on the supplied $identifier
189
+	 *
190
+	 * @param  mixed $identifier
191
+	 * @return StylesheetAsset
192
+	 * @since $VID:$
193
+	 */
194
+	public function getStylesheetAsset($identifier)
195
+	{
196
+		return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
+	}
198
+
199
+
200
+	/**
201
+	 * returns the Javascript Asset from the Collection
202
+	 * based on the supplied $identifier
203
+	 *
204
+	 * @param  mixed $identifier
205
+	 * @return JavascriptAsset
206
+	 * @since $VID:$
207
+	 */
208
+	public function getJavascriptAsset($identifier)
209
+	{
210
+		return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
+	}
212 212
 }
Please login to merge, or discard this patch.