function thunder_media_update_8103 in Thunder 8.2
Adjust instagrams preview in backend.
File
- modules/
thunder_media/ thunder_media.install, line 801 - Contains.
Code
function thunder_media_update_8103() {
/** @var \Drupal\update_helper\Updater $updater */
$updater = \Drupal::service('update_helper.updater');
$updateLogger = $updater
->logger();
// List of configurations that should be checked for existence.
$expectedConfig['hidden']['thumbnail'] = TRUE;
$expectedConfig['content']['field_url'] = [
'type' => 'instagram_embed',
'weight' => 0,
'label' => 'hidden',
'settings' => [
'width' => 241,
'height' => 313,
],
'third_party_settings' => [],
];
// New configuration that should be applied.
$newConfig['content']['thumbnail'] = [
'type' => 'image',
'weight' => 0,
'region' => 'content',
'label' => 'hidden',
'settings' => [
'image_style' => 'media_thumbnail',
'image_link' => '',
],
'third_party_settings' => [],
];
$successfulUpdate = TRUE;
if (_thunder_media_update_config('core.entity_view_display.media.instagram.thumbnail', $newConfig, $expectedConfig)) {
$display = EntityViewDisplay::load('media.instagram.thumbnail');
$display
->removeComponent('field_url')
->save();
$updateLogger
->info(t('Configuration is successfully changed for instagram thumbnail.'));
}
else {
$updateLogger
->warning(t('Unable to adjust core.entity_view_display.media.instagram.thumbnail config'));
$successfulUpdate = FALSE;
}
try {
/** @var \Drupal\update_helper_checklist\UpdateChecklist $updateChecklist */
$updateChecklist = \Drupal::service('update_helper_checklist.update_checklist');
if ($successfulUpdate) {
$updateChecklist
->markUpdatesSuccessful([
'thunder' => [
'v1_1__instagram_edit_preview',
],
]);
}
else {
$updateChecklist
->markUpdatesFailed([
'thunder' => [
'v1_1__instagram_edit_preview',
],
]);
}
} catch (EntityStorageException $ee) {
$updateLogger
->warning(t('Unable to mark update in checklist.'));
} catch (ServiceNotFoundException $se) {
// If service is not available, we will just ignore it.
}
// Output log result depending on channel used for update execution.
return $updateLogger
->output();
}