You are here

function lightning_media_update_8013 in Lightning Media 8.4

Same name and namespace in other branches
  1. 8 lightning_media.install \lightning_media_update_8013()
  2. 8.2 lightning_media.install \lightning_media_update_8013()
  3. 8.3 lightning_media.install \lightning_media_update_8013()

Adds the media.embedded view display to the media_browser embed button.

File

./lightning_media.install, line 217
Contains install and update routines for Lightning Media.

Code

function lightning_media_update_8013() {
  $button = EmbedButton::load('media_browser');
  if ($button) {

    // During installation, the media.embedded view mode may have just been
    // created as part of this module's default configuration. So we need to
    // clear Entity Embed's display plugin definition cache to ensure that it
    // picks up the new view mode's corresponding display plugin.
    \Drupal::service('plugin.manager.entity_embed.display')
      ->clearCachedDefinitions();
    $type_settings = $button
      ->getTypeSettings();
    $type_settings['display_plugins'][] = 'view_mode:media.embedded';
    $button
      ->set('type_settings', $type_settings);
    $button
      ->save();
  }
}