You are here

function thunder_media_update_8009 in Thunder 8.2

Set required fields for Image and Video bundles.

File

modules/thunder_media/thunder_media.install, line 387
Contains.

Code

function thunder_media_update_8009() {

  /** @var \Drupal\update_helper\Updater $updater */
  $updater = \Drupal::service('update_helper.updater');
  $updateLogger = $updater
    ->logger();

  // List of expected configurations that should be checked.
  $expectedConfig['field.field.media.image.field_image']['required'] = FALSE;
  $expectedConfig['field.field.media.video.field_media_video_embed_field']['required'] = FALSE;

  // Config for required Video and Image media fields.
  $configsToUpdate['field.field.media.image.field_image']['required'] = TRUE;
  $configsToUpdate['field.field.media.video.field_media_video_embed_field']['required'] = TRUE;

  // Check that gallery paragraph uses complex widget.
  foreach ($configsToUpdate as $configName => $newConfig) {
    if (!_thunder_media_update_config($configName, $newConfig, $expectedConfig[$configName])) {
      $updateLogger
        ->warning(t('Unable to set field "@configName" as required.', [
        '@configName' => $configName,
      ]));
    }
  }
  return $updateLogger
    ->output();
}