Completed
Branch EDTR/standardize-dom-data (4f6981)
by
unknown
10:02 queued 59s
created
core/services/json/PrimaryJsonDataNode.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,37 +17,37 @@
 block discarded – undo
17 17
 abstract class PrimaryJsonDataNode extends JsonDataNode
18 18
 {
19 19
 
20
-    /**
21
-     * wp script handle for the app that requires the JSON data
22
-     *
23
-     * @var string $target_script
24
-     */
25
-    private $target_script;
26
-
27
-
28
-    /**
29
-     * sets the WP script handle that this data node is providing data for.
30
-     * The JSON data will written to the DOM inline prior to the targeted script handle
31
-     *
32
-     * @param string $target_script
33
-     * @throws DomainException
34
-     */
35
-    protected function setTargetScript($target_script)
36
-    {
37
-        if ($this->target_script !== null) {
38
-            $this->validator->overwriteError($target_script, 'target script');
39
-        }
40
-        $this->target_script = $target_script;
41
-    }
42
-
43
-
44
-    /**
45
-     * the WP script handle that this data node is providing data for
46
-     *
47
-     * @return string
48
-     */
49
-    public function targetScript()
50
-    {
51
-        return $this->target_script;
52
-    }
20
+	/**
21
+	 * wp script handle for the app that requires the JSON data
22
+	 *
23
+	 * @var string $target_script
24
+	 */
25
+	private $target_script;
26
+
27
+
28
+	/**
29
+	 * sets the WP script handle that this data node is providing data for.
30
+	 * The JSON data will written to the DOM inline prior to the targeted script handle
31
+	 *
32
+	 * @param string $target_script
33
+	 * @throws DomainException
34
+	 */
35
+	protected function setTargetScript($target_script)
36
+	{
37
+		if ($this->target_script !== null) {
38
+			$this->validator->overwriteError($target_script, 'target script');
39
+		}
40
+		$this->target_script = $target_script;
41
+	}
42
+
43
+
44
+	/**
45
+	 * the WP script handle that this data node is providing data for
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function targetScript()
50
+	{
51
+		return $this->target_script;
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/services/graphql/GraphQLManager.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,76 +16,76 @@
 block discarded – undo
16 16
 class GraphQLManager implements GQLManagerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var ConnectionsManager $connections_manager
21
-     */
22
-    protected $connections_manager;
19
+	/**
20
+	 * @var ConnectionsManager $connections_manager
21
+	 */
22
+	protected $connections_manager;
23 23
 
24
-    /**
25
-     * @var DataLoaderManager $data_loader_manager
26
-     */
27
-    protected $data_loader_manager;
24
+	/**
25
+	 * @var DataLoaderManager $data_loader_manager
26
+	 */
27
+	protected $data_loader_manager;
28 28
 
29
-    /**
30
-     * @var EnumsManager $enums_manager
31
-     */
32
-    protected $enums_manager;
29
+	/**
30
+	 * @var EnumsManager $enums_manager
31
+	 */
32
+	protected $enums_manager;
33 33
 
34
-    /**
35
-     * @var InputsManager $inputs_manager
36
-     */
37
-    protected $inputs_manager;
34
+	/**
35
+	 * @var InputsManager $inputs_manager
36
+	 */
37
+	protected $inputs_manager;
38 38
 
39
-    /**
40
-     * @var TypesManager $types_manager
41
-     */
42
-    protected $types_manager;
39
+	/**
40
+	 * @var TypesManager $types_manager
41
+	 */
42
+	protected $types_manager;
43 43
 
44
-    /**
45
-     * @var boolean $initialized
46
-     */
47
-    private $initialized = false;
44
+	/**
45
+	 * @var boolean $initialized
46
+	 */
47
+	private $initialized = false;
48 48
 
49 49
 
50
-    /**
51
-     * GraphQLManager constructor.
52
-     *
53
-     * @param ConnectionsManager $connections_manager
54
-     * @param DataLoaderManager $data_loader_manager
55
-     * @param EnumsManager $enums_manager
56
-     * @param InputsManager $inputs_manager
57
-     * @param TypesManager $types_manager
58
-     */
59
-    public function __construct(
60
-        ConnectionsManager $connections_manager,
61
-        DataLoaderManager $data_loader_manager,
62
-        EnumsManager $enums_manager,
63
-        InputsManager $inputs_manager,
64
-        TypesManager $types_manager
65
-    ) {
66
-        $this->connections_manager = $connections_manager;
67
-        $this->data_loader_manager = $data_loader_manager;
68
-        $this->enums_manager = $enums_manager;
69
-        $this->inputs_manager = $inputs_manager;
70
-        $this->types_manager = $types_manager;
71
-    }
50
+	/**
51
+	 * GraphQLManager constructor.
52
+	 *
53
+	 * @param ConnectionsManager $connections_manager
54
+	 * @param DataLoaderManager $data_loader_manager
55
+	 * @param EnumsManager $enums_manager
56
+	 * @param InputsManager $inputs_manager
57
+	 * @param TypesManager $types_manager
58
+	 */
59
+	public function __construct(
60
+		ConnectionsManager $connections_manager,
61
+		DataLoaderManager $data_loader_manager,
62
+		EnumsManager $enums_manager,
63
+		InputsManager $inputs_manager,
64
+		TypesManager $types_manager
65
+	) {
66
+		$this->connections_manager = $connections_manager;
67
+		$this->data_loader_manager = $data_loader_manager;
68
+		$this->enums_manager = $enums_manager;
69
+		$this->inputs_manager = $inputs_manager;
70
+		$this->types_manager = $types_manager;
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @throws CollectionDetailsException
76
-     * @throws CollectionLoaderException
77
-     * @since $VID:$
78
-     */
79
-    public function init()
80
-    {
81
-        if ($this->initialized) {
82
-            return;
83
-        }
84
-        $this->connections_manager->init();
85
-        $this->data_loader_manager->init();
86
-        $this->enums_manager->init();
87
-        $this->inputs_manager->init();
88
-        $this->types_manager->init();
89
-        $this->initialized = true;
90
-    }
74
+	/**
75
+	 * @throws CollectionDetailsException
76
+	 * @throws CollectionLoaderException
77
+	 * @since $VID:$
78
+	 */
79
+	public function init()
80
+	{
81
+		if ($this->initialized) {
82
+			return;
83
+		}
84
+		$this->connections_manager->init();
85
+		$this->data_loader_manager->init();
86
+		$this->enums_manager->init();
87
+		$this->inputs_manager->init();
88
+		$this->types_manager->init();
89
+		$this->initialized = true;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
core/services/assets/BlockAssetManager.php 2 patches
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -22,255 +22,255 @@
 block discarded – undo
22 22
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
23 23
 {
24 24
 
25
-    const JS_HANDLE_EDITOR = 'eventespresso-blocks';
26
-
27
-    /**
28
-     * @var string $editor_script_handle
29
-     */
30
-    private $editor_script_handle;
31
-
32
-    /**
33
-     * @var string $editor_style_handle
34
-     */
35
-    private $editor_style_handle;
36
-
37
-    /**
38
-     * @var string $script_handle
39
-     */
40
-    private $script_handle;
41
-
42
-    /**
43
-     * @var string $style_handle
44
-     */
45
-    private $style_handle;
46
-
47
-
48
-    /**
49
-     * @return string
50
-     */
51
-    public function getEditorScriptHandle()
52
-    {
53
-        return $this->editor_script_handle;
54
-    }
55
-
56
-
57
-    /**
58
-     * @param string $editor_script_handle
59
-     */
60
-    public function setEditorScriptHandle($editor_script_handle)
61
-    {
62
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
63
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
64
-        }
65
-        $this->editor_script_handle = $editor_script_handle;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    public function getEditorStyleHandle()
73
-    {
74
-        return $this->editor_style_handle;
75
-    }
76
-
77
-
78
-    /**
79
-     * @param string $editor_style_handle
80
-     */
81
-    public function setEditorStyleHandle($editor_style_handle)
82
-    {
83
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
84
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
85
-        }
86
-        $this->editor_style_handle = $editor_style_handle;
87
-    }
88
-
89
-
90
-    /**
91
-     * @return string
92
-     */
93
-    public function getScriptHandle()
94
-    {
95
-        return $this->script_handle;
96
-    }
97
-
98
-
99
-    /**
100
-     * @param string $script_handle
101
-     */
102
-    public function setScriptHandle($script_handle)
103
-    {
104
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
105
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
106
-        }
107
-        $this->script_handle = $script_handle;
108
-    }
109
-
110
-
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getStyleHandle()
115
-    {
116
-        return $this->style_handle;
117
-    }
118
-
119
-
120
-    /**
121
-     * @param string $style_handle
122
-     */
123
-    public function setStyleHandle($style_handle)
124
-    {
125
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
126
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
127
-        }
128
-        $this->style_handle = $style_handle;
129
-    }
130
-
131
-    /**
132
-     * @since 4.9.71.p
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidEntityException
135
-     * @throws DuplicateCollectionIdentifierException
136
-     */
137
-    public function addAssets()
138
-    {
139
-        $this->addEditorScript($this->getEditorScriptHandle());
140
-        // $this->addEditorStyle($this->getEditorStyleHandle());
141
-        $this->addScript($this->getScriptHandle());
142
-        // $this->addStyle($this->getStyleHandle());
143
-    }
144
-
145
-
146
-    /**
147
-     * @param       $handle
148
-     * @param array $dependencies
149
-     * @since 4.9.71.p
150
-     * @return JavascriptAsset
151
-     * @throws InvalidDataTypeException
152
-     * @throws InvalidEntityException
153
-     * @throws DuplicateCollectionIdentifierException
154
-     */
155
-    public function addEditorScript($handle, array $dependencies = array())
156
-    {
157
-        if ($this->assets->hasJavascriptAsset($handle)){
158
-            return $this->assets->getJavascriptAsset($handle);
159
-        }
160
-        $dependencies = array_merge(
161
-            $dependencies,
162
-            ['wp-blocks']
163
-        );
164
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
165
-    }
166
-
167
-
168
-    /**
169
-     * @param        $handle
170
-     * @param array  $dependencies
171
-     * @since 4.9.71.p
172
-     * @return StylesheetAsset
173
-     * @throws InvalidDataTypeException
174
-     * @throws InvalidEntityException
175
-     * @throws DuplicateCollectionIdentifierException
176
-     */
177
-    public function addEditorStyle($handle, array $dependencies = array())
178
-    {
179
-        if ($this->assets->hasStylesheetAsset($handle)) {
180
-            return $this->assets->getStylesheetAsset($handle);
181
-        }
182
-        return $this->addCss($handle, $dependencies);
183
-    }
184
-
185
-
186
-    /**
187
-     * @param       $handle
188
-     * @param array $dependencies
189
-     * @since 4.9.71.p
190
-     * @return JavascriptAsset
191
-     * @throws InvalidDataTypeException
192
-     * @throws InvalidEntityException
193
-     * @throws DuplicateCollectionIdentifierException
194
-     */
195
-    public function addScript($handle, array $dependencies = array())
196
-    {
197
-        if ($this->assets->hasJavascriptAsset($handle)) {
198
-            return $this->assets->getJavascriptAsset($handle);
199
-        }
200
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
201
-    }
202
-
203
-
204
-    /**
205
-     * @param        $handle
206
-     * @param array  $dependencies
207
-     * @since 4.9.71.p
208
-     * @return StylesheetAsset
209
-     * @throws InvalidDataTypeException
210
-     * @throws InvalidEntityException
211
-     * @throws DuplicateCollectionIdentifierException
212
-     */
213
-    public function addStyle($handle, array $dependencies = array())
214
-    {
215
-        if ($this->assets->hasStylesheetAsset($handle)) {
216
-            return $this->assets->getStylesheetAsset($handle);
217
-        }
218
-        return $this->addCss($handle, $dependencies);
219
-    }
220
-
221
-
222
-    /**
223
-     * @return JavascriptAsset|null
224
-     */
225
-    public function getEditorScript()
226
-    {
227
-        return $this->assets->getJavascriptAsset($this->editor_script_handle);
228
-    }
229
-
230
-
231
-    /**
232
-     * @return StylesheetAsset|null
233
-     */
234
-    public function getEditorStyle()
235
-    {
236
-        return $this->assets->getStylesheetAsset($this->editor_style_handle);
237
-    }
238
-
239
-
240
-    /**
241
-     * @return JavascriptAsset|null
242
-     */
243
-    public function getScript()
244
-    {
245
-        return $this->assets->getJavascriptAsset($this->script_handle);
246
-    }
247
-
248
-
249
-    /**
250
-     * @return StylesheetAsset|null
251
-     */
252
-    public function getStyle()
253
-    {
254
-        return $this->assets->getStylesheetAsset($this->style_handle);
255
-    }
256
-
257
-
258
-    /**
259
-     * @return  void
260
-     */
261
-    public function enqueueAssets()
262
-    {
263
-        $assets = array(
264
-            $this->getEditorScript(),
265
-            $this->getEditorStyle(),
266
-            $this->getScript(),
267
-            $this->getStyle(),
268
-        );
269
-        foreach ($assets as $asset) {
270
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
271
-                $asset->enqueueAsset();
272
-            }
273
-        }
274
-    }
25
+	const JS_HANDLE_EDITOR = 'eventespresso-blocks';
26
+
27
+	/**
28
+	 * @var string $editor_script_handle
29
+	 */
30
+	private $editor_script_handle;
31
+
32
+	/**
33
+	 * @var string $editor_style_handle
34
+	 */
35
+	private $editor_style_handle;
36
+
37
+	/**
38
+	 * @var string $script_handle
39
+	 */
40
+	private $script_handle;
41
+
42
+	/**
43
+	 * @var string $style_handle
44
+	 */
45
+	private $style_handle;
46
+
47
+
48
+	/**
49
+	 * @return string
50
+	 */
51
+	public function getEditorScriptHandle()
52
+	{
53
+		return $this->editor_script_handle;
54
+	}
55
+
56
+
57
+	/**
58
+	 * @param string $editor_script_handle
59
+	 */
60
+	public function setEditorScriptHandle($editor_script_handle)
61
+	{
62
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
63
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
64
+		}
65
+		$this->editor_script_handle = $editor_script_handle;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	public function getEditorStyleHandle()
73
+	{
74
+		return $this->editor_style_handle;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @param string $editor_style_handle
80
+	 */
81
+	public function setEditorStyleHandle($editor_style_handle)
82
+	{
83
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
84
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
85
+		}
86
+		$this->editor_style_handle = $editor_style_handle;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return string
92
+	 */
93
+	public function getScriptHandle()
94
+	{
95
+		return $this->script_handle;
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param string $script_handle
101
+	 */
102
+	public function setScriptHandle($script_handle)
103
+	{
104
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
105
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
106
+		}
107
+		$this->script_handle = $script_handle;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getStyleHandle()
115
+	{
116
+		return $this->style_handle;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param string $style_handle
122
+	 */
123
+	public function setStyleHandle($style_handle)
124
+	{
125
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
126
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
127
+		}
128
+		$this->style_handle = $style_handle;
129
+	}
130
+
131
+	/**
132
+	 * @since 4.9.71.p
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidEntityException
135
+	 * @throws DuplicateCollectionIdentifierException
136
+	 */
137
+	public function addAssets()
138
+	{
139
+		$this->addEditorScript($this->getEditorScriptHandle());
140
+		// $this->addEditorStyle($this->getEditorStyleHandle());
141
+		$this->addScript($this->getScriptHandle());
142
+		// $this->addStyle($this->getStyleHandle());
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param       $handle
148
+	 * @param array $dependencies
149
+	 * @since 4.9.71.p
150
+	 * @return JavascriptAsset
151
+	 * @throws InvalidDataTypeException
152
+	 * @throws InvalidEntityException
153
+	 * @throws DuplicateCollectionIdentifierException
154
+	 */
155
+	public function addEditorScript($handle, array $dependencies = array())
156
+	{
157
+		if ($this->assets->hasJavascriptAsset($handle)){
158
+			return $this->assets->getJavascriptAsset($handle);
159
+		}
160
+		$dependencies = array_merge(
161
+			$dependencies,
162
+			['wp-blocks']
163
+		);
164
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
165
+	}
166
+
167
+
168
+	/**
169
+	 * @param        $handle
170
+	 * @param array  $dependencies
171
+	 * @since 4.9.71.p
172
+	 * @return StylesheetAsset
173
+	 * @throws InvalidDataTypeException
174
+	 * @throws InvalidEntityException
175
+	 * @throws DuplicateCollectionIdentifierException
176
+	 */
177
+	public function addEditorStyle($handle, array $dependencies = array())
178
+	{
179
+		if ($this->assets->hasStylesheetAsset($handle)) {
180
+			return $this->assets->getStylesheetAsset($handle);
181
+		}
182
+		return $this->addCss($handle, $dependencies);
183
+	}
184
+
185
+
186
+	/**
187
+	 * @param       $handle
188
+	 * @param array $dependencies
189
+	 * @since 4.9.71.p
190
+	 * @return JavascriptAsset
191
+	 * @throws InvalidDataTypeException
192
+	 * @throws InvalidEntityException
193
+	 * @throws DuplicateCollectionIdentifierException
194
+	 */
195
+	public function addScript($handle, array $dependencies = array())
196
+	{
197
+		if ($this->assets->hasJavascriptAsset($handle)) {
198
+			return $this->assets->getJavascriptAsset($handle);
199
+		}
200
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
201
+	}
202
+
203
+
204
+	/**
205
+	 * @param        $handle
206
+	 * @param array  $dependencies
207
+	 * @since 4.9.71.p
208
+	 * @return StylesheetAsset
209
+	 * @throws InvalidDataTypeException
210
+	 * @throws InvalidEntityException
211
+	 * @throws DuplicateCollectionIdentifierException
212
+	 */
213
+	public function addStyle($handle, array $dependencies = array())
214
+	{
215
+		if ($this->assets->hasStylesheetAsset($handle)) {
216
+			return $this->assets->getStylesheetAsset($handle);
217
+		}
218
+		return $this->addCss($handle, $dependencies);
219
+	}
220
+
221
+
222
+	/**
223
+	 * @return JavascriptAsset|null
224
+	 */
225
+	public function getEditorScript()
226
+	{
227
+		return $this->assets->getJavascriptAsset($this->editor_script_handle);
228
+	}
229
+
230
+
231
+	/**
232
+	 * @return StylesheetAsset|null
233
+	 */
234
+	public function getEditorStyle()
235
+	{
236
+		return $this->assets->getStylesheetAsset($this->editor_style_handle);
237
+	}
238
+
239
+
240
+	/**
241
+	 * @return JavascriptAsset|null
242
+	 */
243
+	public function getScript()
244
+	{
245
+		return $this->assets->getJavascriptAsset($this->script_handle);
246
+	}
247
+
248
+
249
+	/**
250
+	 * @return StylesheetAsset|null
251
+	 */
252
+	public function getStyle()
253
+	{
254
+		return $this->assets->getStylesheetAsset($this->style_handle);
255
+	}
256
+
257
+
258
+	/**
259
+	 * @return  void
260
+	 */
261
+	public function enqueueAssets()
262
+	{
263
+		$assets = array(
264
+			$this->getEditorScript(),
265
+			$this->getEditorStyle(),
266
+			$this->getScript(),
267
+			$this->getStyle(),
268
+		);
269
+		foreach ($assets as $asset) {
270
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
271
+				$asset->enqueueAsset();
272
+			}
273
+		}
274
+	}
275 275
 
276 276
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function setEditorScriptHandle($editor_script_handle)
61 61
     {
62
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
63
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
63
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
64 64
         }
65 65
         $this->editor_script_handle = $editor_script_handle;
66 66
     }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function setEditorStyleHandle($editor_style_handle)
82 82
     {
83
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
84
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
84
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
85 85
         }
86 86
         $this->editor_style_handle = $editor_style_handle;
87 87
     }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function setScriptHandle($script_handle)
