You are here

function pathauto_entity_delete in Pathauto 8

Same name and namespace in other branches
  1. 7 pathauto.module \pathauto_entity_delete()

Implements hook_entity_delete().

File

./pathauto.module, line 99
pathauto Pathauto: Automatically generates aliases for content

Code

function pathauto_entity_delete(EntityInterface $entity) {
  if ($entity
    ->hasLinkTemplate('canonical') && $entity instanceof ContentEntityInterface && $entity
    ->hasField('path') && $entity
    ->getFieldDefinition('path')
    ->getType() == 'path') {
    \Drupal::service('pathauto.alias_storage_helper')
      ->deleteEntityPathAll($entity);
    $entity
      ->get('path')
      ->first()
      ->get('pathauto')
      ->purge();
  }
}