You are here

function content_access_install in Content Access 8

Same name and namespace in other branches
  1. 5 content_access.install \content_access_install()
  2. 6 content_access.install \content_access_install()

Implements hook_install().

File

./content_access.install, line 13
Content access install file.

Code

function content_access_install() {
  $config = \Drupal::configFactory()
    ->getEditable('content_access.settings');
  $roles_gids = [];
  $roles = Role::loadMultiple();
  $i = 1;
  foreach ($roles as $role) {
    $roles_gids[$i] = $role
      ->id();
    $i++;
  }
  $config
    ->set('content_access_roles_gids', array_flip($roles_gids))
    ->save();
}