You are here

function simple_sitemap_delete_bundle_config in Simple XML sitemap 8.2

Helper function used by simple_sitemap_entity_bundle_delete() and simple_sitemap_menu_delete() hooks. This is needed, as menus are technically not bundles.

Parameters

string $entity_type_id:

string $bundle:

2 calls to simple_sitemap_delete_bundle_config()
simple_sitemap_entity_bundle_delete in ./simple_sitemap.module
Implements hook_entity_bundle_delete().
simple_sitemap_menu_delete in ./simple_sitemap.module
Implements hook_menu_delete().

File

./simple_sitemap.module, line 231
Main module file containing hooks.

Code

function simple_sitemap_delete_bundle_config($entity_type_id, $bundle) {

  /**
   * @var \Drupal\simple_sitemap\Simplesitemap $generator
   */
  $generator = \Drupal::service('simple_sitemap.generator');
  $deleted_bundle_settings = $generator
    ->getBundleSettings($entity_type_id, $bundle);
  if ($deleted_bundle_settings !== FALSE) {

    // Delete bundle settings.
    \Drupal::service('config.factory')
      ->getEditable("simple_sitemap.bundle_settings.{$entity_type_id}.{$bundle}")
      ->delete();
    $message = 'You may want to <a href="@url">regenerate</a> your XML sitemap now.';
    if ($generator
      ->getSetting('cron_generate')) {
      $message .= ' Otherwise the sitemap will be regenerated during a future cron run.';
    }
    drupal_set_message(t($message, [
      '@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap',
    ]));
  }
}