You are here

function menu_per_role_update_8103 in Menu Per Role 8

Have distinct permissions for front and admin access bypass.

File

./menu_per_role.install, line 44

Code

function menu_per_role_update_8103() {

  /** @var \Drupal\user\Entity\Role[] $roles */
  $roles = Role::loadMultiple();
  foreach ($roles as $role) {
    if ($role
      ->hasPermission('bypass menu_per_role access')) {
      $role
        ->revokePermission('bypass menu_per_role access');
      $role
        ->grantPermission('bypass menu_per_role access front');
      $role
        ->grantPermission('bypass menu_per_role access admin');
      $role
        ->save();
    }
  }
}