media_expire.post_update.php in Media Expire 8
Same filename and directory in other branches
Install file.
File
media_expire.post_update.phpView source
<?php
/**
* @file
* Install file.
*/
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
/**
* Update fallback image configuration.
*/
function media_expire_post_update_fallback_id(&$sandbox = NULL) {
$mediaStorage = \Drupal::entityTypeManager()
->getStorage('media');
\Drupal::classResolver(ConfigEntityUpdater::class)
->update($sandbox, 'media_bundle', function ($bundle) use ($mediaStorage) {
/** @var \Drupal\media_entity\Entity\MediaBundle $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;
}
}
});
}
Functions
Name | Description |
---|---|
media_expire_post_update_fallback_id | Update fallback image configuration. |