You are here

function simple_sitemap_update_8216 in Simple XML sitemap 8.3

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

Adding per-variant bundle and entity override configuration.

File

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

Code

function simple_sitemap_update_8216() {
  $config_factory = \Drupal::service('config.factory');
  foreach ($config_factory
    ->listAll('simple_sitemap.bundle_settings.') as $bundle_config_name) {
    $config = $config_factory
      ->getEditable($bundle_config_name);
    $config_name_parts = explode('.', $bundle_config_name);
    $config_factory
      ->getEditable($config_name_parts[0] . '.' . $config_name_parts[1] . '.' . _simple_sitemap_update_8216_get_default_variant() . '.' . $config_name_parts[2] . '.' . $config_name_parts[3])
      ->setData($config
      ->get())
      ->save();
    $config
      ->delete();
  }
  $database = \Drupal::database();
  if (!$database
    ->schema()
    ->fieldExists('simple_sitemap_entity_overrides', 'type')) {
    $database
      ->schema()
      ->addField('simple_sitemap_entity_overrides', 'type', [
      'description' => 'Type of sitemap this override belongs to.',
      'type' => 'varchar',
      'length' => 50,
      'not null' => TRUE,
      'initial' => 'default',
    ]);
  }
}