function nodeaccess_update_8101 in Nodeaccess 8
Same name and namespace in other branches
- 8.2 nodeaccess.install \nodeaccess_update_8101()
Update nodeaccess allowed role settings.
File
- ./
nodeaccess.install, line 110 - Install/uninstall functions for Nodeaccess.
Code
function nodeaccess_update_8101() {
$config = \Drupal::configFactory()
->getEditable('nodeaccess.settings');
$role_alias = $config
->get('role_alias');
foreach (user_roles() as $id => $role) {
if ($role_alias[$id]) {
$role_alias[$id]['alias'] = $role
->label();
$role_alias[$id]['name'] = $role
->label();
}
else {
$role_alias[$id] = [
'alias' => $role
->label(),
'name' => $role
->label(),
'weight' => 0,
'allow' => 0,
];
}
$i++;
}
$config
->set('role_alias', $role_alias);
$config
->save();
}