You are here

function thunder_media_update_8013 in Thunder 8.2

Import slick media display view configuration.

File

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

Code

function thunder_media_update_8013() {

  /** @var \Drupal\update_helper\UpdateLogger $updateLogger */
  $updateLogger = \Drupal::service('update_helper.logger');

  /** @var \Drupal\Core\Config\StorageInterface $configStorage */
  $configStorage = \Drupal::service('config.storage');
  if ($configStorage
    ->exists('core.entity_view_display.media.image.slick')) {
    $updateLogger
      ->info(t('Configuration already exists.'));
  }
  else {

    // Enable "config_update" module.
    \Drupal::service('module_installer')
      ->install([
      'config_update',
    ]);

    /** @var \Drupal\config_update\ConfigRevertInterface $configUpdater */
    $configUpdater = \Drupal::service('config_update.config_update');
    try {
      $configUpdater
        ->import('entity_view_display', 'media.image.slick');
      $updateLogger
        ->info(t('Configuration successfully imported.'));
    } catch (\Exception $e) {
      $updateLogger
        ->warning(t('Unable to import configuration: core.entity_view_display.media.image.slick.yml.'));
    }
  }

  // Output collected update log.
  return $updateLogger
    ->output();
}