You are here

pbf.install in Permissions by field 8

Permissions by field install file.

File

pbf.install
View source
<?php

/**
 * @file
 * Permissions by field install file.
 */
use Drupal\user\Entity\Role;

/**
 * Implements hook_install().
 */
function pbf_install() {
  $config = \Drupal::configFactory()
    ->getEditable('pbf.settings');
  $roles_gids = array();
  $roles = Role::loadMultiple();
  $i = 1;
  foreach ($roles as $role) {
    $roles_gids[$i] = $role
      ->id();
    $i++;
  }
  $config
    ->set('pbf_roles_gids', array_flip($roles_gids));
  $config
    ->save();
}

Functions

Namesort descending Description
pbf_install Implements hook_install().