function NodeAccessControlHandler::acquireGrants

Same name in other branches
  1. 9 core/modules/node/src/NodeAccessControlHandler.php \Drupal\node\NodeAccessControlHandler::acquireGrants()
  2. 8.9.x core/modules/node/src/NodeAccessControlHandler.php \Drupal\node\NodeAccessControlHandler::acquireGrants()
  3. 11.x core/modules/node/src/NodeAccessControlHandler.php \Drupal\node\NodeAccessControlHandler::acquireGrants()

Overrides NodeAccessControlHandlerInterface::acquireGrants

File

core/modules/node/src/NodeAccessControlHandler.php, line 230

Class

NodeAccessControlHandler
Defines the access control handler for the node entity type.

Namespace

Drupal\node

Code

public function acquireGrants(NodeInterface $node) {
    $grants = $this->moduleHandler
        ->invokeAll('node_access_records', [
        $node,
    ]);
    // Let modules alter the grants.
    $this->moduleHandler
        ->alter('node_access_records', $grants, $node);
    // If no grants are set and the node is published, then use the default grant.
    if (empty($grants) && $node->isPublished()) {
        $grants[] = [
            'realm' => 'all',
            'gid' => 0,
            'grant_view' => 1,
            'grant_update' => 0,
            'grant_delete' => 0,
        ];
    }
    return $grants;
}

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