3 namespace Drupal\entity\QueryAccess;
5 use Drupal\Core\Session\AccountInterface;
8 * Query access handlers control access to entities in queries.
10 * An entity defines a query access handler in its annotation:
12 * query_access = "\Drupal\entity\QueryAccess\QueryAccessHandler"
14 * The handler builds a set of conditions which are then applied to a query
15 * to filter it. For example, if the user #22 only has access to view
16 * their own entities, a uid = '22' condition will be built and applied.
18 * The following query types are supported:
19 * - Entity queries with the $entity_type_id . '_access' tag.
22 interface QueryAccessHandlerInterface {
25 * Gets the conditions for the given operation and user.
27 * The "entity.query_access.$entity_type_id" event is fired to allow
28 * modules to alter the conditions.
30 * @param string $operation
31 * The access operation. Usually one of "view", "update" or "delete".
32 * @param \Drupal\Core\Session\AccountInterface $account
33 * The user for which to restrict access, or NULL
34 * to assume the current user. Defaults to NULL.
36 * @return \Drupal\entity\QueryAccess\ConditionGroup
39 public function getConditions($operation, AccountInterface $account = NULL);