function lightning_media_video_update_8003 in Lightning Media 8.4
Same name and namespace in other branches
- 8 modules/lightning_media_video/lightning_media_video.install \lightning_media_video_update_8003()
- 8.2 modules/lightning_media_video/lightning_media_video.install \lightning_media_video_update_8003()
- 8.3 modules/lightning_media_video/lightning_media_video.install \lightning_media_video_update_8003()
Creates the thumbnail display for remote videos.
1 call to lightning_media_video_update_8003()
- Update8003Test::testUpdate in modules/
lightning_media_video/ tests/ src/ Kernel/ Update8003Test.php - Tests the update function.
File
- modules/
lightning_media_video/ lightning_media_video.install, line 32 - Contains install and update routines for Lightning Media Video.
Code
function lightning_media_video_update_8003() {
// In Lightning Media 4, the video media type was renamed to remote_video.
// This update existed prior to Lightning Media 4, so we need to ensure that
// the thumbnail view display is created for the existing media type.
$view_display = EntityViewDisplay::load('media.video.thumbnail');
// Only create the view display if it hasn't been created already.
if (empty($view_display)) {
$media_type = MediaType::load('video');
// Adapt the view display we ship for the remote_video media type, so that
// it works with the video media type.
$values = Config::forModule('lightning_media_video')
->optional()
->read('core.entity_view_display.media.remote_video.thumbnail');
$values['bundle'] = $media_type
->id();
unset($values['id'], $values['dependencies'], $values['hidden']['field_media_oembed_video']);
EntityViewDisplay::create($values)
->removeComponent($media_type
->getSource()
->getSourceFieldDefinition($media_type)
->getName())
->save();
}
}