You are here

function nodeaccess_entity_delete in Nodeaccess 8

Same name and namespace in other branches
  1. 8.2 nodeaccess.module \nodeaccess_entity_delete()

Implements hook_entity_delete().

File

./nodeaccess.module, line 190
Control access to site content based on the users and roles.

Code

function nodeaccess_entity_delete(EntityInterface $entity) {
  $config = \Drupal::configFactory()
    ->getEditable('nodeaccess.settings');
  if ($entity instanceof RoleInterface) {
    $roles_gids = $config
      ->get('role_map');
    unset($roles_gids[$entity
      ->id()]);
    $config
      ->set('role_map', $roles_gids);
    $role_alias = $config
      ->get('role_alias');
    unset($role_alias[$entity
      ->id()]);
    $config
      ->set('role_alias', $role_alias);
    $config
      ->save();
  }
}