You are here

function simple_sitemap_entity_delete in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 simple_sitemap.module \simple_sitemap_entity_delete()
  2. 8.2 simple_sitemap.module \simple_sitemap_entity_delete()

Implements hook_entity_delete().

Removes settings of the removed entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity:

File

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

Code

function simple_sitemap_entity_delete(EntityInterface $entity) {

  /** @var \Drupal\simple_sitemap\Entity\EntityHelper $entity_helper */
  $entity_helper = \Drupal::service('simple_sitemap.entity_helper');
  if ($entity_helper
    ->supports($entity
    ->getEntityType())) {

    /** @var \Drupal\simple_sitemap\Manager\Generator $generator */
    $generator = \Drupal::service('simple_sitemap.generator');
    $generator
      ->setVariants(TRUE)
      ->entityManager()
      ->removeEntityInstanceSettings($entity
      ->getEntityTypeId(), $entity
      ->id());
  }
}