You are here

function content_access_entity_insert in Content Access 8

Implements hook_entity_insert().

File

./content_access.module, line 142
Content access module file.

Code

function content_access_entity_insert(EntityInterface $entity) {
  $config = \Drupal::configFactory()
    ->getEditable('content_access.settings');
  if ($entity instanceof RoleInterface) {
    $roles_gids = array_flip($config
      ->get('content_access_roles_gids'));
    $roles_gids[] = $entity
      ->id();
    $config
      ->set('content_access_roles_gids', array_flip($roles_gids));
    $config
      ->save();
  }
}