1 node_test.module node_test_node_access_records(Node $node)

Implements hook_node_access_records().

File

core/modules/node/tests/node_test/node_test.module, line 70
A dummy module for testing node related hooks.

Code

function node_test_node_access_records(Node $node) {
  // Return nothing when testing for empty responses.
  if (!empty($node->disable_node_access)) {
    return;
  }
  $grants = array();
  if ($node->type == 'post') {
    // Create grant in arbitrary post_realm for post nodes.
    $grants[] = array(
      'realm' => 'test_post_realm',
      'gid' => 1,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
  }
  elseif ($node->type == 'page') {
    // Create grant in arbitrary page_realm for page nodes.
    $grants[] = array(
      'realm' => 'test_page_realm',
      'gid' => 1,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
  }
  return $grants;
}