function menu_per_role_update_8101 in Menu Per Role 8
Permission to bypass menu_per_role access to roles having old permission.
File
- ./
menu_per_role.install, line 15
Code
function menu_per_role_update_8101() {
$config = \Drupal::config('menu_per_role.settings');
$admin_see_all = !is_null($config
->get('admin_see_all')) ? $config
->get('admin_see_all') : FALSE;
if ($admin_see_all) {
/** @var \Drupal\user\Entity\Role[] $roles */
$roles = Role::loadMultiple();
foreach ($roles as $role) {
if ($role
->hasPermission('administer menu_per_role')) {
$role
->grantPermission('bypass menu_per_role access');
$role
->save();
}
}
}
}