Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / lib / Drupal / Core / Access / AccessResultInterface.php
1 <?php
2
3 namespace Drupal\Core\Access;
4
5 /**
6  * Interface for access result value objects.
7  *
8  * IMPORTANT NOTE: You have to call isAllowed() when you want to know whether
9  * someone has access. Just using
10  * @code
11  * if ($access_result) {
12  *   // The user has access!
13  * }
14  * else {
15  *   // The user doesn't have access!
16  * }
17  * @endcode
18  * would never enter the else-statement and hence introduce a critical security
19  * issue.
20  */
21 interface AccessResultInterface {
22
23   /**
24    * Checks whether this access result indicates access is explicitly allowed.
25    *
26    * @return bool
27    *   When TRUE then isForbidden() and isNeutral() are FALSE.
28    */
29   public function isAllowed();
30
31   /**
32    * Checks whether this access result indicates access is explicitly forbidden.
33    *
34    * This is a kill switch — both orIf() and andIf() will result in
35    * isForbidden() if either results are isForbidden().
36    *
37    * @return bool
38    *   When TRUE then isAllowed() and isNeutral() are FALSE.
39    */
40   public function isForbidden();
41
42   /**
43    * Checks whether this access result indicates access is not yet determined.
44    *
45    * @return bool
46    *   When TRUE then isAllowed() and isForbidden() are FALSE.
47    */
48   public function isNeutral();
49
50   /**
51    * Combine this access result with another using OR.
52    *
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()
57    *
58    * Truth table:
59    * @code
60    *   |A N F
61    * --+-----
62    * A |A A F
63    * N |A N F
64    * F |F F F
65    * @endcode
66    *
67    * @param \Drupal\Core\Access\AccessResultInterface $other
68    *   The other access result to OR this one with.
69    *
70    * @return static
71    */
72   public function orIf(AccessResultInterface $other);
73
74   /**
75    * Combine this access result with another using AND.
76    *
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()
81    *
82    * Truth table:
83    * @code
84    *   |A N F
85    * --+-----
86    * A |A N F
87    * N |N N F
88    * F |F F F
89    * @endcode
90    *
91    * @param \Drupal\Core\Access\AccessResultInterface $other
92    *   The other access result to AND this one with.
93    *
94    * @return static
95    */
96   public function andIf(AccessResultInterface $other);
97
98 }