You are here

function simplesitemap_entity_bundle_delete in Simple XML sitemap 8

Implements hook_entity_bundle_delete().

Removes settings of the removed bundle.

File

./simplesitemap.module, line 126
Main module file containing hooks.

Code

function simplesitemap_entity_bundle_delete($entity_type_id, $bundle) {
  $sitemap = new Simplesitemap();
  $entity_types = $sitemap
    ->get_config('entity_types');
  $bundle_entity_type_id = \Drupal::entityManager()
    ->getDefinition($entity_type_id)
    ->getBundleEntityType();
  if (isset($entity_types[$bundle_entity_type_id][$bundle])) {
    unset($entity_types[$bundle_entity_type_id][$bundle]);
    $sitemap
      ->save_config('entity_types', $entity_types);
    drupal_set_message(t("You may want to <a href='@url'>regenerate</a> your XML sitemap now.\n    Otherwise it will be rebuilt on the next cron run.", array(
      '@url' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap',
    )));
  }
}