2 * Implements hook_node_access_records().
4 function {{ machine_name }}_node_access_records(\Drupal\node\NodeInterface $node) {
5 // We only care about the node if it has been marked private. If not, it is
6 // treated just like any other node and we completely ignore it.
7 if ($node->private->value) {
9 // Only published Catalan translations of private nodes should be viewable
10 // to all users. If we fail to check $node->isPublished(), all users would be able
11 // to view an unpublished node.
12 if ($node->isPublished()) {
22 // For the example_author array, the GID is equivalent to a UID, which
23 // means there are many groups of just 1 user.
24 // Note that an author can always view his or her nodes, even if they
25 // have status unpublished.
26 if ($node->getOwnerId()) {
28 'realm' => 'example_author',
29 'gid' => $node->getOwnerId(),