diff --git a/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/src/Plugin/EmbedSource/PowerBI.php b/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/src/Plugin/EmbedSource/PowerBI.php index ca91c6399..1a8fc6a4f 100644 --- a/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/src/Plugin/EmbedSource/PowerBI.php +++ b/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/src/Plugin/EmbedSource/PowerBI.php @@ -21,12 +21,12 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface { /** * {@inheritdoc} */ - protected static $pattern = '/^https:\/\/app.powerbi.com\/(?view|reportEmbed)(?\?.+)/'; + protected static $pattern = '/^https:\/\/app.powerbi.com\/(?view|reportEmbed)(?\?.+)/'; /** * {@inheritdoc} */ - protected static $template = ''; + protected static $template = ''; /** * {@inheritdoc} @@ -74,8 +74,8 @@ class PowerBI extends EmbedSourceBase implements EmbedSourceInterface { */ public function getUrl(array $params): string { $type = $params['type']; - $query_params = $params['query_params']; - return 'https://app.powerbi.com/' . $type . $query_params; + $form_params = $params['form_params']; + return 'https://app.powerbi.com/' . $type . $form_params; } } diff --git a/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/ys_embed.install b/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/ys_embed.install index c80aae3c6..45ebbe1d8 100644 --- a/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/ys_embed.install +++ b/web/profiles/custom/yalesites_profile/modules/custom/ys_embed/ys_embed.install @@ -179,3 +179,25 @@ function _copy_embed_file($filename) { return TRUE; } + +/** + * Updates existing Power BI embeds to add new type parameter. + */ +function ys_embed_update_9006() { + $media_storage = \Drupal::entityTypeManager()->getStorage('media'); + + $power_bi_embeds = $media_storage->loadByProperties([ + 'bundle' => 'embed', + 'field_media_embed.embed_source' => 'powerbi', + ]); + + foreach ($power_bi_embeds as $embed) { + /** @var \Drupal\media\Entity\Media $embed */ + $field_value = $embed->get('field_media_embed')->getValue(); + if (!isset($field_value[0]['params']['type'])) { + $field_value[0]['params']['type'] = 'view'; + $embed->set('field_media_embed', $field_value); + $embed->save(); + } + } +}