function entityconnect_update_8001 in Entity connect 8.2
Grant new permission to roles having 'access admin pages' permission.
File
- ./
entityconnect.install, line 13 - Install, update and uninstall functions for the entityconnect module.
Code
function entityconnect_update_8001() {
$roles_changed = [];
/** @var \Drupal\user\RoleInterface[] $roles */
$roles = Role::loadMultiple();
foreach ($roles as $roleObj) {
if ($roleObj
->hasPermission('access administration pages')) {
$roleObj
->grantPermission('administer entityconnect');
$roleObj
->save();
$roles_changed[] = $roleObj
->label();
}
}
return t('The "administer entityconnect" permission was granted to roles: %r.', [
'%r' => implode(', ', $roles_changed),
]);
}