You are here

function simple_sitemap_update_8213 in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x simple_sitemap.install \simple_sitemap_update_8213()

Altering the configuration storage of variants.

File

./simple_sitemap.install, line 587
Module install and update procedures.

Code

function simple_sitemap_update_8213() {
  $config_factory = \Drupal::service('config.factory');
  $new_variants = [];
  foreach ($config_factory
    ->get('simple_sitemap.variants')
    ->get('variants') as $variant_name => $variant_definition) {
    $new_variants[$variant_definition['type']][$variant_name] = [
      'label' => $variant_definition['label'],
    ];
  }

  // Create new configuration objects.
  foreach ($new_variants as $type => $variants) {
    $config_factory
      ->getEditable('simple_sitemap.variants.' . $type)
      ->set('variants', $variants)
      ->save();
  }

  // Remove old configuration object.
  $config_factory
    ->getEditable('simple_sitemap.variants')
    ->delete();
}