You are here

function xmlsitemap_link_bundle_rename in XML sitemap 8

Same name and namespace in other branches
  1. 6.2 xmlsitemap.module \xmlsitemap_link_bundle_rename()
  2. 7.2 xmlsitemap.module \xmlsitemap_link_bundle_rename()
  3. 2.x xmlsitemap.module \xmlsitemap_link_bundle_rename()

Renames a bundle.

Parameters

string $entity: Entity type id.

string $bundle_old: Old bundle name.

string $bundle_new: New bundle name.

1 call to xmlsitemap_link_bundle_rename()
xmlsitemap_entity_bundle_rename in ./xmlsitemap.module
Implements hook_entity_bundle_rename().

File

./xmlsitemap.module, line 906
xmlsitemap XML sitemap

Code

function xmlsitemap_link_bundle_rename($entity, $bundle_old, $bundle_new) {
  if ($bundle_old != $bundle_new) {
    if (!\Drupal::config("xmlsitemap.settings.{$entity}.{$bundle_old}")
      ->isNew()) {
      $settings = xmlsitemap_link_bundle_load($entity, $bundle_old);
      \Drupal::configFactory()
        ->getEditable("xmlsitemap.settings.{$entity}.{$bundle_old}")
        ->delete();
      xmlsitemap_link_bundle_settings_save($entity, $bundle_new, $settings, FALSE);
      \Drupal::service('xmlsitemap.link_storage')
        ->updateMultiple([
        'subtype' => $bundle_new,
      ], [
        'type' => $entity,
        'subtype' => $bundle_old,
      ]);
    }
  }
}