NodeAccessControlHandlerInterface.php 2.33 KB
Newer Older
1 2 3 4 5 6
<?php

namespace Drupal\node;

use Drupal\Core\Session\AccountInterface;

7 8
/**
 * Node specific entity access control methods.
9 10
 *
 * @ingroup node_access
11 12
 */
interface NodeAccessControlHandlerInterface {
13 14 15 16 17 18 19 20 21 22 23 24 25

  /**
   * 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.
   *
   * @param \Drupal\node\NodeInterface $node
   *   The $node to acquire grants for.
   *
26
   * @return array
27 28 29 30 31 32 33
   *   The access rules for the node.
   */
  public function acquireGrants(NodeInterface $node);

  /**
   * Writes a list of grants to the database, deleting any previously saved ones.
   *
34 35
   * Modules that use node access can use this function when doing mass updates
   * due to widespread permission changes.
36 37
   *
   * Note: Don't call this function directly from a contributed module. Call
38
   * \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants() instead.
39
   *
40
   * @param \Drupal\node\NodeInterface $node
41 42 43 44 45
   *   The node whose grants are being written.
   * @param $delete
   *   (optional) If false, does not delete records. This is only for optimization
   *   purposes, and assumes the caller has already performed a mass delete of
   *   some form. Defaults to TRUE.
46 47 48
   *
   * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
   *   Use \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants().
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
   */
  public function writeGrants(NodeInterface $node, $delete = TRUE);

  /**
   * Creates the default node access grant entry on the grant storage.
   */
  public function writeDefaultGrant();

  /**
   * Deletes all node access entries.
   */
  public function deleteGrants();

  /**
   * Counts available node grants.
   *
   * @return int
   *   Returns the amount of node grants.
   */
  public function countGrants();

  /**
   * Checks all grants for a given account.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   A user object representing the user for whom the operation is to be
   *   performed.
   *
77
   * @return int
78 79 80 81 82
   *   Status of the access check.
   */
  public function checkAllGrants(AccountInterface $account);

}