5 use Drupal\Core\Session\AccountInterface;
8 * Provides an interface for node access grant storage.
10 * @ingroup node_access
12 interface NodeGrantDatabaseStorageInterface {
15 * Checks all grants for a given account.
17 * @param \Drupal\Core\Session\AccountInterface $account
18 * A user object representing the user for whom the operation is to be
22 * Status of the access check.
24 public function checkAll(AccountInterface $account);
27 * Alters a query when node access is required.
30 * Query that is being altered.
31 * @param array $tables
32 * A list of tables that need to be part of the alter.
34 * The operation to be performed on the node. Possible values are:
39 * @param \Drupal\Core\Session\AccountInterface $account
40 * A user object representing the user for whom the operation is to be
42 * @param string $base_table
43 * The base table of the query.
46 * Status of the access check.
48 public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table);
51 * Writes a list of grants to the database, deleting previously saved ones.
53 * If a realm is provided, it will only delete grants from that realm, but
54 * it will always delete a grant from the 'all' realm. Modules that use
55 * node access can use this method when doing mass updates due to widespread
58 * Note: Don't call this method directly from a contributed module. Call
59 * \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants() instead.
61 * @param \Drupal\node\NodeInterface $node
62 * The node whose grants are being written.
63 * @param array $grants
64 * A list of grants to write. Each grant is an array that must contain the
65 * following keys: realm, gid, grant_view, grant_update, grant_delete.
66 * The realm is specified by a particular module; the gid is as well, and
67 * is a module-defined id to define grant privileges. each grant_* field
69 * @param string $realm
70 * (optional) If provided, read/write grants for that realm only. Defaults to
73 * (optional) If false, does not delete records. This is only for optimization
74 * purposes, and assumes the caller has already performed a mass delete of
75 * some form. Defaults to TRUE.
77 public function write(NodeInterface $node, array $grants, $realm = NULL, $delete = TRUE);
80 * Deletes all node access entries.
82 public function delete();
85 * Creates the default node access grant entry.
87 public function writeDefault();
90 * Determines access to nodes based on node grants.
92 * @param \Drupal\node\NodeInterface $node
93 * The entity for which to check 'create' access.
94 * @param string $operation
95 * The entity operation. Usually one of 'view', 'edit', 'create' or
97 * @param \Drupal\Core\Session\AccountInterface $account
98 * The user for which to check access.
100 * @return \Drupal\Core\Access\AccessResultInterface
101 * The access result, either allowed or neutral. If there are no node
102 * grants, the default grant defined by writeDefault() is applied.
104 * @see hook_node_grants()
105 * @see hook_node_access_records()
106 * @see \Drupal\node\NodeGrantDatabaseStorageInterface::writeDefault()
108 public function access(NodeInterface $node, $operation, AccountInterface $account);
111 * Counts available node grants.
114 * Returns the amount of node grants.
116 public function count();
119 * Remove the access records belonging to certain nodes.
122 * A list of node IDs. The grant records belonging to these nodes will be
125 public function deleteNodeRecords(array $nids);