function node_test_node_access_records

Same name in other branches
  1. 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_access_records()
  2. 8.9.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_access_records()
  3. 10 core/modules/node/tests/modules/node_test/node_test.module \node_test_node_access_records()
  4. 11.x core/modules/node/tests/modules/node_test/node_test.module \node_test_node_access_records()

Implements hook_node_access_records().

File

modules/node/tests/node_test.module, line 71

Code

function node_test_node_access_records($node) {
    // Return nothing when testing for empty responses.
    if (!empty($node->disable_node_access)) {
        return;
    }
    $grants = array();
    if ($node->type == 'article') {
        // Create grant in arbitrary article_realm for article nodes.
        $grants[] = array(
            'realm' => 'test_article_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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.