File tree 2 files changed +26
-4
lines changed
web/profiles/custom/yalesites_profile/modules/custom/ys_embed
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface {
21
21
/**
22
22
* {@inheritdoc}
23
23
*/
24
- protected static $ pattern = '/^https:\/\/app.powerbi.com\/(?<type>view|reportEmbed)(?<query_params >\?.+)/ ' ;
24
+ protected static $ pattern = '/^https:\/\/app.powerbi.com\/(?<type>view|reportEmbed)(?<form_params >\?.+)/ ' ;
25
25
26
26
/**
27
27
* {@inheritdoc}
28
28
*/
29
- protected static $ template = '<iframe class="iframe" title="{{ title }}" src="https://app.powerbi.com/{{ type }}{{ query_params }}" height="100%" width="100%" loading="lazy"></iframe> ' ;
29
+ protected static $ template = '<iframe class="iframe" title="{{ title }}" src="https://app.powerbi.com/{{ type }}{{ form_params }}" height="100%" width="100%" loading="lazy"></iframe> ' ;
30
30
31
31
/**
32
32
* {@inheritdoc}
@@ -74,8 +74,8 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface {
74
74
*/
75
75
public function getUrl (array $ params ): string {
76
76
$ type = $ params ['type ' ];
77
- $ query_params = $ params ['query_params ' ];
78
- return 'https://app.powerbi.com/ ' . $ type . $ query_params ;
77
+ $ form_params = $ params ['form_params ' ];
78
+ return 'https://app.powerbi.com/ ' . $ type . $ form_params ;
79
79
}
80
80
81
81
}
Original file line number Diff line number Diff line change @@ -179,3 +179,25 @@ function _copy_embed_file($filename) {
179
179
180
180
return TRUE;
181
181
}
182
+
183
+ /**
184
+ * Updates existing Power BI embeds to add new type parameter.
185
+ */
186
+ function ys_embed_update_9006() {
187
+ $media_storage = \Drupal::entityTypeManager()->getStorage('media');
188
+
189
+ $power_bi_embeds = $media_storage->loadByProperties([
190
+ 'bundle' => 'embed',
191
+ 'field_media_embed.embed_source' => 'powerbi',
192
+ ]);
193
+
194
+ foreach ($power_bi_embeds as $embed) {
195
+ /** @var \Drupal\media\Entity\Media $embed */
196
+ $field_value = $embed->get('field_media_embed')->getValue();
197
+ if (!isset($field_value[0]['params']['type'])) {
198
+ $field_value[0]['params']['type'] = 'view';
199
+ $embed->set('field_media_embed', $field_value);
200
+ $embed->save();
201
+ }
202
+ }
203
+ }
You can’t perform that action at this time.
0 commit comments