You are here

function lightning_layout_update_8006 in Lightning Layout 8

Same name and namespace in other branches
  1. 8.2 lightning_layout.install \lightning_layout_update_8006()

Removes administrative privileges from layout_manager role.

File

./lightning_layout.install, line 69
Contains installation and update routines for Lightning Layout.

Code

function lightning_layout_update_8006() {
  $role_storage = \Drupal::entityTypeManager()
    ->getStorage('user_role');

  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = $role_storage
    ->loadByProperties([
    'is_admin' => TRUE,
  ]);
  $keys = array_keys($roles);
  sort($keys);
  if ($keys == [
    'administrator',
    'layout_manager',
  ]) {
    $roles['layout_manager']
      ->setIsAdmin(FALSE)
      ->grantPermission('administer node display')
      ->grantPermission('administer panelizer')
      ->save();
    lightning_layout_update_8003();
  }
}