function nodeaccess_node_grants in Nodeaccess 8
Same name and namespace in other branches
- 8.2 nodeaccess.module \nodeaccess_node_grants()
- 5 nodeaccess.module \nodeaccess_node_grants()
- 6.2 nodeaccess.module \nodeaccess_node_grants()
- 6 nodeaccess.module \nodeaccess_node_grants()
- 7 nodeaccess.module \nodeaccess_node_grants()
Implements hook_node_grants().
File
- ./
nodeaccess.module, line 123 - Control access to site content based on the users and roles.
Code
function nodeaccess_node_grants(AccountInterface $account, $op) {
$config = \Drupal::configFactory()
->get('nodeaccess.settings');
$role_map = $config
->get('role_map');
$roles = $account
->getRoles();
$rids = [];
foreach ($roles as $role) {
$rids[] = $role_map[$role];
}
return [
'nodeaccess_rid' => $rids,
'nodeaccess_uid' => [
$account
->id(),
],
'nodeaccess_author' => [
$account
->id(),
],
];
}