103 103
     {
104
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
105
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
105
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
106 106
         }
107 107
         $this->script_handle = $script_handle;
108 108
     }
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function setStyleHandle($style_handle)
124 124
     {
125
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
126
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
126
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
127 127
         }
128 128
         $this->style_handle = $style_handle;
129 129
     }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function addEditorScript($handle, array $dependencies = array())
156 156
     {
157
-        if ($this->assets->hasJavascriptAsset($handle)){
157
+        if ($this->assets->hasJavascriptAsset($handle)) {
158 158
             return $this->assets->getJavascriptAsset($handle);
159 159
         }
160 160
         $dependencies = array_merge(
Please login to merge, or discard this patch.
core/services/assets/AssetManager.php 1 patch
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -24,308 +24,308 @@
 block discarded – undo
24 24
 abstract class AssetManager implements AssetManagerInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var AssetCollection $assets
29
-     */
30
-    protected $assets;
31
-
32
-    /**
33
-     * @var DomainInterface
34
-     */
35
-    protected $domain;
36
-
37
-    /**
38
-     * @var Registry $registry
39
-     */
40
-    protected $registry;
41
-
42
-
43
-    /**
44
-     * AssetRegister constructor.
45
-     *
46
-     * @param DomainInterface $domain
47
-     * @param AssetCollection $assets
48
-     * @param Registry        $registry
49
-     */
50
-    public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
51
-    {
52
-        $this->domain = $domain;
53
-        $this->assets = $assets;
54
-        $this->registry = $registry;
55
-        add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
-        add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
57
-        add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
58
-        add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
59
-    }
60
-
61
-
62
-    /**
63
-     * @return AssetCollection
64
-     */
65
-    public function getAssets()
66
-    {
67
-        return $this->assets;
68
-    }
69
-
70
-
71
-    /**
72
-     * @since 4.9.71.p
73
-     * @return string
74
-     */
75
-    public function assetNamespace()
76
-    {
77
-        return $this->domain->assetNamespace();
78
-    }
79
-
80
-
81
-    /**
82
-     * @return void
83
-     * @throws DuplicateCollectionIdentifierException
84
-     * @throws InvalidDataTypeException
85
-     * @throws InvalidEntityException
86
-     * @since 4.9.62.p
87
-     */
88
-    public function addManifestFile()
89
-    {
90
-        // if a manifest file has already been added for this domain, then just return
91
-        if ($this->assets->has($this->domain->assetNamespace())) {
92
-            return;
93
-        }
94
-        $asset = new ManifestFile($this->domain);
95
-        $this->assets->add($asset, $this->domain->assetNamespace());
96
-    }
97
-
98
-
99
-    /**
100
-     * @return ManifestFile[]
101
-     * @since 4.9.62.p
102
-     */
103
-    public function getManifestFile()
104
-    {
105
-        return $this->assets->getManifestFiles();
106
-    }
107
-
108
-
109
-    /**
110
-     * @param string $handle
111
-     * @param string $source
112
-     * @param array  $dependencies
113
-     * @param bool   $load_in_footer
114
-     * @param string $version
115
-     * @return JavascriptAsset
116
-     * @throws DuplicateCollectionIdentifierException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidEntityException
119
-     * @throws DomainException
120
-     * @since 4.9.62.p
121
-     */
122
-    public function addJavascript(
123
-        $handle,
124
-        $source,
125
-        array $dependencies = array(),
126
-        $load_in_footer = true,
127
-        $version = ''
128
-    ) {
129
-        $asset = new JavascriptAsset(
130
-            $handle,
131
-            $source,
132
-            array_unique($dependencies),
133
-            $load_in_footer,
134
-            $this->domain,
135
-            $version
136
-        );
137
-        $this->assets->add($asset, $handle);
138
-        return $asset;
139
-    }
140
-
141
-
142
-    /**
143
-     * Used to register a javascript asset where everything is dynamically derived from the given handle.
144
-     *
145
-     * @param string       $handle
146
-     * @param string|array $extra_dependencies
147
-     * @return JavascriptAsset
148
-     * @throws DuplicateCollectionIdentifierException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @throws DomainException
152
-     */
153
-    public function addJs($handle, $extra_dependencies = [])
154
-    {
155
-        $details = $this->getAssetDetails(
156
-            Asset::TYPE_JS,
157
-            $handle,
158
-            $extra_dependencies
159
-        );
160
-        $source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
161
-        return $this->addJavascript(
162
-            $handle,
163
-            $source,
164
-            $details['dependencies'],
165
-            true,
166
-            $details['version']
167
-        );
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $handle
173
-     * @param array  $dependencies
174
-     * @param bool   $load_in_footer
175
-     * @param string $version
176
-     * @return JavascriptAsset
177
-     * @throws DomainException
178
-     * @throws DuplicateCollectionIdentifierException
179
-     * @throws InvalidDataTypeException
180
-     * @throws InvalidEntityException
181
-     * @since 4.9.71.p
182
-     */
183
-    public function addVendorJavascript(
184
-        $handle,
185
-        array $dependencies = array(),
186
-        $load_in_footer = true,
187
-        $version = ''
188
-    ) {
189
-        $dev_suffix = wp_scripts_get_suffix('dev');
190
-        $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
191
-        return $this->addJavascript(
192
-            $handle,
193
-            "{$vendor_path}{$handle}{$dev_suffix}.js",
194
-            $dependencies,
195
-            $load_in_footer,
196
-            $version
197
-        );
198
-    }
199
-
200
-
201
-    /**
202
-     * @param string $handle
203
-     * @param string $source
204
-     * @param array  $dependencies
205
-     * @param string $media
206
-     * @param string $version
207
-     * @return StylesheetAsset
208
-     * @throws DomainException
209
-     * @throws DuplicateCollectionIdentifierException
210
-     * @throws InvalidDataTypeException
211
-     * @throws InvalidEntityException
212
-     * @since 4.9.62.p
213
-     */
214
-    public function addStylesheet(
215
-        $handle,
216
-        $source,
217
-        array $dependencies = array(),
218
-        $media = 'all',
219
-        $version = ''
220
-    ) {
221
-        $asset = new StylesheetAsset(
222
-            $handle,
223
-            $source,
224
-            array_unique($dependencies),
225
-            $this->domain,
226
-            $media,
227
-            $version
228
-        );
229
-        $this->assets->add($asset, $handle);
230
-        return $asset;
231
-    }
232
-
233
-
234
-    /**
235
-     * Used to register a css asset where everything is dynamically derived from the given handle.
236
-     *
237
-     * @param string       $handle
238
-     * @param string|array $extra_dependencies
239
-     * @return StylesheetAsset
240
-     * @throws DuplicateCollectionIdentifierException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidEntityException
243
-     * @throws DomainException
244
-     */
245
-    public function addCss($handle, $extra_dependencies = [])
246
-    {
247
-        $details = $this->getAssetDetails(
248
-            Asset::TYPE_CSS,
249
-            $handle,
250
-            $extra_dependencies
251
-        );
252
-        return $this->addStylesheet(
253
-            $handle,
254
-            $this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
255
-            $details['dependencies'],
256
-            'all',
257
-            $details['version']
258
-        );
259
-    }
260
-
261
-
262
-    /**
263
-     * @param string $handle
264
-     * @return bool
265
-     * @since 4.9.62.p
266
-     */
267
-    public function enqueueAsset($handle)
268
-    {
269
-        if ($this->assets->has($handle)) {
270
-            $asset = $this->assets->get($handle);
271
-            if ($asset->isRegistered()) {
272
-                $asset->enqueueAsset();
273
-                return true;
274
-            }
275
-        }
276
-        return false;
277
-    }
278
-
279
-
280
-    /**
281
-     * @return  void
282
-     * @since   $VID:$
283
-     */
284
-    public function enqueueBrowserAssets()
285
-    {
286
-        foreach ($this->assets as $asset) {
287
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
288
-                $asset->enqueueAsset();
289
-            }
290
-        }
291
-    }
292
-
293
-
294
-    /**
295
-     * @param string $asset_type
296
-     * @param string $handle
297
-     * @param array  $extra_dependencies
298
-     * @return array
299
-     * @since 4.10.2.p
300
-     */
301
-    private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
302
-    {
303
-        $getAssetDetails = '';
304
-        switch ($asset_type) {
305
-            case Asset::TYPE_JS :
306
-                $getAssetDetails = 'getJsAssetDetails';
307
-                break;
308
-            case Asset::TYPE_CSS :
309
-                $getAssetDetails = 'getCssAssetDetails';
310
-                break;
311
-        }
312
-        if ($getAssetDetails === '') {
313
-            return ['dependencies' => [], 'version' => ''];
314
-        }
315
-        $details = $this->registry->$getAssetDetails(
316
-            $this->domain->assetNamespace(),
317
-            $handle
318
-        );
319
-        $details['dependencies'] = isset($details['dependencies'])
320
-            ? $details['dependencies']
321
-            : [];
322
-        $details['version'] = isset($details['version'])
323
-            ? $details['version']
324
-            : '';
325
-        $details['dependencies'] = ! empty($extra_dependencies)
326
-            ? array_merge($details['dependencies'], (array) $extra_dependencies)
327
-            : $details['dependencies'];
328
-        return $details;
329
-
330
-    }
27
+	/**
28
+	 * @var AssetCollection $assets
29
+	 */
30
+	protected $assets;
31
+
32
+	/**
33
+	 * @var DomainInterface
34
+	 */
35
+	protected $domain;
36
+
37
+	/**
38
+	 * @var Registry $registry
39
+	 */
40
+	protected $registry;
41
+
42
+
43
+	/**
44
+	 * AssetRegister constructor.
45
+	 *
46
+	 * @param DomainInterface $domain
47
+	 * @param AssetCollection $assets
48
+	 * @param Registry        $registry
49
+	 */
50
+	public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)
51
+	{
52
+		$this->domain = $domain;
53
+		$this->assets = $assets;
54
+		$this->registry = $registry;
55
+		add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0);
56
+		add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0);
57
+		add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2);
58
+		add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return AssetCollection
64
+	 */
65
+	public function getAssets()
66
+	{
67
+		return $this->assets;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @since 4.9.71.p
73
+	 * @return string
74
+	 */
75
+	public function assetNamespace()
76
+	{
77
+		return $this->domain->assetNamespace();
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return void
83
+	 * @throws DuplicateCollectionIdentifierException
84
+	 * @throws InvalidDataTypeException
85
+	 * @throws InvalidEntityException
86
+	 * @since 4.9.62.p
87
+	 */
88
+	public function addManifestFile()
89
+	{
90
+		// if a manifest file has already been added for this domain, then just return
91
+		if ($this->assets->has($this->domain->assetNamespace())) {
92
+			return;
93
+		}
94
+		$asset = new ManifestFile($this->domain);
95
+		$this->assets->add($asset, $this->domain->assetNamespace());
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return ManifestFile[]
101
+	 * @since 4.9.62.p
102
+	 */
103
+	public function getManifestFile()
104
+	{
105
+		return $this->assets->getManifestFiles();
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param string $handle
111
+	 * @param string $source
112
+	 * @param array  $dependencies
113
+	 * @param bool   $load_in_footer
114
+	 * @param string $version
115
+	 * @return JavascriptAsset
116
+	 * @throws DuplicateCollectionIdentifierException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidEntityException
119
+	 * @throws DomainException
120
+	 * @since 4.9.62.p
121
+	 */
122
+	public function addJavascript(
123
+		$handle,
124
+		$source,
125
+		array $dependencies = array(),
126
+		$load_in_footer = true,
127
+		$version = ''
128
+	) {
129
+		$asset = new JavascriptAsset(
130
+			$handle,
131
+			$source,
132
+			array_unique($dependencies),
133
+			$load_in_footer,
134
+			$this->domain,
135
+			$version
136
+		);
137
+		$this->assets->add($asset, $handle);
138
+		return $asset;
139
+	}
140
+
141
+
142
+	/**
143
+	 * Used to register a javascript asset where everything is dynamically derived from the given handle.
144
+	 *
145
+	 * @param string       $handle
146
+	 * @param string|array $extra_dependencies
147
+	 * @return JavascriptAsset
148
+	 * @throws DuplicateCollectionIdentifierException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @throws DomainException
152
+	 */
153
+	public function addJs($handle, $extra_dependencies = [])
154
+	{
155
+		$details = $this->getAssetDetails(
156
+			Asset::TYPE_JS,
157
+			$handle,
158
+			$extra_dependencies
159
+		);
160
+		$source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle);
161
+		return $this->addJavascript(
162
+			$handle,
163
+			$source,
164
+			$details['dependencies'],
165
+			true,
166
+			$details['version']
167
+		);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $handle
173
+	 * @param array  $dependencies
174
+	 * @param bool   $load_in_footer
175
+	 * @param string $version
176
+	 * @return JavascriptAsset
177
+	 * @throws DomainException
178
+	 * @throws DuplicateCollectionIdentifierException
179
+	 * @throws InvalidDataTypeException
180
+	 * @throws InvalidEntityException
181
+	 * @since 4.9.71.p
182
+	 */
183
+	public function addVendorJavascript(
184
+		$handle,
185
+		array $dependencies = array(),
186
+		$load_in_footer = true,
187
+		$version = ''
188
+	) {
189
+		$dev_suffix = wp_scripts_get_suffix('dev');
190
+		$vendor_path = $this->domain->pluginUrl() . 'assets/vendor/';
191
+		return $this->addJavascript(
192
+			$handle,
193
+			"{$vendor_path}{$handle}{$dev_suffix}.js",
194
+			$dependencies,
195
+			$load_in_footer,
196
+			$version
197
+		);
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param string $handle
203
+	 * @param string $source
204
+	 * @param array  $dependencies
205
+	 * @param string $media
206
+	 * @param string $version
207
+	 * @return StylesheetAsset
208
+	 * @throws DomainException
209
+	 * @throws DuplicateCollectionIdentifierException
210
+	 * @throws InvalidDataTypeException
211
+	 * @throws InvalidEntityException
212
+	 * @since 4.9.62.p
213
+	 */
214
+	public function addStylesheet(
215
+		$handle,
216
+		$source,
217
+		array $dependencies = array(),
218
+		$media = 'all',
219
+		$version = ''
220
+	) {
221
+		$asset = new StylesheetAsset(
222
+			$handle,
223
+			$source,
224
+			array_unique($dependencies),
225
+			$this->domain,
226
+			$media,
227
+			$version
228
+		);
229
+		$this->assets->add($asset, $handle);
230
+		return $asset;
231
+	}
232
+
233
+
234
+	/**
235
+	 * Used to register a css asset where everything is dynamically derived from the given handle.
236
+	 *
237
+	 * @param string       $handle
238
+	 * @param string|array $extra_dependencies
239
+	 * @return StylesheetAsset
240
+	 * @throws DuplicateCollectionIdentifierException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidEntityException
243
+	 * @throws DomainException
244
+	 */
245
+	public function addCss($handle, $extra_dependencies = [])
246
+	{
247
+		$details = $this->getAssetDetails(
248
+			Asset::TYPE_CSS,
249
+			$handle,
250
+			$extra_dependencies
251
+		);
252
+		return $this->addStylesheet(
253
+			$handle,
254
+			$this->registry->getCssUrl($this->domain->assetNamespace(), $handle),
255
+			$details['dependencies'],
256
+			'all',
257
+			$details['version']
258
+		);
259
+	}
260
+
261
+
262
+	/**
263
+	 * @param string $handle
264
+	 * @return bool
265
+	 * @since 4.9.62.p
266
+	 */
267
+	public function enqueueAsset($handle)
268
+	{
269
+		if ($this->assets->has($handle)) {
270
+			$asset = $this->assets->get($handle);
271
+			if ($asset->isRegistered()) {
272
+				$asset->enqueueAsset();
273
+				return true;
274
+			}
275
+		}
276
+		return false;
277
+	}
278
+
279
+
280
+	/**
281
+	 * @return  void
282
+	 * @since   $VID:$
283
+	 */
284
+	public function enqueueBrowserAssets()
285
+	{
286
+		foreach ($this->assets as $asset) {
287
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
288
+				$asset->enqueueAsset();
289
+			}
290
+		}
291
+	}
292
+
293
+
294
+	/**
295
+	 * @param string $asset_type
296
+	 * @param string $handle
297
+	 * @param array  $extra_dependencies
298
+	 * @return array
299
+	 * @since 4.10.2.p
300
+	 */
301
+	private function getAssetDetails($asset_type, $handle, $extra_dependencies = [])
302
+	{
303
+		$getAssetDetails = '';
304
+		switch ($asset_type) {
305
+			case Asset::TYPE_JS :
306
+				$getAssetDetails = 'getJsAssetDetails';
307
+				break;
308
+			case Asset::TYPE_CSS :
309
+				$getAssetDetails = 'getCssAssetDetails';
310
+				break;
311
+		}
312
+		if ($getAssetDetails === '') {
313
+			return ['dependencies' => [], 'version' => ''];
314
+		}
315
+		$details = $this->registry->$getAssetDetails(
316
+			$this->domain->assetNamespace(),
317
+			$handle
318
+		);
319
+		$details['dependencies'] = isset($details['dependencies'])
320
+			? $details['dependencies']
321
+			: [];
322
+		$details['version'] = isset($details['version'])
323
+			? $details['version']
324
+			: '';
325
+		$details['dependencies'] = ! empty($extra_dependencies)
326
+			? array_merge($details['dependencies'], (array) $extra_dependencies)
327
+			: $details['dependencies'];
328
+		return $details;
329
+
330
+	}
331 331
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +785 added lines, -785 removed lines patch added patch discarded remove patch
@@ -26,796 +26,796 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
-
31
-    /**
32
-     * @var AssetCollection $assets
33
-     */
34
-    protected $assets;
35
-
36
-    /**
37
-     * @var I18nRegistry
38
-     */
39
-    private $i18n_registry;
40
-
41
-    /**
42
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $jsdata = array();
47
-
48
-    /**
49
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
-     * page source.
51
-     *
52
-     * @var array
53
-     */
54
-    private $script_handles_with_data = array();
55
-
56
-
57
-    /**
58
-     * Holds the manifest data obtained from registered manifest files.
59
-     * Manifests are maps of asset chunk name to actual built asset file names.
60
-     * Shape of this array is:
61
-     * array(
62
-     *  'some_namespace_slug' => array(
63
-     *      'some_chunk_name' => array(
64
-     *          'js' => 'filename.js'
65
-     *          'css' => 'filename.js'
66
-     *      ),
67
-     *      'url_base' => 'https://baseurl.com/to/assets
68
-     *  )
69
-     * )
70
-     *
71
-     * @var array
72
-     */
73
-    private $manifest_data = array();
74
-
75
-
76
-    /**
77
-     * Holds any dependency data obtained from registered dependency map json.
78
-     * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
-     * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
-     *
81
-     * @var array
82
-     */
83
-    private $dependencies_data = [];
84
-
85
-
86
-    /**
87
-     * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
-     * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
-     * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
-     * are used for both js and css.
91
-     * @var array
92
-     */
93
-    private $wp_css_handle_dependencies = [
94
-        'wp-components',
95
-        'wp-block-editor',
96
-        'wp-block-library',
97
-        'wp-edit-post',
98
-        'wp-edit-widgets',
99
-        'wp-editor',
100
-        'wp-format-library',
101
-        'wp-list-reusable-blocks',
102
-        'wp-nux',
103
-    ];
104
-
105
-
106
-    /**
107
-     * Registry constructor.
108
-     * Hooking into WP actions for script registry.
109
-     *
110
-     * @param AssetCollection      $assets
111
-     * @param I18nRegistry         $i18n_registry
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     */
116
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
-    {
118
-        $this->assets = $assets;
119
-        $this->i18n_registry = $i18n_registry;
120
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
123
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
124
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 5);
125
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 5);
126
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
-    }
129
-
130
-
131
-    /**
132
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
-     * translation handling.
134
-     *
135
-     * @return I18nRegistry
136
-     */
137
-    public function getI18nRegistry()
138
-    {
139
-        return $this->i18n_registry;
140
-    }
141
-
142
-
143
-    /**
144
-     * Callback for the wp_enqueue_scripts actions used to register assets.
145
-     *
146
-     * @since 4.9.62.p
147
-     * @throws Exception
148
-     */
149
-    public function registerScriptsAndStyles()
150
-    {
151
-        try {
152
-            $this->registerScripts($this->assets->getJavascriptAssets());
153
-            $this->registerStyles($this->assets->getStylesheetAssets());
154
-        } catch (Exception $exception) {
155
-            new ExceptionStackTraceDisplay($exception);
156
-        }
157
-    }
158
-
159
-
160
-    /**
161
-     * Registers JS assets with WP core
162
-     *
163
-     * @param JavascriptAsset[] $scripts
164
-     * @throws AssetRegistrationException
165
-     * @throws InvalidDataTypeException
166
-     * @throws DomainException
167
-     * @since 4.9.62.p
168
-     */
169
-    public function registerScripts(array $scripts)
170
-    {
171
-        foreach ($scripts as $script) {
172
-            // skip to next script if this has already been done
173
-            if ($script->isRegistered()) {
174
-                continue;
175
-            }
176
-            do_action(
177
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
-                $script
179
-            );
180
-            $registered = wp_register_script(
181
-                $script->handle(),
182
-                $script->source(),
183
-                $script->dependencies(),
184
-                $script->version(),
185
-                $script->loadInFooter()
186
-            );
187
-            if (! $registered && $this->debug()) {
188
-                throw new AssetRegistrationException($script->handle());
189
-            }
190
-            $script->setRegistered($registered);
191
-            if ($script->requiresTranslation()) {
192
-                $this->registerTranslation($script->handle());
193
-            }
194
-            do_action(
195
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
-                $script
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * Registers CSS assets with WP core
204
-     *
205
-     * @param StylesheetAsset[] $styles
206
-     * @throws InvalidDataTypeException
207
-     * @throws DomainException
208
-     * @since 4.9.62.p
209
-     */
210
-    public function registerStyles(array $styles)
211
-    {
212
-        foreach ($styles as $style) {
213
-            // skip to next style if this has already been done
214
-            if ($style->isRegistered()) {
215
-                continue;
216
-            }
217
-            do_action(
218
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
-                $style
220
-            );
221
-            wp_register_style(
222
-                $style->handle(),
223
-                $style->source(),
224
-                $style->dependencies(),
225
-                $style->version(),
226
-                $style->media()
227
-            );
228
-            $style->setRegistered();
229
-            do_action(
230
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
-                $style
232
-            );
233
-        }
234
-    }
235
-
236
-
237
-    /**
238
-     * Call back for the script print in frontend and backend.
239
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
-     *
241
-     * @throws Exception
242
-     * @since 4.9.31.rc.015
243
-     */
244
-    public function enqueueData()
245
-    {
246
-        try {
247
-            $this->removeAlreadyRegisteredDataForScriptHandles();
248
-            wp_add_inline_script(
249
-                'eejs-core',
250
-                'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
251
-                'before'
252
-            );
253
-            $scripts = $this->assets->getJavascriptAssetsWithData();
254
-            foreach ($scripts as $script) {
255
-                $this->addRegisteredScriptHandlesWithData($script->handle());
256
-                if ($script->hasInlineDataCallback()) {
257
-                    $localize = $script->inlineDataCallback();
258
-                    $localize();
259
-                }
260
-            }
261
-        } catch (Exception $exception) {
262
-            EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
263
-            new ExceptionStackTraceDisplay($exception);
264
-        }
265
-    }
266
-
267
-
268
-    /**
269
-     * Used to add data to eejs.data object.
270
-     * Note:  Overriding existing data is not allowed.
271
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
272
-     * If the data you add is something like this:
273
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
274
-     * It will be exposed in the page source as:
275
-     *  eejs.data.my_plugin_data.foo == gar
276
-     *
277
-     * @param string       $key   Key used to access your data
278
-     * @param string|array $value Value to attach to key
279
-     * @throws InvalidArgumentException
280
-     */
281
-    public function addData($key, $value)
282
-    {
283
-        if ($this->verifyDataNotExisting($key)) {
284
-            $this->jsdata[ $key ] = $value;
285
-        }
286
-    }
287
-
288
-
289
-    /**
290
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
291
-     * elements in an array.
292
-     *
293
-     * When you use this method, the value you include will be merged with the array on $key.
294
-     * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
295
-     * object like this, eejs.data.test = [ my_data,
296
-     * ]
297
-     * If there has already been a scalar value attached to the data object given key (via addData for instance), then
298
-     * this will throw an exception.
299
-     *
300
-     * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
301
-     * key potentially overriding the existing data on merge (specifically with associative arrays).
302
-     *
303
-     * @param string       $key   Key to attach data to.
304
-     * @param string|array $value Value being registered.
305
-     * @throws InvalidArgumentException
306
-     */
307
-    public function pushData($key, $value)
308
-    {
309
-        if (isset($this->jsdata[ $key ])
310
-            && ! is_array($this->jsdata[ $key ])
311
-        ) {
312
-            if (! $this->debug()) {
313
-                return;
314
-            }
315
-            throw new InvalidArgumentException(
316
-                sprintf(
317
-                    __(
318
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
30
+
31
+	/**
32
+	 * @var AssetCollection $assets
33
+	 */
34
+	protected $assets;
35
+
36
+	/**
37
+	 * @var I18nRegistry
38
+	 */
39
+	private $i18n_registry;
40
+
41
+	/**
42
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $jsdata = array();
47
+
48
+	/**
49
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
50
+	 * page source.
51
+	 *
52
+	 * @var array
53
+	 */
54
+	private $script_handles_with_data = array();
55
+
56
+
57
+	/**
58
+	 * Holds the manifest data obtained from registered manifest files.
59
+	 * Manifests are maps of asset chunk name to actual built asset file names.
60
+	 * Shape of this array is:
61
+	 * array(
62
+	 *  'some_namespace_slug' => array(
63
+	 *      'some_chunk_name' => array(
64
+	 *          'js' => 'filename.js'
65
+	 *          'css' => 'filename.js'
66
+	 *      ),
67
+	 *      'url_base' => 'https://baseurl.com/to/assets
68
+	 *  )
69
+	 * )
70
+	 *
71
+	 * @var array
72
+	 */
73
+	private $manifest_data = array();
74
+
75
+
76
+	/**
77
+	 * Holds any dependency data obtained from registered dependency map json.
78
+	 * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
79
+	 * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
80
+	 *
81
+	 * @var array
82
+	 */
83
+	private $dependencies_data = [];
84
+
85
+
86
+	/**
87
+	 * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
88
+	 * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
89
+	 * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
90
+	 * are used for both js and css.
91
+	 * @var array
92
+	 */
93
+	private $wp_css_handle_dependencies = [
94
+		'wp-components',
95
+		'wp-block-editor',
96
+		'wp-block-library',
97
+		'wp-edit-post',
98
+		'wp-edit-widgets',
99
+		'wp-editor',
100
+		'wp-format-library',
101
+		'wp-list-reusable-blocks',
102
+		'wp-nux',
103
+	];
104
+
105
+
106
+	/**
107
+	 * Registry constructor.
108
+	 * Hooking into WP actions for script registry.
109
+	 *
110
+	 * @param AssetCollection      $assets
111
+	 * @param I18nRegistry         $i18n_registry
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 */
116
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
117
+	{
118
+		$this->assets = $assets;
119
+		$this->i18n_registry = $i18n_registry;
120
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
121
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
123
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 4);
124
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 5);
125
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 5);
126
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
127
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
128
+	}
129
+
130
+
131
+	/**
132
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
133
+	 * translation handling.
134
+	 *
135
+	 * @return I18nRegistry
136
+	 */
137
+	public function getI18nRegistry()
138
+	{
139
+		return $this->i18n_registry;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
145
+	 *
146
+	 * @since 4.9.62.p
147
+	 * @throws Exception
148
+	 */
149
+	public function registerScriptsAndStyles()
150
+	{
151
+		try {
152
+			$this->registerScripts($this->assets->getJavascriptAssets());
153
+			$this->registerStyles($this->assets->getStylesheetAssets());
154
+		} catch (Exception $exception) {
155
+			new ExceptionStackTraceDisplay($exception);
156
+		}
157
+	}
158
+
159
+
160
+	/**
161
+	 * Registers JS assets with WP core
162
+	 *
163
+	 * @param JavascriptAsset[] $scripts
164
+	 * @throws AssetRegistrationException
165
+	 * @throws InvalidDataTypeException
166
+	 * @throws DomainException
167
+	 * @since 4.9.62.p
168
+	 */
169
+	public function registerScripts(array $scripts)
170
+	{
171
+		foreach ($scripts as $script) {
172
+			// skip to next script if this has already been done
173
+			if ($script->isRegistered()) {
174
+				continue;
175
+			}
176
+			do_action(
177
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
+				$script
179
+			);
180
+			$registered = wp_register_script(
181
+				$script->handle(),
182
+				$script->source(),
183
+				$script->dependencies(),
184
+				$script->version(),
185
+				$script->loadInFooter()
186
+			);
187
+			if (! $registered && $this->debug()) {
188
+				throw new AssetRegistrationException($script->handle());
189
+			}
190
+			$script->setRegistered($registered);
191
+			if ($script->requiresTranslation()) {
192
+				$this->registerTranslation($script->handle());
193
+			}
194
+			do_action(
195
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
+				$script
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * Registers CSS assets with WP core
204
+	 *
205
+	 * @param StylesheetAsset[] $styles
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws DomainException
208
+	 * @since 4.9.62.p
209
+	 */
210
+	public function registerStyles(array $styles)
211
+	{
212
+		foreach ($styles as $style) {
213
+			// skip to next style if this has already been done
214
+			if ($style->isRegistered()) {
215
+				continue;
216
+			}
217
+			do_action(
218
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
219
+				$style
220
+			);
221
+			wp_register_style(
222
+				$style->handle(),
223
+				$style->source(),
224
+				$style->dependencies(),
225
+				$style->version(),
226
+				$style->media()
227
+			);
228
+			$style->setRegistered();
229
+			do_action(
230
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
231
+				$style
232
+			);
233
+		}
234
+	}
235
+
236
+
237
+	/**
238
+	 * Call back for the script print in frontend and backend.
239
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
240
+	 *
241
+	 * @throws Exception
242
+	 * @since 4.9.31.rc.015
243
+	 */
244
+	public function enqueueData()
245
+	{
246
+		try {
247
+			$this->removeAlreadyRegisteredDataForScriptHandles();
248
+			wp_add_inline_script(
249
+				'eejs-core',
250
+				'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
251
+				'before'
252
+			);
253
+			$scripts = $this->assets->getJavascriptAssetsWithData();
254
+			foreach ($scripts as $script) {
255
+				$this->addRegisteredScriptHandlesWithData($script->handle());
256
+				if ($script->hasInlineDataCallback()) {
257
+					$localize = $script->inlineDataCallback();
258
+					$localize();
259
+				}
260
+			}
261
+		} catch (Exception $exception) {
262
+			EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
263
+			new ExceptionStackTraceDisplay($exception);
264
+		}
265
+	}
266
+
267
+
268
+	/**
269
+	 * Used to add data to eejs.data object.
270
+	 * Note:  Overriding existing data is not allowed.
271
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
272
+	 * If the data you add is something like this:
273
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
274
+	 * It will be exposed in the page source as:
275
+	 *  eejs.data.my_plugin_data.foo == gar
276
+	 *
277
+	 * @param string       $key   Key used to access your data
278
+	 * @param string|array $value Value to attach to key
279
+	 * @throws InvalidArgumentException
280
+	 */
281
+	public function addData($key, $value)
282
+	{
283
+		if ($this->verifyDataNotExisting($key)) {
284
+			$this->jsdata[ $key ] = $value;
285
+		}
286
+	}
287
+
288
+
289
+	/**
290
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
291
+	 * elements in an array.
292
+	 *
293
+	 * When you use this method, the value you include will be merged with the array on $key.
294
+	 * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
295
+	 * object like this, eejs.data.test = [ my_data,
296
+	 * ]
297
+	 * If there has already been a scalar value attached to the data object given key (via addData for instance), then
298
+	 * this will throw an exception.
299
+	 *
300
+	 * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
301
+	 * key potentially overriding the existing data on merge (specifically with associative arrays).
302
+	 *
303
+	 * @param string       $key   Key to attach data to.
304
+	 * @param string|array $value Value being registered.
305
+	 * @throws InvalidArgumentException
306
+	 */
307
+	public function pushData($key, $value)
308
+	{
309
+		if (isset($this->jsdata[ $key ])
310
+			&& ! is_array($this->jsdata[ $key ])
311
+		) {
312
+			if (! $this->debug()) {
313
+				return;
314
+			}
315
+			throw new InvalidArgumentException(
316
+				sprintf(
317
+					__(
318
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
319 319
                          push values to this data element when it is an array.',
320
-                        'event_espresso'
321
-                    ),
322
-                    $key,
323
-                    __METHOD__
324
-                )
325
-            );
326
-        }
327
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
328
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
329
-        } else {
330
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
331
-        }
332
-    }
333
-
334
-
335
-    /**
336
-     * Used to set content used by javascript for a template.
337
-     * Note: Overrides of existing registered templates are not allowed.
338
-     *
339
-     * @param string $template_reference
340
-     * @param string $template_content
341
-     * @throws InvalidArgumentException
342
-     */
343
-    public function addTemplate($template_reference, $template_content)
344
-    {
345
-        if (! isset($this->jsdata['templates'])) {
346
-            $this->jsdata['templates'] = array();
347
-        }
348
-        //no overrides allowed.
349
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
350
-            if (! $this->debug()) {
351
-                return;
352
-            }
353
-            throw new InvalidArgumentException(
354
-                sprintf(
355
-                    __(
356
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
357
-                        'event_espresso'
358
-                    ),
359
-                    $template_reference
360
-                )
361
-            );
362
-        }
363
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
364
-    }
365
-
366
-
367
-    /**
368
-     * Retrieve the template content already registered for the given reference.
369
-     *
370
-     * @param string $template_reference
371
-     * @return string
372
-     */
373
-    public function getTemplate($template_reference)
374
-    {
375
-        return isset($this->jsdata['templates'][ $template_reference ])
376
-            ? $this->jsdata['templates'][ $template_reference ]
377
-            : '';
378
-    }
379
-
380
-
381
-    /**
382
-     * Retrieve registered data.
383
-     *
384
-     * @param string $key Name of key to attach data to.
385
-     * @return mixed                If there is no for the given key, then false is returned.
386
-     */
387
-    public function getData($key)
388
-    {
389
-        return isset($this->jsdata[ $key ])
390
-            ? $this->jsdata[ $key ]
391
-            : false;
392
-    }
393
-
394
-
395
-    /**
396
-     * Verifies whether the given data exists already on the jsdata array.
397
-     * Overriding data is not allowed.
398
-     *
399
-     * @param string $key Index for data.
400
-     * @return bool        If valid then return true.
401
-     * @throws InvalidArgumentException if data already exists.
402
-     */
403
-    protected function verifyDataNotExisting($key)
404
-    {
405
-        if (isset($this->jsdata[ $key ])) {
406
-            if (! $this->debug()) {
407
-                return false;
408
-            }
409
-            if (is_array($this->jsdata[ $key ])) {
410
-                throw new InvalidArgumentException(
411
-                    sprintf(
412
-                        __(
413
-                            'The value for %1$s already exists in the Registry::eejs object.
320
+						'event_espresso'
321
+					),
322
+					$key,
323
+					__METHOD__
324
+				)
325
+			);
326
+		}
327
+		if ( ! isset( $this->jsdata[ $key ] ) ) {
328
+			$this->jsdata[ $key ] = is_array($value) ? $value : [$value];
329
+		} else {
330
+			$this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
331
+		}
332
+	}
333
+
334
+
335
+	/**
336
+	 * Used to set content used by javascript for a template.
337
+	 * Note: Overrides of existing registered templates are not allowed.
338
+	 *
339
+	 * @param string $template_reference
340
+	 * @param string $template_content
341
+	 * @throws InvalidArgumentException
342
+	 */
343
+	public function addTemplate($template_reference, $template_content)
344
+	{
345
+		if (! isset($this->jsdata['templates'])) {
346
+			$this->jsdata['templates'] = array();
347
+		}
348
+		//no overrides allowed.
349
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
350
+			if (! $this->debug()) {
351
+				return;
352
+			}
353
+			throw new InvalidArgumentException(
354
+				sprintf(
355
+					__(
356
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
357
+						'event_espresso'
358
+					),
359
+					$template_reference
360
+				)
361
+			);
362
+		}
363
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
364
+	}
365
+
366
+
367
+	/**
368
+	 * Retrieve the template content already registered for the given reference.
369
+	 *
370
+	 * @param string $template_reference
371
+	 * @return string
372
+	 */
373
+	public function getTemplate($template_reference)
374
+	{
375
+		return isset($this->jsdata['templates'][ $template_reference ])
376
+			? $this->jsdata['templates'][ $template_reference ]
377
+			: '';
378
+	}
379
+
380
+
381
+	/**
382
+	 * Retrieve registered data.
383
+	 *
384
+	 * @param string $key Name of key to attach data to.
385
+	 * @return mixed                If there is no for the given key, then false is returned.
386
+	 */
387
+	public function getData($key)
388
+	{
389
+		return isset($this->jsdata[ $key ])
390
+			? $this->jsdata[ $key ]
391
+			: false;
392
+	}
393
+
394
+
395
+	/**
396
+	 * Verifies whether the given data exists already on the jsdata array.
397
+	 * Overriding data is not allowed.
398
+	 *
399
+	 * @param string $key Index for data.
400
+	 * @return bool        If valid then return true.
401
+	 * @throws InvalidArgumentException if data already exists.
402
+	 */
403
+	protected function verifyDataNotExisting($key)
404
+	{
405
+		if (isset($this->jsdata[ $key ])) {
406
+			if (! $this->debug()) {
407
+				return false;
408
+			}
409
+			if (is_array($this->jsdata[ $key ])) {
410
+				throw new InvalidArgumentException(
411
+					sprintf(
412
+						__(
413
+							'The value for %1$s already exists in the Registry::eejs object.
414 414
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
415 415
                             %2$s method to push your value to the array.',
416
-                            'event_espresso'
417
-                        ),
418
-                        $key,
419
-                        'pushData()'
420
-                    )
421
-                );
422
-            }
423
-            throw new InvalidArgumentException(
424
-                sprintf(
425
-                    __(
426
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
416
+							'event_espresso'
417
+						),
418
+						$key,
419
+						'pushData()'
420
+					)
421
+				);
422
+			}
423
+			throw new InvalidArgumentException(
424
+				sprintf(
425
+					__(
426
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
427 427
                         allowed.  Consider attaching your value to a different key',
428
-                        'event_espresso'
429
-                    ),
430
-                    $key
431
-                )
432
-            );
433
-        }
434
-        return true;
435
-    }
436
-
437
-
438
-    /**
439
-     * Get the actual asset path for asset manifests.
440
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
441
-     *
442
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
443
-     *                           asset file location.
444
-     * @param string $chunk_name
445
-     * @param string $asset_type
446
-     * @return string
447
-     * @since 4.9.59.p
448
-     */
449
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
450
-    {
451
-        $asset_index = $chunk_name . '.' . $asset_type;
452
-        $url = isset(
453
-            $this->manifest_data[ $namespace ][ $asset_index ],
454
-            $this->manifest_data[ $namespace ]['url_base']
455
-        )
456
-            ? $this->manifest_data[ $namespace ]['url_base']
457
-              . $this->manifest_data[ $namespace ][ $asset_index ]
458
-            : '';
459
-        return apply_filters(
460
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
461
-            $url,
462
-            $namespace,
463
-            $chunk_name,
464
-            $asset_type
465
-        );
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     * Return the url to a js file for the given namespace and chunk name.
472
-     *
473
-     * @param string $namespace
474
-     * @param string $chunk_name
475
-     * @return string
476
-     */
477
-    public function getJsUrl($namespace, $chunk_name)
478
-    {
479
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
480
-    }
481
-
482
-
483
-    /**
484
-     * Return the url to a css file for the given namespace and chunk name.
485
-     *
486
-     * @param string $namespace
487
-     * @param string $chunk_name
488
-     * @return string
489
-     */
490
-    public function getCssUrl($namespace, $chunk_name)
491
-    {
492
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
493
-    }
494
-
495
-
496
-    /**
497
-     * Return the dependencies array and version string for a given asset $chunk_name
498
-     *
499
-     * @param string $namespace
500
-     * @param string $chunk_name
501
-     * @param string $asset_type
502
-     * @return array
503
-     * @since 4.9.82.p
504
-     */
505
-    private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506
-    {
507
-        $asset_index = $chunk_name . '.' . $asset_type;
508
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
-            $path = isset($this->manifest_data[ $namespace ]['path'])
510
-                ? $this->manifest_data[ $namespace ]['path']
511
-                : '';
512
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
515
-                :
516
-                '';
517
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
518
-                ? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519
-                : [];
520
-        }
521
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
522
-    }
523
-
524
-
525
-    /**
526
-     * Return dependencies array and version string according to asset type.
527
-     * For css assets, this filters the auto generated dependencies by css type.
528
-     *
529
-     * @param string $namespace
530
-     * @param string $asset_type
531
-     * @param string $file_path
532
-     * @param string $chunk_name
533
-     * @return array
534
-     * @since 4.9.82.p
535
-     */
536
-    private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
537
-    {
538
-        // $asset_dependencies = json_decode(file_get_contents($file_path), true);
539
-        $asset_details = require($file_path);
540
-        $asset_details['dependencies'] = isset($asset_details['dependencies'])
541
-            ? $asset_details['dependencies']
542
-            : [];
543
-        $asset_details['version'] = isset($asset_details['version'])
544
-            ? $asset_details['version']
545
-            : '';
546
-        if ($asset_type === Asset::TYPE_JS) {
547
-            $asset_details['dependencies'] =  $chunk_name === 'eejs-core'
548
-                ? $asset_details['dependencies']
549
-                : $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
550
-            return $asset_details;
551
-        }
552
-        // for css we need to make sure there is actually a css file related to this chunk.
553
-        if (isset($this->manifest_data[ $namespace ])) {
554
-            // array of css chunk files for ee.
555
-            $css_chunks = array_map(
556
-                static function ($value) {
557
-                    return str_replace('.css', '', $value);
558
-                },
559
-                array_filter(
560
-                    array_keys($this->manifest_data[ $namespace ]),
561
-                    static function ($value) {
562
-                        return strpos($value, '.css') !== false;
563
-                    }
564
-                )
565
-            );
566
-            // add known wp chunks with css
567
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
568
-            // flip for easier search
569
-            $css_chunks = array_flip($css_chunks);
570
-
571
-            // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572
-            $asset_details['dependencies'] = array_filter(
573
-                $asset_details['dependencies'],
574
-                static function ($chunk_name) use ($css_chunks) {
575
-                    return isset($css_chunks[ $chunk_name ]);
576
-                }
577
-            );
578
-            return $asset_details;
579
-        }
580
-        return ['dependencies' => [], 'version' => ''];
581
-    }
582
-
583
-
584
-    /**
585
-     * Get the dependencies array and version string for the given js asset chunk name
586
-     *
587
-     * @param string $namespace
588
-     * @param string $chunk_name
589
-     * @return array
590
-     * @since 4.10.2.p
591
-     */
592
-    public function getJsAssetDetails($namespace, $chunk_name)
593
-    {
594
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
595
-    }
596
-
597
-
598
-    /**
599
-     * Get the dependencies array and version string for the given css asset chunk name
600
-     *
601
-     * @param string $namespace
602
-     * @param string $chunk_name
603
-     * @return array
604
-     * @since 4.10.2.p
605
-     */
606
-    public function getCssAssetDetails($namespace, $chunk_name)
607
-    {
608
-        return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
609
-    }
610
-
611
-
612
-    /**
613
-     * @throws Exception
614
-     * @throws InvalidArgumentException
615
-     * @throws InvalidFilePathException
616
-     * @since 4.9.62.p
617
-     */
618
-    public function registerManifestFiles()
619
-    {
620
-        try {
621
-            $manifest_files = $this->assets->getManifestFiles();
622
-            foreach ($manifest_files as $manifest_file) {
623
-                $this->registerManifestFile(
624
-                    $manifest_file->assetNamespace(),
625
-                    $manifest_file->urlBase(),
626
-                    $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
627
-                    $manifest_file->filepath()
628
-                );
629
-            }
630
-        } catch (Exception $exception) {
631
-            EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
632
-            new ExceptionStackTraceDisplay($exception);
633
-        }
634
-    }
635
-
636
-
637
-    /**
638
-     * Used to register a js/css manifest file with the registered_manifest_files property.
639
-     *
640
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
641
-     * @param string $url_base      The url base for the manifest file location.
642
-     * @param string $manifest_file The absolute path to the manifest file.
643
-     * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
644
-     *                                    default to `plugin_root/assets/dist`.
645
-     * @throws InvalidArgumentException
646
-     * @throws InvalidFilePathException
647
-     * @since 4.9.59.p
648
-     */
649
-    public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650
-    {
651
-        if (isset($this->manifest_data[ $namespace ])) {
652
-            if (! $this->debug()) {
653
-                return;
654
-            }
655
-            throw new InvalidArgumentException(
656
-                sprintf(
657
-                    esc_html__(
658
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
659
-                        'event_espresso'
660
-                    ),
661
-                    $namespace
662
-                )
663
-            );
664
-        }
665
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
666
-            if (is_admin()) {
667
-                EE_Error::add_error(
668
-                    sprintf(
669
-                        esc_html__(
670
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
671
-                            'event_espresso'
672
-                        ),
673
-                        'Event Espresso',
674
-                        $url_base,
675
-                        'plugins_url',
676
-                        'WP_PLUGIN_URL'
677
-                    ),
678
-                    __FILE__,
679
-                    __FUNCTION__,
680
-                    __LINE__
681
-                );
682
-            }
683
-            return;
684
-        }
685
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
-            $this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
688
-        }
689
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
-            $this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
691
-        }
692
-    }
693
-
694
-
695
-    /**
696
-     * Decodes json from the provided manifest file.
697
-     *
698
-     * @since 4.9.59.p
699
-     * @param string $manifest_file Path to manifest file.
700
-     * @return array
701
-     * @throws InvalidFilePathException
702
-     */
703
-    private function decodeManifestFile($manifest_file)
704
-    {
705
-        if (! file_exists($manifest_file)) {
706
-            throw new InvalidFilePathException($manifest_file);
707
-        }
708
-        return json_decode(file_get_contents($manifest_file), true);
709
-    }
710
-
711
-
712
-    /**
713
-     * This is used to set registered script handles that have data.
714
-     *
715
-     * @param string $script_handle
716
-     */
717
-    private function addRegisteredScriptHandlesWithData($script_handle)
718
-    {
719
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
720
-    }
721
-
722
-
723
-    /**i
428
+						'event_espresso'
429
+					),
430
+					$key
431
+				)
432
+			);
433
+		}
434
+		return true;
435
+	}
436
+
437
+
438
+	/**
439
+	 * Get the actual asset path for asset manifests.
440
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
441
+	 *
442
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
443
+	 *                           asset file location.
444
+	 * @param string $chunk_name
445
+	 * @param string $asset_type
446
+	 * @return string
447
+	 * @since 4.9.59.p
448
+	 */
449
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
450
+	{
451
+		$asset_index = $chunk_name . '.' . $asset_type;
452
+		$url = isset(
453
+			$this->manifest_data[ $namespace ][ $asset_index ],
454
+			$this->manifest_data[ $namespace ]['url_base']
455
+		)
456
+			? $this->manifest_data[ $namespace ]['url_base']
457
+			  . $this->manifest_data[ $namespace ][ $asset_index ]
458
+			: '';
459
+		return apply_filters(
460
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
461
+			$url,
462
+			$namespace,
463
+			$chunk_name,
464
+			$asset_type
465
+		);
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 * Return the url to a js file for the given namespace and chunk name.
472
+	 *
473
+	 * @param string $namespace
474
+	 * @param string $chunk_name
475
+	 * @return string
476
+	 */
477
+	public function getJsUrl($namespace, $chunk_name)
478
+	{
479
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
480
+	}
481
+
482
+
483
+	/**
484
+	 * Return the url to a css file for the given namespace and chunk name.
485
+	 *
486
+	 * @param string $namespace
487
+	 * @param string $chunk_name
488
+	 * @return string
489
+	 */
490
+	public function getCssUrl($namespace, $chunk_name)
491
+	{
492
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
493
+	}
494
+
495
+
496
+	/**
497
+	 * Return the dependencies array and version string for a given asset $chunk_name
498
+	 *
499
+	 * @param string $namespace
500
+	 * @param string $chunk_name
501
+	 * @param string $asset_type
502
+	 * @return array
503
+	 * @since 4.9.82.p
504
+	 */
505
+	private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506
+	{
507
+		$asset_index = $chunk_name . '.' . $asset_type;
508
+		if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
+			$path = isset($this->manifest_data[ $namespace ]['path'])
510
+				? $this->manifest_data[ $namespace ]['path']
511
+				: '';
512
+			$dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
+			$file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
+				? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
515
+				:
516
+				'';
517
+			$this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
518
+				? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519
+				: [];
520
+		}
521
+		return $this->dependencies_data[ $namespace ][ $asset_index ];
522
+	}
523
+
524
+
525
+	/**
526
+	 * Return dependencies array and version string according to asset type.
527
+	 * For css assets, this filters the auto generated dependencies by css type.
528
+	 *
529
+	 * @param string $namespace
530
+	 * @param string $asset_type
531
+	 * @param string $file_path
532
+	 * @param string $chunk_name
533
+	 * @return array
534
+	 * @since 4.9.82.p
535
+	 */
536
+	private function getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
537
+	{
538
+		// $asset_dependencies = json_decode(file_get_contents($file_path), true);
539
+		$asset_details = require($file_path);
540
+		$asset_details['dependencies'] = isset($asset_details['dependencies'])
541
+			? $asset_details['dependencies']
542
+			: [];
543
+		$asset_details['version'] = isset($asset_details['version'])
544
+			? $asset_details['version']
545
+			: '';
546
+		if ($asset_type === Asset::TYPE_JS) {
547
+			$asset_details['dependencies'] =  $chunk_name === 'eejs-core'
548
+				? $asset_details['dependencies']
549
+				: $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
550
+			return $asset_details;
551
+		}
552
+		// for css we need to make sure there is actually a css file related to this chunk.
553
+		if (isset($this->manifest_data[ $namespace ])) {
554
+			// array of css chunk files for ee.
555
+			$css_chunks = array_map(
556
+				static function ($value) {
557
+					return str_replace('.css', '', $value);
558
+				},
559
+				array_filter(
560
+					array_keys($this->manifest_data[ $namespace ]),
561
+					static function ($value) {
562
+						return strpos($value, '.css') !== false;
563
+					}
564
+				)
565
+			);
566
+			// add known wp chunks with css
567
+			$css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
568
+			// flip for easier search
569
+			$css_chunks = array_flip($css_chunks);
570
+
571
+			// now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572
+			$asset_details['dependencies'] = array_filter(
573
+				$asset_details['dependencies'],
574
+				static function ($chunk_name) use ($css_chunks) {
575
+					return isset($css_chunks[ $chunk_name ]);
576
+				}
577
+			);
578
+			return $asset_details;
579
+		}
580
+		return ['dependencies' => [], 'version' => ''];
581
+	}
582
+
583
+
584
+	/**
585
+	 * Get the dependencies array and version string for the given js asset chunk name
586
+	 *
587
+	 * @param string $namespace
588
+	 * @param string $chunk_name
589
+	 * @return array
590
+	 * @since 4.10.2.p
591
+	 */
592
+	public function getJsAssetDetails($namespace, $chunk_name)
593
+	{
594
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_JS);
595
+	}
596
+
597
+
598
+	/**
599
+	 * Get the dependencies array and version string for the given css asset chunk name
600
+	 *
601
+	 * @param string $namespace
602
+	 * @param string $chunk_name
603
+	 * @return array
604
+	 * @since 4.10.2.p
605
+	 */
606
+	public function getCssAssetDetails($namespace, $chunk_name)
607
+	{
608
+		return $this->getDetailsForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
609
+	}
610
+
611
+
612
+	/**
613
+	 * @throws Exception
614
+	 * @throws InvalidArgumentException
615
+	 * @throws InvalidFilePathException
616
+	 * @since 4.9.62.p
617
+	 */
618
+	public function registerManifestFiles()
619
+	{
620
+		try {
621
+			$manifest_files = $this->assets->getManifestFiles();
622
+			foreach ($manifest_files as $manifest_file) {
623
+				$this->registerManifestFile(
624
+					$manifest_file->assetNamespace(),
625
+					$manifest_file->urlBase(),
626
+					$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
627
+					$manifest_file->filepath()
628
+				);
629
+			}
630
+		} catch (Exception $exception) {
631
+			EE_Error::add_error($exception->getMessage(), __FILE__, __FUNCTION__, __LINE__);
632
+			new ExceptionStackTraceDisplay($exception);
633
+		}
634
+	}
635
+
636
+
637
+	/**
638
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
639
+	 *
640
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
641
+	 * @param string $url_base      The url base for the manifest file location.
642
+	 * @param string $manifest_file The absolute path to the manifest file.
643
+	 * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
644
+	 *                                    default to `plugin_root/assets/dist`.
645
+	 * @throws InvalidArgumentException
646
+	 * @throws InvalidFilePathException
647
+	 * @since 4.9.59.p
648
+	 */
649
+	public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650
+	{
651
+		if (isset($this->manifest_data[ $namespace ])) {
652
+			if (! $this->debug()) {
653
+				return;
654
+			}
655
+			throw new InvalidArgumentException(
656
+				sprintf(
657
+					esc_html__(
658
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
659
+						'event_espresso'
660
+					),
661
+					$namespace
662
+				)
663
+			);
664
+		}
665
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
666
+			if (is_admin()) {
667
+				EE_Error::add_error(
668
+					sprintf(
669
+						esc_html__(
670
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
671
+							'event_espresso'
672
+						),
673
+						'Event Espresso',
674
+						$url_base,
675
+						'plugins_url',
676
+						'WP_PLUGIN_URL'
677
+					),
678
+					__FILE__,
679
+					__FUNCTION__,
680
+					__LINE__
681
+				);
682
+			}
683
+			return;
684
+		}
685
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
+			$this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
688
+		}
689
+		if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
+			$this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
691
+		}
692
+	}
693
+
694
+
695
+	/**
696
+	 * Decodes json from the provided manifest file.
697
+	 *
698
+	 * @since 4.9.59.p
699
+	 * @param string $manifest_file Path to manifest file.
700
+	 * @return array
701
+	 * @throws InvalidFilePathException
702
+	 */
703
+	private function decodeManifestFile($manifest_file)
704
+	{
705
+		if (! file_exists($manifest_file)) {
706
+			throw new InvalidFilePathException($manifest_file);
707
+		}
708
+		return json_decode(file_get_contents($manifest_file), true);
709
+	}
710
+
711
+
712
+	/**
713
+	 * This is used to set registered script handles that have data.
714
+	 *
715
+	 * @param string $script_handle
716
+	 */
717
+	private function addRegisteredScriptHandlesWithData($script_handle)
718
+	{
719
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
720
+	}
721
+
722
+
723
+	/**i
724 724
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
725 725
      * Dependency stored in WP_Scripts if its set.
726 726
      */
727
-    private function removeAlreadyRegisteredDataForScriptHandles()
728
-    {
729
-        if (empty($this->script_handles_with_data)) {
730
-            return;
731
-        }
732
-        foreach ($this->script_handles_with_data as $script_handle) {
733
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
734
-        }
735
-    }
736
-
737
-
738
-    /**
739
-     * Removes any data dependency registered in WP_Scripts if its set.
740
-     *
741
-     * @param string $script_handle
742
-     */
743
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744
-    {
745
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
746
-            global $wp_scripts;
747
-            $unset_handle = false;
748
-            if ($wp_scripts->get_data($script_handle, 'data')) {
749
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
750
-                $unset_handle = true;
751
-            }
752
-            //deal with inline_scripts
753
-            if ($wp_scripts->get_data($script_handle, 'before')) {
754
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
755
-                $unset_handle = true;
756
-            }
757
-            if ($wp_scripts->get_data($script_handle, 'after')) {
758
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
759
-            }
760
-            if ($unset_handle) {
761
-                unset($this->script_handles_with_data[ $script_handle ]);
762
-            }
763
-        }
764
-    }
765
-
766
-
767
-    /**
768
-     * register translations for a registered script
769
-     *
770
-     * @param string $handle
771
-     */
772
-    public function registerTranslation($handle)
773
-    {
774
-        $this->i18n_registry->registerScriptI18n($handle);
775
-    }
776
-
777
-
778
-    /**
779
-     * @since 4.9.63.p
780
-     * @return bool
781
-     */
782
-    private function debug()
783
-    {
784
-        return apply_filters(
785
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
786
-            defined('EE_DEBUG') && EE_DEBUG
787
-        );
788
-    }
789
-
790
-
791
-    /**
792
-     * Get the dependencies array for the given js asset chunk name
793
-     *
794
-     * @param string $namespace
795
-     * @param string $chunk_name
796
-     * @return array
797
-     * @deprecated 4.10.2.p
798
-     * @since 4.9.82.p
799
-     */
800
-    public function getJsDependencies($namespace, $chunk_name)
801
-    {
802
-        $details = $this->getJsAssetDetails($namespace, $chunk_name);
803
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
804
-    }
805
-
806
-
807
-    /**
808
-     * Get the dependencies array for the given css asset chunk name
809
-     *
810
-     * @param string $namespace
811
-     * @param string $chunk_name
812
-     * @return array
813
-     * @deprecated 4.10.2.p
814
-     * @since      4.9.82.p
815
-     */
816
-    public function getCssDependencies($namespace, $chunk_name)
817
-    {
818
-        $details = $this->getCssAssetDetails($namespace, $chunk_name);
819
-        return isset($details['dependencies']) ? $details['dependencies'] : [];
820
-    }
727
+	private function removeAlreadyRegisteredDataForScriptHandles()
728
+	{
729
+		if (empty($this->script_handles_with_data)) {
730
+			return;
731
+		}
732
+		foreach ($this->script_handles_with_data as $script_handle) {
733
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
734
+		}
735
+	}
736
+
737
+
738
+	/**
739
+	 * Removes any data dependency registered in WP_Scripts if its set.
740
+	 *
741
+	 * @param string $script_handle
742
+	 */
743
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744
+	{
745
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
746
+			global $wp_scripts;
747
+			$unset_handle = false;
748
+			if ($wp_scripts->get_data($script_handle, 'data')) {
749
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
750
+				$unset_handle = true;
751
+			}
752
+			//deal with inline_scripts
753
+			if ($wp_scripts->get_data($script_handle, 'before')) {
754
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
755
+				$unset_handle = true;
756
+			}
757
+			if ($wp_scripts->get_data($script_handle, 'after')) {
758
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
759
+			}
760
+			if ($unset_handle) {
761
+				unset($this->script_handles_with_data[ $script_handle ]);
762
+			}
763
+		}
764
+	}
765
+
766
+
767
+	/**
768
+	 * register translations for a registered script
769
+	 *
770
+	 * @param string $handle
771
+	 */
772
+	public function registerTranslation($handle)
773
+	{
774
+		$this->i18n_registry->registerScriptI18n($handle);
775
+	}
776
+
777
+
778
+	/**
779
+	 * @since 4.9.63.p
780
+	 * @return bool
781
+	 */
782
+	private function debug()
783
+	{
784
+		return apply_filters(
785
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
786
+			defined('EE_DEBUG') && EE_DEBUG
787
+		);
788
+	}
789
+
790
+
791
+	/**
792
+	 * Get the dependencies array for the given js asset chunk name
793
+	 *
794
+	 * @param string $namespace
795
+	 * @param string $chunk_name
796
+	 * @return array
797
+	 * @deprecated 4.10.2.p
798
+	 * @since 4.9.82.p
799
+	 */
800
+	public function getJsDependencies($namespace, $chunk_name)
801
+	{
802
+		$details = $this->getJsAssetDetails($namespace, $chunk_name);
803
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
804
+	}
805
+
806
+
807
+	/**
808
+	 * Get the dependencies array for the given css asset chunk name
809
+	 *
810
+	 * @param string $namespace
811
+	 * @param string $chunk_name
812
+	 * @return array
813
+	 * @deprecated 4.10.2.p
814
+	 * @since      4.9.82.p
815
+	 */
816
+	public function getCssDependencies($namespace, $chunk_name)
817
+	{
818
+		$details = $this->getCssAssetDetails($namespace, $chunk_name);
819
+		return isset($details['dependencies']) ? $details['dependencies'] : [];
820
+	}
821 821
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 $script->version(),
185 185
                 $script->loadInFooter()
