function media_expire_post_update_fallback_id in Media Expire 8.2
Same name and namespace in other branches
- 8 media_expire.post_update.php \media_expire_post_update_fallback_id()
Update fallback image configuration.
File
- ./
media_expire.post_update.php, line 13 - Install file.
Code
function media_expire_post_update_fallback_id(&$sandbox = NULL) {
$mediaStorage = \Drupal::entityTypeManager()
->getStorage('media');
\Drupal::classResolver(ConfigEntityUpdater::class)
->update($sandbox, 'media_type', function ($bundle) use ($mediaStorage) {
/** @var \Drupal\media\Entity\MediaType $bundle */
$fallback_media = $bundle
->getThirdPartySetting('media_expire', 'fallback_media');
if (!empty($fallback_media)) {
if ($media = $mediaStorage
->load($fallback_media)) {
$bundle
->setThirdPartySetting('media_expire', 'fallback_media', $media
->uuid());
return TRUE;
}
}
});
}