3 namespace Drupal\Core\Access;
6 * Interface for access result value objects.
8 * IMPORTANT NOTE: You have to call isAllowed() when you want to know whether
9 * someone has access. Just using
11 * if ($access_result) {
12 * // The user has access!
15 * // The user doesn't have access!
18 * would never enter the else-statement and hence introduce a critical security
21 interface AccessResultInterface {
24 * Checks whether this access result indicates access is explicitly allowed.
27 * When TRUE then isForbidden() and isNeutral() are FALSE.
29 public function isAllowed();
32 * Checks whether this access result indicates access is explicitly forbidden.
34 * This is a kill switch — both orIf() and andIf() will result in
35 * isForbidden() if either results are isForbidden().
38 * When TRUE then isAllowed() and isNeutral() are FALSE.
40 public function isForbidden();
43 * Checks whether this access result indicates access is not yet determined.
46 * When TRUE then isAllowed() and isForbidden() are FALSE.
48 public function isNeutral();
51 * Combine this access result with another using OR.
53 * When OR-ing two access results, the result is:
54 * - isForbidden() in either ⇒ isForbidden()
55 * - otherwise if isAllowed() in either ⇒ isAllowed()
56 * - otherwise both must be isNeutral() ⇒ isNeutral()
67 * @param \Drupal\Core\Access\AccessResultInterface $other
68 * The other access result to OR this one with.
72 public function orIf(AccessResultInterface $other);
75 * Combine this access result with another using AND.
77 * When AND-ing two access results, the result is:
78 * - isForbidden() in either ⇒ isForbidden()
79 * - otherwise, if isAllowed() in both ⇒ isAllowed()
80 * - otherwise, one of them is isNeutral() ⇒ isNeutral()
91 * @param \Drupal\Core\Access\AccessResultInterface $other
92 * The other access result to AND this one with.
96 public function andIf(AccessResultInterface $other);