Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / modules / contrib / entity / src / QueryAccess / QueryAccessEvent.php
1 <?php
2
3 namespace Drupal\entity\QueryAccess;
4
5 use Drupal\Core\Session\AccountInterface;
6 use Symfony\Component\EventDispatcher\Event;
7
8 /**
9  * Defines the query access event.
10  *
11  * Allows modules to modify access conditions before they're applied to a query.
12  *
13  * The event ID is dynamic: entity.query_access.$entity_type_id
14  */
15 class QueryAccessEvent extends Event {
16
17   /**
18    * The conditions.
19    *
20    * @var \Drupal\entity\QueryAccess\ConditionGroup
21    */
22   protected $conditions;
23
24   /**
25    * The operation.
26    *
27    * @var string
28    */
29   protected $operation;
30
31   /**
32    * The user for which to restrict access.
33    *
34    * @var \Drupal\Core\Session\AccountInterface
35    */
36   protected $account;
37
38   /**
39    * Constructs a new QueryAccessEvent.
40    *
41    * @param \Drupal\entity\QueryAccess\ConditionGroup $conditions
42    *   The 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.
47    */
48   public function __construct(ConditionGroup $conditions, $operation, AccountInterface $account) {
49     $this->conditions = $conditions;
50     $this->operation = $operation;
51     $this->account = $account;
52   }
53
54   /**
55    * Gets the conditions.
56    *
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).
60    *
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.
64    *
65    * @return \Drupal\entity\QueryAccess\ConditionGroup
66    *   The conditions.
67    */
68   public function getConditions() {
69     return $this->conditions;
70   }
71
72   /**
73    * Gets the operation.
74    *
75    * @return string
76    *   The operation. Usually one of "view", "update" or "delete".
77    */
78   public function getOperation() {
79     return $this->operation;
80   }
81
82   /**
83    * Gets the user for which to restrict access.
84    *
85    * @return \Drupal\Core\Session\AccountInterface
86    *   The user.
87    */
88   public function getAccount() {
89     return $this->account;
90   }
91
92 }