function thunder_liveblog_update_8101 in Thunder 8.2
Adds image to the list of available paragraphs.
File
- modules/
thunder_liveblog/ thunder_liveblog.install, line 68 - The install file.
Code
function thunder_liveblog_update_8101() {
/** @var \Drupal\update_helper\Updater $updater */
$updater = \Drupal::service('update_helper.updater');
$updateLogger = $updater
->logger();
/** @var \Drupal\field\Entity\FieldConfig $field */
$field = FieldConfig::load('liveblog_post.liveblog_post.field_embed_media');
if ($field) {
$settings = $field
->getSetting('handler_settings');
$settings['target_bundles']['image'] = 'image';
$settings['target_bundles_drag_drop']['image'] = [
'enabled' => TRUE,
'weight' => -17,
];
$field
->setSetting('handler_settings', $settings);
try {
$field
->save();
$updateLogger
->info(t('Image paragraph added to the liveblog post field "embed_media".'));
} catch (Exception $e) {
$updateLogger
->error(t('There was an error, while saving the liveblog post field "embed_media", please try to add the image paragraph manually.'));
}
}
else {
$updateLogger
->warning(t('Liveblog post field "embed_media" was not found. Please try to add the image paragraph manually.'));
}
// Output logged result of update hook execution.
return $updateLogger
->output();
}