You are here

function simple_sitemap_update_8201 in Simple XML sitemap 8.2

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

Changing the data structure of the module's configuration.

File

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

Code

function simple_sitemap_update_8201() {
  $entity_types = \Drupal::config('simple_sitemap.settings')
    ->get('entity_types');
  $entity_types = is_array($entity_types) ? $entity_types : [];
  $naming_changes = [
    'node_type' => 'node',
    'taxonomy_vocabulary' => 'taxonomy_term',
    'menu' => 'menu_link_content',
    'commerce_product_type' => 'commerce_product',
    'media_bundle' => 'media',
  ];
  foreach ($entity_types as $entity_type_name => $settings) {
    if (isset($naming_changes[$entity_type_name])) {
      $entity_types[$naming_changes[$entity_type_name]] = $entity_types[$entity_type_name];
      unset($entity_types[$entity_type_name]);
    }
  }
  \Drupal::service('config.factory')
    ->getEditable('simple_sitemap.settings')
    ->set('entity_types', $entity_types)
    ->save();
}