Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/src/NodeGrantDatabaseStorageInterface.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\node; | |
4 | |
5 use Drupal\Core\Session\AccountInterface; | |
6 | |
7 /** | |
8 * Provides an interface for node access grant storage. | |
9 * | |
10 * @ingroup node_access | |
11 */ | |
12 interface NodeGrantDatabaseStorageInterface { | |
13 | |
14 /** | |
15 * Checks all grants for a given account. | |
16 * | |
17 * @param \Drupal\Core\Session\AccountInterface $account | |
18 * A user object representing the user for whom the operation is to be | |
19 * performed. | |
20 * | |
21 * @return int | |
22 * Status of the access check. | |
23 */ | |
24 public function checkAll(AccountInterface $account); | |
25 | |
26 /** | |
27 * Alters a query when node access is required. | |
28 * | |
29 * @param mixed $query | |
30 * Query that is being altered. | |
31 * @param array $tables | |
32 * A list of tables that need to be part of the alter. | |
33 * @param string $op | |
34 * The operation to be performed on the node. Possible values are: | |
35 * - "view" | |
36 * - "update" | |
37 * - "delete" | |
38 * - "create" | |
39 * @param \Drupal\Core\Session\AccountInterface $account | |
40 * A user object representing the user for whom the operation is to be | |
41 * performed. | |
42 * @param string $base_table | |
43 * The base table of the query. | |
44 * | |
45 * @return int | |
46 * Status of the access check. | |
47 */ | |
48 public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table); | |
49 | |
50 /** | |
51 * Writes a list of grants to the database, deleting previously saved ones. | |
52 * | |
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 | |
56 * permission changes. | |
57 * | |
58 * Note: Don't call this method directly from a contributed module. Call | |
59 * \Drupal\node\NodeAccessControlHandlerInterface::acquireGrants() instead. | |
60 * | |
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 | |
68 * is a boolean value. | |
69 * @param string $realm | |
70 * (optional) If provided, read/write grants for that realm only. Defaults to | |
71 * NULL. | |
72 * @param bool $delete | |
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. | |
76 */ | |
77 public function write(NodeInterface $node, array $grants, $realm = NULL, $delete = TRUE); | |
78 | |
79 /** | |
80 * Deletes all node access entries. | |
81 */ | |
82 public function delete(); | |
83 | |
84 /** | |
85 * Creates the default node access grant entry. | |
86 */ | |
87 public function writeDefault(); | |
88 | |
89 /** | |
90 * Determines access to nodes based on node grants. | |
91 * | |
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 | |
96 * 'delete'. | |
97 * @param \Drupal\Core\Session\AccountInterface $account | |
98 * The user for which to check access. | |
99 * | |
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. | |
103 * | |
104 * @see hook_node_grants() | |
105 * @see hook_node_access_records() | |
106 * @see \Drupal\node\NodeGrantDatabaseStorageInterface::writeDefault() | |
107 */ | |
108 public function access(NodeInterface $node, $operation, AccountInterface $account); | |
109 | |
110 /** | |
111 * Counts available node grants. | |
112 * | |
113 * @return int | |
114 * Returns the amount of node grants. | |
115 */ | |
116 public function count(); | |
117 | |
118 /** | |
119 * Remove the access records belonging to certain nodes. | |
120 * | |
121 * @param array $nids | |
122 * A list of node IDs. The grant records belonging to these nodes will be | |
123 * deleted. | |
124 */ | |
125 public function deleteNodeRecords(array $nids); | |
126 | |
127 } |