You are here

function permissions_by_term_taxonomy_term_delete in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 permissions_by_term.module \permissions_by_term_taxonomy_term_delete()

Implements hook_ENTITY_TYPE_delete().

Deletes all term permissions from storage when a term is deleted.

File

./permissions_by_term.module, line 565
Allows access to terms in a vocabulary to be limited by user or role.

Code

function permissions_by_term_taxonomy_term_delete(EntityInterface $entity) {

  /* @var AccessStorage $access_storage */
  $access_storage = \Drupal::service('permissions_by_term.access_storage');
  $access_storage
    ->deleteAllTermPermissionsByTid($entity
    ->id());

  /**
   * @var \Drupal\permissions_by_term\Cache\CacheInvalidator $cacheInvalidator
   */
  $cacheInvalidator = \Drupal::service('permissions_by_term.cache_invalidator');
  $cacheInvalidator
    ->invalidate();
}