You are here

function pbf_entity_insert in Permissions by field 8

Implements hook_entity_insert().

File

./pbf.module, line 247
Contains pbf.module.

Code

function pbf_entity_insert(EntityInterface $entity) {
  $config = \Drupal::configFactory()
    ->getEditable('pbf.settings');
  if ($entity instanceof RoleInterface) {
    $roles_gids = array_flip($config
      ->get('pbf_roles_gids'));
    $roles_gids[] = $entity
      ->id();
    $config
      ->set('pbf_roles_gids', array_flip($roles_gids));
    $config
      ->save();
  }
  if ($entity instanceof FieldableEntityInterface) {
    \Drupal::service('pbf.synchronize')
      ->synchronize('insert', $entity);
  }
}