You are here

public function NodeAccessControlHandler::acquireGrants in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/NodeAccessControlHandler.php \Drupal\node\NodeAccessControlHandler::acquireGrants()

Gets the list of node access grants.

This function is called to check the access grants for a node. It collects all node access grants for the node from hook_node_access_records() implementations, allows these grants to be altered via hook_node_access_records_alter() implementations, and returns the grants to the caller.

Parameters

\Drupal\node\NodeInterface $node: The $node to acquire grants for.

Return value

array $grants The access rules for the node.

Overrides NodeAccessControlHandlerInterface::acquireGrants

1 call to NodeAccessControlHandler::acquireGrants()
NodeAccessControlHandler::writeGrants in core/modules/node/src/NodeAccessControlHandler.php
Writes a list of grants to the database, deleting any previously saved ones.

File

core/modules/node/src/NodeAccessControlHandler.php, line 153
Contains \Drupal\node\NodeAccessControlHandler.

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', array(
    $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[] = array(
      'realm' => 'all',
      'gid' => 0,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
    );
  }
  return $grants;
}