186 186
             );
187
-            if (! $registered && $this->debug()) {
187
+            if ( ! $registered && $this->debug()) {
188 188
                 throw new AssetRegistrationException($script->handle());
189 189
             }
190 190
             $script->setRegistered($registered);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $this->removeAlreadyRegisteredDataForScriptHandles();
248 248
             wp_add_inline_script(
249 249
                 'eejs-core',
250
-                'var eejsdata=' . wp_json_encode(['data' => $this->jsdata]),
250
+                'var eejsdata='.wp_json_encode(['data' => $this->jsdata]),
251 251
                 'before'
252 252
             );
253 253
             $scripts = $this->assets->getJavascriptAssetsWithData();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     public function addData($key, $value)
282 282
     {
283 283
         if ($this->verifyDataNotExisting($key)) {
284
-            $this->jsdata[ $key ] = $value;
284
+            $this->jsdata[$key] = $value;
285 285
         }
286 286
     }
287 287
 
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function pushData($key, $value)
308 308
     {
309
-        if (isset($this->jsdata[ $key ])
310
-            && ! is_array($this->jsdata[ $key ])
309
+        if (isset($this->jsdata[$key])
310
+            && ! is_array($this->jsdata[$key])
311 311
         ) {
312
-            if (! $this->debug()) {
312
+            if ( ! $this->debug()) {
313 313
                 return;
314 314
             }
315 315
             throw new InvalidArgumentException(
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
                 )
325 325
             );
326 326
         }
327
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
328
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
327
+        if ( ! isset($this->jsdata[$key])) {
328
+            $this->jsdata[$key] = is_array($value) ? $value : [$value];
329 329
         } else {
330
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
330
+            $this->jsdata[$key] = array_merge($this->jsdata[$key], (array) $value);
331 331
         }
332 332
     }
333 333
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function addTemplate($template_reference, $template_content)
344 344
     {
345
-        if (! isset($this->jsdata['templates'])) {
345
+        if ( ! isset($this->jsdata['templates'])) {
346 346
             $this->jsdata['templates'] = array();
347 347
         }
348 348
         //no overrides allowed.
349
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
350
-            if (! $this->debug()) {
349
+        if (isset($this->jsdata['templates'][$template_reference])) {
350
+            if ( ! $this->debug()) {
351 351
                 return;
352 352
             }
353 353
             throw new InvalidArgumentException(
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 )
361 361
             );
362 362
         }
363
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
363
+        $this->jsdata['templates'][$template_reference] = $template_content;
364 364
     }
365 365
 
366 366
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function getTemplate($template_reference)
374 374
     {
375
-        return isset($this->jsdata['templates'][ $template_reference ])
376
-            ? $this->jsdata['templates'][ $template_reference ]
375
+        return isset($this->jsdata['templates'][$template_reference])
376
+            ? $this->jsdata['templates'][$template_reference]
377 377
             : '';
378 378
     }
379 379
 
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public function getData($key)
388 388
     {
389
-        return isset($this->jsdata[ $key ])
390
-            ? $this->jsdata[ $key ]
389
+        return isset($this->jsdata[$key])
390
+            ? $this->jsdata[$key]
391 391
             : false;
392 392
     }
393 393
 
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
      */
403 403
     protected function verifyDataNotExisting($key)
404 404
     {
405
-        if (isset($this->jsdata[ $key ])) {
406
-            if (! $this->debug()) {
405
+        if (isset($this->jsdata[$key])) {
406
+            if ( ! $this->debug()) {
407 407
                 return false;
408 408
             }
409
-            if (is_array($this->jsdata[ $key ])) {
409
+            if (is_array($this->jsdata[$key])) {
410 410
                 throw new InvalidArgumentException(
411 411
                     sprintf(
412 412
                         __(
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function getAssetUrl($namespace, $chunk_name, $asset_type)
450 450
     {
451
-        $asset_index = $chunk_name . '.' . $asset_type;
451
+        $asset_index = $chunk_name.'.'.$asset_type;
452 452
         $url = isset(
453
-            $this->manifest_data[ $namespace ][ $asset_index ],
454
-            $this->manifest_data[ $namespace ]['url_base']
453
+            $this->manifest_data[$namespace][$asset_index],
454
+            $this->manifest_data[$namespace]['url_base']
455 455
         )
456
-            ? $this->manifest_data[ $namespace ]['url_base']
457
-              . $this->manifest_data[ $namespace ][ $asset_index ]
456
+            ? $this->manifest_data[$namespace]['url_base']
457
+              . $this->manifest_data[$namespace][$asset_index]
458 458
             : '';
459 459
         return apply_filters(
460 460
             'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
@@ -504,21 +504,21 @@  discard block
 block discarded – undo
504 504
      */
505 505
     private function getDetailsForAsset($namespace, $chunk_name, $asset_type)
506 506
     {
507
-        $asset_index = $chunk_name . '.' . $asset_type;
508
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
509
-            $path = isset($this->manifest_data[ $namespace ]['path'])
510
-                ? $this->manifest_data[ $namespace ]['path']
507
+        $asset_index = $chunk_name.'.'.$asset_type;
508
+        if ( ! isset($this->dependencies_data[$namespace][$asset_index])) {
509
+            $path = isset($this->manifest_data[$namespace]['path'])
510
+                ? $this->manifest_data[$namespace]['path']
511 511
                 : '';
512
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_PHP;
513
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
514
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
512
+            $dependencies_index = $chunk_name.'.'.Asset::TYPE_PHP;
513
+            $file_path = isset($this->manifest_data[$namespace][$dependencies_index])
514
+                ? $path.$this->manifest_data[$namespace][$dependencies_index]
515 515
                 :
516 516
                 '';
517
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
517
+            $this->dependencies_data[$namespace][$asset_index] = $file_path !== '' && file_exists($file_path)
518 518
                 ? $this->getDetailsForAssetType($namespace, $asset_type, $file_path, $chunk_name)
519 519
                 : [];
520 520
         }
521
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
521
+        return $this->dependencies_data[$namespace][$asset_index];
522 522
     }
523 523
 
524 524
 
@@ -544,35 +544,35 @@  discard block
 block discarded – undo
544 544
             ? $asset_details['version']
545 545
             : '';
546 546
         if ($asset_type === Asset::TYPE_JS) {
547
-            $asset_details['dependencies'] =  $chunk_name === 'eejs-core'
547
+            $asset_details['dependencies'] = $chunk_name === 'eejs-core'
548 548
                 ? $asset_details['dependencies']
549
-                : $asset_details['dependencies'] + [ CoreAssetManager::JS_HANDLE_JS_CORE ];
549
+                : $asset_details['dependencies'] + [CoreAssetManager::JS_HANDLE_JS_CORE];
550 550
             return $asset_details;
551 551
         }
552 552
         // for css we need to make sure there is actually a css file related to this chunk.
553
-        if (isset($this->manifest_data[ $namespace ])) {
553
+        if (isset($this->manifest_data[$namespace])) {
554 554
             // array of css chunk files for ee.
555 555
             $css_chunks = array_map(
556
-                static function ($value) {
556
+                static function($value) {
557 557
                     return str_replace('.css', '', $value);
558 558
                 },
559 559
                 array_filter(
560
-                    array_keys($this->manifest_data[ $namespace ]),
561
-                    static function ($value) {
560
+                    array_keys($this->manifest_data[$namespace]),
561
+                    static function($value) {
562 562
                         return strpos($value, '.css') !== false;
563 563
                     }
564 564
                 )
565 565
             );
566 566
             // add known wp chunks with css
567
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
567
+            $css_chunks = array_merge($css_chunks, $this->wp_css_handle_dependencies);
568 568
             // flip for easier search
569 569
             $css_chunks = array_flip($css_chunks);
570 570
 
571 571
             // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
572 572
             $asset_details['dependencies'] = array_filter(
573 573
                 $asset_details['dependencies'],
574
-                static function ($chunk_name) use ($css_chunks) {
575
-                    return isset($css_chunks[ $chunk_name ]);
574
+                static function($chunk_name) use ($css_chunks) {
575
+                    return isset($css_chunks[$chunk_name]);
576 576
                 }
577 577
             );
578 578
             return $asset_details;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                 $this->registerManifestFile(
624 624
                     $manifest_file->assetNamespace(),
625 625
                     $manifest_file->urlBase(),
626
-                    $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
626
+                    $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST,
627 627
                     $manifest_file->filepath()
628 628
                 );
629 629
             }
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
      */
649 649
     public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
650 650
     {
651
-        if (isset($this->manifest_data[ $namespace ])) {
652
-            if (! $this->debug()) {
651
+        if (isset($this->manifest_data[$namespace])) {
652
+            if ( ! $this->debug()) {
653 653
                 return;
654 654
             }
655 655
             throw new InvalidArgumentException(
@@ -682,12 +682,12 @@  discard block
 block discarded – undo
682 682
             }
683 683
             return;
684 684
         }
685
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
686
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
687
-            $this->manifest_data[ $namespace ]['url_base'] = untrailingslashit($url_base);
685
+        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
686
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
687
+            $this->manifest_data[$namespace]['url_base'] = untrailingslashit($url_base);
688 688
         }
689
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
690
-            $this->manifest_data[ $namespace ]['path'] = untrailingslashit($manifest_file_path);
689
+        if ( ! isset($this->manifest_data[$namespace]['path'])) {
690
+            $this->manifest_data[$namespace]['path'] = untrailingslashit($manifest_file_path);
691 691
         }
692 692
     }
693 693
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      */
703 703
     private function decodeManifestFile($manifest_file)
704 704
     {
705
-        if (! file_exists($manifest_file)) {
705
+        if ( ! file_exists($manifest_file)) {
706 706
             throw new InvalidFilePathException($manifest_file);
707 707
         }
708 708
         return json_decode(file_get_contents($manifest_file), true);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
      */
717 717
     private function addRegisteredScriptHandlesWithData($script_handle)
718 718
     {
719
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
719
+        $this->script_handles_with_data[$script_handle] = $script_handle;
720 720
     }
721 721
 
722 722
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
      */
743 743
     private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
744 744
     {
745
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
745
+        if (isset($this->script_handles_with_data[$script_handle])) {
746 746
             global $wp_scripts;
747 747
             $unset_handle = false;
748 748
             if ($wp_scripts->get_data($script_handle, 'data')) {
749
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
749
+                unset($wp_scripts->registered[$script_handle]->extra['data']);
750 750
                 $unset_handle = true;
751 751
             }
752 752
             //deal with inline_scripts
753 753
             if ($wp_scripts->get_data($script_handle, 'before')) {
754
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
754
+                unset($wp_scripts->registered[$script_handle]->extra['before']);
755 755
                 $unset_handle = true;
756 756
             }
757 757
             if ($wp_scripts->get_data($script_handle, 'after')) {
758
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
758
+                unset($wp_scripts->registered[$script_handle]->extra['after']);
759 759
             }
760 760
             if ($unset_handle) {
761
-                unset($this->script_handles_with_data[ $script_handle ]);
761
+                unset($this->script_handles_with_data[$script_handle]);
762 762
             }
763 763
         }
764 764
     }
Please login to merge, or discard this patch.
core/services/routing/RouteInterface.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -19,50 +19,50 @@
 block discarded – undo
19 19
 interface RouteInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @return JsonDataNode
24
-     */
25
-    public function dataNode();
22
+	/**
23
+	 * @return JsonDataNode
24
+	 */
25
+	public function dataNode();
26 26
 
27 27
 
28
-    /**
29
-     * final method called by RouteHandler on Route which in turn calls requestHandler()
30
-     *
31
-     * @return bool
32
-     * @since   $VID:$
33
-     */
34
-    public function handleRequest();
28
+	/**
29
+	 * final method called by RouteHandler on Route which in turn calls requestHandler()
30
+	 *
31
+	 * @return bool
32
+	 * @since   $VID:$
33
+	 */
34
+	public function handleRequest();
35 35
 
36 36
 
37
-    /**
38
-     * a place to run any setup required for matchesCurrentRequest() which runs immediately after
39
-     *
40
-     * @since $VID:$
41
-     */
42
-    public function initialize();
37
+	/**
38
+	 * a place to run any setup required for matchesCurrentRequest() which runs immediately after
39
+	 *
40
+	 * @since $VID:$
41
+	 */
42
+	public function initialize();
43 43
 
44 44
 
45
-    /**
46
-     * returns true if the route has already been handled
47
-     *
48
-     * @return bool
49
-     */
50
-    public function isHandled();
45
+	/**
46
+	 * returns true if the route has already been handled
47
+	 *
48
+	 * @return bool
49
+	 */
50
+	public function isHandled();
51 51
 
52 52
 
53
-    /**
54
-     * returns true if the route has not yet been handled
55
-     *
56
-     * @return bool
57
-     */
58
-    public function isNotHandled();
53
+	/**
54
+	 * returns true if the route has not yet been handled
55
+	 *
56
+	 * @return bool
57
+	 */
58
+	public function isNotHandled();
59 59
 
60 60
 
61
-    /**
62
-     * returns true if the current request matches this route
63
-     *
64
-     * @return bool
65
-     * @since   $VID:$
66
-     */
67
-    public function matchesCurrentRequest();
61
+	/**
62
+	 * returns true if the current request matches this route
63
+	 *
64
+	 * @return bool
65
+	 * @since   $VID:$
66
+	 */
67
+	public function matchesCurrentRequest();
68 68
 }
Please login to merge, or discard this patch.
core/services/routing/RouteCollection.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
 class RouteCollection extends Collection
18 18
 {
19 19
 
20
-    const COLLECTION_NAME = 'routes';
20
+	const COLLECTION_NAME = 'routes';
21 21
 
22 22
 
23
-    /**
24
-     * RouteMatchSpecificationCollection constructor
25
-     *
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public function __construct()
29
-    {
30
-        parent::__construct(
31
-            'EventEspresso\core\services\routing\RouteInterface',
32
-            RouteCollection::COLLECTION_NAME
33
-        );
34
-    }
23
+	/**
24
+	 * RouteMatchSpecificationCollection constructor
25
+	 *
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public function __construct()
29
+	{
30
+		parent::__construct(
31
+			'EventEspresso\core\services\routing\RouteInterface',
32
+			RouteCollection::COLLECTION_NAME
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * getIdentifier
39
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
40
-     * If no $identifier is supplied, then the  fully qualified class name is used
41
-     *
42
-     * @param        $object
43
-     * @param mixed  $identifier
44
-     * @return bool
45
-     */
46
-    public function getIdentifier($object, $identifier = null)
47
-    {
48
-        return ! empty($identifier)
49
-            ? $identifier
50
-            : get_class($object);
51
-    }
37
+	/**
38
+	 * getIdentifier
39
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
40
+	 * If no $identifier is supplied, then the  fully qualified class name is used
41
+	 *
42
+	 * @param        $object
43
+	 * @param mixed  $identifier
44
+	 * @return bool
45
+	 */
46
+	public function getIdentifier($object, $identifier = null)
47
+	{
48
+		return ! empty($identifier)
49
+			? $identifier
50
+			: get_class($object);
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * finds and returns all Routes that have yet to be handled
56
-     *
57
-     * @return RouteInterface[]
58
-     */
59
-    public function getRoutesForCurrentRequest()
60
-    {
61
-        $routes = [];
62
-        $this->rewind();
63
-        while ($this->valid()) {
64
-            /** @var RouteInterface $route */
65
-            $route = $this->current();
66
-            if ($route->matchesCurrentRequest()) {
67
-                $routes[] = $route;
68
-            }
69
-            $this->next();
70
-        }
71
-        $this->rewind();
72
-        return $routes;
73
-    }
54
+	/**
55
+	 * finds and returns all Routes that have yet to be handled
56
+	 *
57
+	 * @return RouteInterface[]
58
+	 */
59
+	public function getRoutesForCurrentRequest()
60
+	{
61
+		$routes = [];
62
+		$this->rewind();
63
+		while ($this->valid()) {
64
+			/** @var RouteInterface $route */
65
+			$route = $this->current();
66
+			if ($route->matchesCurrentRequest()) {
67
+				$routes[] = $route;
68
+			}
69
+			$this->next();
70
+		}
71
+		$this->rewind();
72
+		return $routes;
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * calls RouteInterface::handleRequest() on all Routes that
78
-     *      - match current request
79
-     *      - have yet to be handled
80
-     *
81
-     * @return void
82
-     */
83
-    public function handleRoutesForCurrentRequest()
84
-    {
85
-        $this->rewind();
86
-        while ($this->valid()) {
87
-            $this->current()->handleRequest();
88
-            $this->next();
89
-        }
90
-        $this->rewind();
91
-    }
76
+	/**
77
+	 * calls RouteInterface::handleRequest() on all Routes that
78
+	 *      - match current request
79
+	 *      - have yet to be handled
80
+	 *
81
+	 * @return void
82
+	 */
83
+	public function handleRoutesForCurrentRequest()
84
+	{
85
+		$this->rewind();
86
+		while ($this->valid()) {
87
+			$this->current()->handleRequest();
88
+			$this->next();
89
+		}
90
+		$this->rewind();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
core/services/routing/Route.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -25,182 +25,182 @@
 block discarded – undo
25 25
 abstract class Route implements RouteInterface
26 26
 {
27 27
 
28
-    /**
29
-     * @var AssetManagerInterface $asset_manager
30
-     */
31
-    protected $asset_manager;
32
-
33
-    /**
34
-     * @var EE_Dependency_Map $dependency_map
35
-     */
36
-    protected $dependency_map;
37
-
38
-    /**
39
-     * @var JsonDataNode $data_node
40
-     */
41
-    protected $data_node;
42
-
43
-    /**
44
-     * @var LoaderInterface $loader
45
-     */
46
-    protected $loader;
47
-
48
-    /**
49
-     * @var RequestInterface $request
50
-     */
51
-    protected $request;
52
-
53
-    /**
54
-     * @var RouteMatchSpecificationInterface $specification
55
-     */
56
-    protected $specification;
57
-
58
-    /**
59
-     * @var boolean $handled
60
-     */
61
-    private $handled = false;
62
-
63
-
64
-    /**
65
-     * Route constructor.
66
-     *
67
-     * @param EE_Dependency_Map                $dependency_map
68
-     * @param LoaderInterface                  $loader
69
-     * @param RequestInterface                 $request
70
-     * @param JsonDataNode                     $data_node
71
-     * @param RouteMatchSpecificationInterface $specification
72
-     */
73
-    public function __construct(
74
-        EE_Dependency_Map $dependency_map,
75
-        LoaderInterface $loader,
76
-        RequestInterface $request,
77
-        JsonDataNode $data_node = null,
78
-        RouteMatchSpecificationInterface $specification = null
79
-    ) {
80
-        $this->dependency_map = $dependency_map;
81
-        $this->data_node = $data_node;
82
-        $this->loader = $loader;
83
-        $this->request = $request;
84
-        $this->specification = $specification;
85
-    }
86
-
87
-
88
-    /**
89
-     * @since $VID:$
90
-     */
91
-    abstract protected function registerDependencies();
92
-
93
-
94
-    /**
95
-     * implements logic required to run during request
96
-     *
97
-     * @return bool
98
-     * @since   $VID:$
99
-     */
100
-    abstract protected function requestHandler();
101
-
102
-
103
-    /**
104
-     * @param JsonDataNode $data_node
105
-     */
106
-    protected function setDataNode($data_node)
107
-    {
108
-        $this->data_node = $data_node;
109
-    }
110
-
111
-
112
-    /**
113
-     * @param RouteMatchSpecificationInterface $specification
114
-     */
115
-    protected function setSpecification($specification)
116
-    {
117
-        $this->specification = $specification;
118
-    }
119
-
120
-
121
-    /**
122
-     * @return JsonDataNode
123
-     */
124
-    public function dataNode()
125
-    {
126
-        return $this->data_node;
127
-    }
128
-
129
-
130
-    /**
131
-     * runs route requestHandler() if
132
-     *      - route has not previously been handled
133
-     *      - route specification matches for current request
134
-     * sets route handled property based on results returned by requestHandler()
135
-     *
136
-     * @return bool
137
-     * @since   $VID:$
138
-     */
139
-    public function handleRequest()
140
-    {
141
-        if ($this->isNotHandled()) {
142
-            $this->initialize();
143
-            if ($this->matchesCurrentRequest()) {
144
-                do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this);
145
-                $this->registerDependencies();
146
-                $handled = $this->requestHandler();
147
-                if (! is_bool($handled)) {
148
-                    throw new DomainException(
149
-                        esc_html__(
150
-                            'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.',
151
-                            'event_espresso'
152
-                        )
153
-                    );
154
-                }
155
-                $this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN);
156
-            }
157
-        }
158
-        return $this->handled;
159
-    }
160
-
161
-
162
-    /**
163
-     * called just before matchesCurrentRequest()
164
-     * and allows Route to perform any setup required such as calling setSpecification()
165
-     *
166
-     * @since $VID:$
167
-     */
168
-    public function initialize()
169
-    {
170
-        // do nothing by default
171
-    }
172
-
173
-
174
-    /**
175
-     * @return bool
176
-     */
177
-    final public function isHandled()
178
-    {
179
-        return $this->handled;
180
-    }
181
-
182
-
183
-    /**
184
-     * @return bool
185
-     */
186
-    final public function isNotHandled()
187
-    {
188
-        return ! $this->handled;
189
-    }
190
-
191
-
192
-    /**
193
-     * returns true if the current request matches this route
194
-     * child classes can override and use Request directly to match route with request
195
-     * or supply a RouteMatchSpecification class and just use the below
196
-     *
197
-     * @return bool
198
-     * @since   $VID:$
199
-     */
200
-    public function matchesCurrentRequest()
201
-    {
202
-        return $this->specification instanceof RouteMatchSpecificationInterface
203
-            ? $this->specification->isMatchingRoute()
204
-            : false;
205
-    }
28
+	/**
29
+	 * @var AssetManagerInterface $asset_manager
30
+	 */
31
+	protected $asset_manager;
32
+
33
+	/**
34
+	 * @var EE_Dependency_Map $dependency_map
35
+	 */
36
+	protected $dependency_map;
37
+
38
+	/**
39
+	 * @var JsonDataNode $data_node
40
+	 */
41
+	protected $data_node;
42
+
43
+	/**
44
+	 * @var LoaderInterface $loader
45
+	 */
46
+	protected $loader;
47
+
48
+	/**
49
+	 * @var RequestInterface $request
50
+	 */
51
+	protected $request;
52
+
53
+	/**
54
+	 * @var RouteMatchSpecificationInterface $specification
55
+	 */
56
+	protected $specification;
57
+
58
+	/**
59
+	 * @var boolean $handled
60
+	 */
61
+	private $handled = false;
62
+
63
+
64
+	/**
65
+	 * Route constructor.
66
+	 *
67
+	 * @param EE_Dependency_Map                $dependency_map
68
+	 * @param LoaderInterface                  $loader
69
+	 * @param RequestInterface                 $request
70
+	 * @param JsonDataNode                     $data_node
71
+	 * @param RouteMatchSpecificationInterface $specification
72
+	 */
73
+	public function __construct(
74
+		EE_Dependency_Map $dependency_map,
75
+		LoaderInterface $loader,
76
+		RequestInterface $request,
77
+		JsonDataNode $data_node = null,
78
+		RouteMatchSpecificationInterface $specification = null
79
+	) {
80
+		$this->dependency_map = $dependency_map;
81
+		$this->data_node = $data_node;
82
+		$this->loader = $loader;
83
+		$this->request = $request;
84
+		$this->specification = $specification;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @since $VID:$
90
+	 */
91
+	abstract protected function registerDependencies();
92
+
93
+
94
+	/**
95
+	 * implements logic required to run during request
96
+	 *
97
+	 * @return bool
98
+	 * @since   $VID:$
99
+	 */
100
+	abstract protected function requestHandler();
101
+
102
+
103
+	/**
104
+	 * @param JsonDataNode $data_node
105
+	 */
106
+	protected function setDataNode($data_node)
107
+	{
108
+		$this->data_node = $data_node;
109
+	}
110
+
111
+
112
+	/**
113
+	 * @param RouteMatchSpecificationInterface $specification
114
+	 */
115
+	protected function setSpecification($specification)
116
+	{
117
+		$this->specification = $specification;
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return JsonDataNode
123
+	 */
124
+	public function dataNode()
125
+	{
126
+		return $this->data_node;
127
+	}
128
+
129
+
130
+	/**
131
+	 * runs route requestHandler() if
132
+	 *      - route has not previously been handled
133
+	 *      - route specification matches for current request
134
+	 * sets route handled property based on results returned by requestHandler()
135
+	 *
136
+	 * @return bool
137
+	 * @since   $VID:$
138
+	 */
139
+	public function handleRequest()
140
+	{
141
+		if ($this->isNotHandled()) {
142
+			$this->initialize();
143
+			if ($this->matchesCurrentRequest()) {
144
+				do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this);
145
+				$this->registerDependencies();
146
+				$handled = $this->requestHandler();
147
+				if (! is_bool($handled)) {
148
+					throw new DomainException(
149
+						esc_html__(
150
+							'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.',
151
+							'event_espresso'
152
+						)
153
+					);
154
+				}
155
+				$this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN);
156
+			}
157
+		}
158
+		return $this->handled;
159
+	}
160
+
161
+
162
+	/**
163
+	 * called just before matchesCurrentRequest()
164
+	 * and allows Route to perform any setup required such as calling setSpecification()
165
+	 *
166
+	 * @since $VID:$
167
+	 */
168
+	public function initialize()
169
+	{
170
+		// do nothing by default
171
+	}
172
+
173
+
174
+	/**
175
+	 * @return bool
176
+	 */
177
+	final public function isHandled()
178
+	{
179
+		return $this->handled;
180
+	}
181
+
182
+
183
+	/**
184
+	 * @return bool
185
+	 */
186
+	final public function isNotHandled()
187
+	{
188
+		return ! $this->handled;
189
+	}
190
+
191
+
192
+	/**
193
+	 * returns true if the current request matches this route
194
+	 * child classes can override and use Request directly to match route with request
195
+	 * or supply a RouteMatchSpecification class and just use the below
196
+	 *
197
+	 * @return bool
198
+	 * @since   $VID:$
199
+	 */
200
+	public function matchesCurrentRequest()
201
+	{
202
+		return $this->specification instanceof RouteMatchSpecificationInterface
203
+			? $this->specification->isMatchingRoute()
204
+			: false;
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@
 block discarded – undo
144 144
                 do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this);
145 145
                 $this->registerDependencies();
146 146
                 $handled = $this->requestHandler();
147
-                if (! is_bool($handled)) {
147
+                if ( ! is_bool($handled)) {
148 148
                     throw new DomainException(
149 149
                         esc_html__(
150 150
                             'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.',
Please login to merge, or discard this patch.
core/services/routing/RouteHandler.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -20,122 +20,122 @@
 block discarded – undo
20 20
 class RouteHandler
21 21
 {
22 22
 
23
-    /**
24
-     * @var JsonDataNodeHandler $data_node_handler
25
-     */
26
-    private $data_node_handler;
27
-
28
-    /**
29
-     * @var LoaderInterface $loader
30
-     */
31
-    private $loader;
32
-
33
-    /**
34
-     * @var RequestInterface $request
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RouteCollection $routes
40
-     */
41
-    private $routes;
42
-
43
-
44
-    /**
45
-     * RouteHandler constructor.
46
-     *
47
-     * @param JsonDataNodeHandler $data_node_handler
48
-     * @param LoaderInterface  $loader
49
-     * @param RequestInterface $request
50
-     * @param RouteCollection $routes
51
-     */
52
-    public function __construct(
53
-        JsonDataNodeHandler $data_node_handler,
54
-        LoaderInterface $loader,
55
-        RequestInterface $request,
56
-        RouteCollection $routes
57
-    ) {
58
-        $this->data_node_handler = $data_node_handler;
59
-        $this->loader = $loader;
60
-        $this->request = $request;
61
-        $this->routes = $routes;
62
-        add_action('admin_footer', [$this->data_node_handler, 'printDataNode']);
63
-        add_action('wp_footer', [$this->data_node_handler, 'printDataNode']);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param string $fqcn   Fully Qualified Class Name for Route
69
-     * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
70
-     * @throws Exception
71
-     * @since $VID:$
72
-     */
73
-    public function addRoute($fqcn, $handle = true)
74
-    {
75
-        try {
76
-            if ($this->request->isActivation()) {
77
-                return;
78
-            }
79
-            $route = $this->loader->getShared($fqcn);
80
-            $this->validateRoute($route, $fqcn);
81
-            $this->routes->add($route);
82
-            $this->handle($route, $handle);
83
-        } catch (Exception $exception) {
84
-            new ExceptionStackTraceDisplay($exception);
85
-        }
86
-    }
87
-
88
-
89
-    /**
90
-     * @param RouteInterface $route
91
-     * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest()
92
-     */
93
-    public function handle(RouteInterface $route, $handle = true)
94
-    {
95
-        if ($handle && $route->isNotHandled()) {
96
-            $route->handleRequest();
97
-            $data_node = $route->dataNode();
98
-            if ($data_node instanceof JsonDataNode) {
99
-                $this->data_node_handler->addDataNode($data_node);
100
-            }
101
-        }
102
-    }
103
-
104
-
105
-    /**
106
-     * calls RouteInterface::handleRequest() on all Routes that
107
-     *      - match current request
108
-     *      - have yet to be handled
109
-     *
110
-     * @return void
111
-     */
112
-    public function handleRoutesForCurrentRequest()
113
-    {
114
-        $this->routes->handleRoutesForCurrentRequest();
115
-    }
116
-
117
-
118
-    /**
119
-     * @param RouteInterface $route
120
-     * @param string         $fqcn
121
-     * @since $VID:$
122
-     */
123
-    private function validateRoute($route, $fqcn)
124
-    {
125
-        if (! $route instanceof RouteInterface) {
126
-            throw new InvalidClassException(
127
-                sprintf(
128
-                /*
23
+	/**
24
+	 * @var JsonDataNodeHandler $data_node_handler
25
+	 */
26
+	private $data_node_handler;
27
+
28
+	/**
29
+	 * @var LoaderInterface $loader
30
+	 */
31
+	private $loader;
32
+
33
+	/**
34
+	 * @var RequestInterface $request
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RouteCollection $routes
40
+	 */
41
+	private $routes;
42
+
43
+
44
+	/**
45
+	 * RouteHandler constructor.
46
+	 *
47
+	 * @param JsonDataNodeHandler $data_node_handler
48
+	 * @param LoaderInterface  $loader
49
+	 * @param RequestInterface $request
50
+	 * @param RouteCollection $routes
51
+	 */
52
+	public function __construct(
53
+		JsonDataNodeHandler $data_node_handler,
54
+		LoaderInterface $loader,
55
+		RequestInterface $request,
56
+		RouteCollection $routes
57
+	) {
58
+		$this->data_node_handler = $data_node_handler;
59
+		$this->loader = $loader;
60
+		$this->request = $request;
61
+		$this->routes = $routes;
62
+		add_action('admin_footer', [$this->data_node_handler, 'printDataNode']);
63
+		add_action('wp_footer', [$this->data_node_handler, 'printDataNode']);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param string $fqcn   Fully Qualified Class Name for Route
69
+	 * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
70
+	 * @throws Exception
71
+	 * @since $VID:$
72
+	 */
73
+	public function addRoute($fqcn, $handle = true)
74
+	{
75
+		try {
76
+			if ($this->request->isActivation()) {
77
+				return;
78
+			}
79
+			$route = $this->loader->getShared($fqcn);
80
+			$this->validateRoute($route, $fqcn);
81
+			$this->routes->add($route);
82
+			$this->handle($route, $handle);
83
+		} catch (Exception $exception) {
84
+			new ExceptionStackTraceDisplay($exception);
85
+		}
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param RouteInterface $route
91
+	 * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest()
92
+	 */
93
+	public function handle(RouteInterface $route, $handle = true)
94
+	{
95
+		if ($handle && $route->isNotHandled()) {
96
+			$route->handleRequest();
97
+			$data_node = $route->dataNode();
98
+			if ($data_node instanceof JsonDataNode) {
99
+				$this->data_node_handler->addDataNode($data_node);
100
+			}
101
+		}
102
+	}
103
+
104
+
105
+	/**
106
+	 * calls RouteInterface::handleRequest() on all Routes that
107
+	 *      - match current request
108
+	 *      - have yet to be handled
109
+	 *
110
+	 * @return void
111
+	 */
112
+	public function handleRoutesForCurrentRequest()
113
+	{
114
+		$this->routes->handleRoutesForCurrentRequest();
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param RouteInterface $route
120
+	 * @param string         $fqcn
121
+	 * @since $VID:$
122
+	 */
123
+	private function validateRoute($route, $fqcn)
124
+	{
125
+		if (! $route instanceof RouteInterface) {
126
+			throw new InvalidClassException(
127
+				sprintf(
128
+				/*
129 129
                  * translators:
130 130
                  * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface.
131 131
                 */
132
-                    esc_html__(
133
-                        'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
134
-                        'event_espresso'
135
-                    ),
136
-                    $fqcn
137
-                )
138
-            );
139
-        }
140
-    }
132
+					esc_html__(
133
+						'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
134
+						'event_espresso'
135
+					),
136
+					$fqcn
137
+				)
138
+			);
139
+		}
140
+	}
141 141
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
      */
123 123
     private function validateRoute($route, $fqcn)
124 124
     {
125
-        if (! $route instanceof RouteInterface) {
125
+        if ( ! $route instanceof RouteInterface) {
126 126
             throw new InvalidClassException(
127 127
                 sprintf(
128 128
                 /*
Please login to merge, or discard this patch.