Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Access/AccessResult.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
37 * | 37 * |
38 * @return \Drupal\Core\Access\AccessResultNeutral | 38 * @return \Drupal\Core\Access\AccessResultNeutral |
39 * isNeutral() will be TRUE. | 39 * isNeutral() will be TRUE. |
40 */ | 40 */ |
41 public static function neutral($reason = NULL) { | 41 public static function neutral($reason = NULL) { |
42 assert('is_string($reason) || is_null($reason)'); | 42 assert(is_string($reason) || is_null($reason)); |
43 return new AccessResultNeutral($reason); | 43 return new AccessResultNeutral($reason); |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * Creates an AccessResultInterface object with isAllowed() === TRUE. | 47 * Creates an AccessResultInterface object with isAllowed() === TRUE. |
62 * | 62 * |
63 * @return \Drupal\Core\Access\AccessResultForbidden | 63 * @return \Drupal\Core\Access\AccessResultForbidden |
64 * isForbidden() will be TRUE. | 64 * isForbidden() will be TRUE. |
65 */ | 65 */ |
66 public static function forbidden($reason = NULL) { | 66 public static function forbidden($reason = NULL) { |
67 assert('is_string($reason) || is_null($reason)'); | 67 assert(is_string($reason) || is_null($reason)); |
68 return new AccessResultForbidden($reason); | 68 return new AccessResultForbidden($reason); |
69 } | 69 } |
70 | 70 |
71 /** | 71 /** |
72 * Creates an allowed or neutral access result. | 72 * Creates an allowed or neutral access result. |
85 /** | 85 /** |
86 * Creates a forbidden or neutral access result. | 86 * Creates a forbidden or neutral access result. |
87 * | 87 * |
88 * @param bool $condition | 88 * @param bool $condition |
89 * The condition to evaluate. | 89 * The condition to evaluate. |
90 * @param string|null $reason | |
91 * (optional) The reason why access is forbidden. Intended for developers, | |
92 * hence not translatable | |
90 * | 93 * |
91 * @return \Drupal\Core\Access\AccessResult | 94 * @return \Drupal\Core\Access\AccessResult |
92 * If $condition is TRUE, isForbidden() will be TRUE, otherwise isNeutral() | 95 * If $condition is TRUE, isForbidden() will be TRUE, otherwise isNeutral() |
93 * will be TRUE. | 96 * will be TRUE. |
94 */ | 97 */ |
95 public static function forbiddenIf($condition) { | 98 public static function forbiddenIf($condition, $reason = NULL) { |
96 return $condition ? static::forbidden() : static::neutral(); | 99 return $condition ? static::forbidden($reason) : static::neutral(); |
97 } | 100 } |
98 | 101 |
99 /** | 102 /** |
100 * Creates an allowed access result if the permission is present, neutral otherwise. | 103 * Creates an allowed access result if the permission is present, neutral otherwise. |
101 * | 104 * |