You are here

public function Update240::installVideoFileMedia in Lightning Media 8.4

Same name and namespace in other branches
  1. 8.2 modules/lightning_media_video/src/Update/Update240.php \Drupal\lightning_media_video\Update\Update240::installVideoFileMedia()
  2. 8.3 modules/lightning_media_video/src/Update/Update240.php \Drupal\lightning_media_video\Update\Update240::installVideoFileMedia()

Installs a media type for locally hosted video files.

@update

@ask Do you want to install the "Video file" media type?

File

modules/lightning_media_video/src/Update/Update240.php, line 21

Class

Update240
Contains optional updates targeting Lightning Media Video 2.4.0.

Namespace

Drupal\lightning_media_video\Update

Code

public function installVideoFileMedia() {
  $helper = ConfigHelper::forModule('lightning_media_video')
    ->optional();
  $helper
    ->getEntity('media_type', 'video')
    ->save();
  $helper
    ->getEntity('field_storage_config', 'media.field_media_video_file')
    ->save();
  $helper
    ->getEntity('field_config', 'media.video.field_media_video_file')
    ->save();
  $helper
    ->getEntity('field_config', 'media.video.field_media_in_library')
    ->save();
  $helper
    ->getEntity('entity_view_display', 'media.video.embedded')
    ->save();
  $helper
    ->getEntity('entity_view_display', 'media.video.thumbnail')
    ->save();

  // Handle entity displays as simple config, since they are created
  // automatically when the media type is imported.
  $helper
    ->get('core.entity_form_display.media.video.default')
    ->save(TRUE);
  $helper
    ->get('core.entity_view_display.media.video.default')
    ->save(TRUE);
}