You are here

function bibcite_entity_update_8021 in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/bibcite_entity.install \bibcite_entity_update_8021()

Reset admin views to default state on update due to recent updates in them.

File

modules/bibcite_entity/bibcite_entity.install, line 770
Module installation hooks implementation.

Code

function bibcite_entity_update_8021() {
  $config_names = [
    'views.view.bibcite_reference_admin',
    'views.view.bibcite_keyword_admin',
    'views.view.bibcite_contributor_admin',
  ];
  $config_factory = \Drupal::configFactory();
  $module_path = \Drupal::moduleHandler()
    ->getModule('bibcite_entity')
    ->getPath();
  $path = $module_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
  $file_storage = new FileStorage($path);
  foreach ($config_names as $config_name) {
    $config = $config_factory
      ->getEditable($config_name);
    if (!$config
      ->isNew()) {
      $data = [
        'uuid' => $config
          ->get('uuid'),
      ] + $file_storage
        ->read($config_name);
      $config
        ->setData($data);
      $config
        ->save(TRUE);
    }
  }
}