7d407c1f162b88c16a3441c0116ff08e8ca0acfe
[yaffs-website] / web / core / modules / node / src / NodeAccessControlHandlerInterface.php
1 <?php
2
3 namespace Drupal\node;
4
5 use Drupal\Core\Session\AccountInterface;
6
7 /**
8  * Node specific entity access control methods.
9  *
10  * @ingroup node_access
11  */
12 interface NodeAccessControlHandlerInterface {
13
14   /**
15    * Gets the list of node access grants.
16    *
17    * This function is called to check the access grants for a node. It collects
18    * all node access grants for the node from hook_node_access_records()
19    * implementations, allows these grants to be altered via
20    * hook_node_access_records_alter() implementations, and returns the grants to
21    * the caller.
22    *
23    * @param \Drupal\node\NodeInterface $node
24    *   The $node to acquire grants for.
25    *
26    * @return array
27    *   The access rules for the node.
28    */
29   public function acquireGrants(NodeInterface $node);
30
31   /**
32    * Writes a list of grants to the database, deleting any previously saved ones.
33    *
34    * Modules that use node access can use this function when doing mass updates
35    * 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    *   The node whose grants are being written.
42    * @param $delete
43    *   (optional) If false, does not delete records. This is only for optimization
44    *   purposes, and assumes the caller has already performed a mass delete of
45    *   some form. Defaults to TRUE.
46    *
47    * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
48    *   Use \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants().
49    */
50   public function writeGrants(NodeInterface $node, $delete = TRUE);
51
52   /**
53    * Creates the default node access grant entry on the grant storage.
54    */
55   public function writeDefaultGrant();
56
57   /**
58    * Deletes all node access entries.
59    */
60   public function deleteGrants();
61
62   /**
63    * Counts available node grants.
64    *
65    * @return int
66    *   Returns the amount of node grants.
67    */
68   public function countGrants();
69
70   /**
71    * Checks all grants for a given account.
72    *
73    * @param \Drupal\Core\Session\AccountInterface $account
74    *   A user object representing the user for whom the operation is to be
75    *   performed.
76    *
77    * @return int
78    *   Status of the access check.
79    */
80   public function checkAllGrants(AccountInterface $account);
81
82 }