3 namespace Drupal\entity\QueryAccess;
5 use Drupal\Core\Session\AccountInterface;
6 use Symfony\Component\EventDispatcher\Event;
9 * Defines the query access event.
11 * Allows modules to modify access conditions before they're applied to a query.
13 * The event ID is dynamic: entity.query_access.$entity_type_id
15 class QueryAccessEvent extends Event {
20 * @var \Drupal\entity\QueryAccess\ConditionGroup
22 protected $conditions;
32 * The user for which to restrict access.
34 * @var \Drupal\Core\Session\AccountInterface
39 * Constructs a new QueryAccessEvent.
41 * @param \Drupal\entity\QueryAccess\ConditionGroup $conditions
43 * @param string $operation
44 * The operation. Usually one of "view", "update" or "delete".
45 * @param \Drupal\Core\Session\AccountInterface $account
46 * The user for which to restrict access.
48 public function __construct(ConditionGroup $conditions, $operation, AccountInterface $account) {
49 $this->conditions = $conditions;
50 $this->operation = $operation;
51 $this->account = $account;
55 * Gets the conditions.
57 * If $conditions->isAlwaysFalse() is TRUE, the user doesn't have access to
58 * any entities, and the query is expected to return no results.
59 * This can be reversed by calling $conditions->alwaysFalse(FALSE).
61 * If $conditions->isAlwaysFalse() is FALSE, and the condition group is
62 * empty (count is 0), the user has full access, and the query doesn't
63 * need to be restricted.
65 * @return \Drupal\entity\QueryAccess\ConditionGroup
68 public function getConditions() {
69 return $this->conditions;
76 * The operation. Usually one of "view", "update" or "delete".
78 public function getOperation() {
79 return $this->operation;
83 * Gets the user for which to restrict access.
85 * @return \Drupal\Core\Session\AccountInterface
88 public function getAccount() {
89 return $this->account;