diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php index b2bba2d..b3c1bc4 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -35,7 +35,7 @@ * (optional) The reason why access is forbidden. Intended for developers, * hence not translatable. * - * @return \Drupal\Core\Access\AccessResult + * @return \Drupal\Core\Access\AccessResultNeutral * isNeutral() will be TRUE. */ public static function neutral($reason = NULL) { @@ -46,7 +46,7 @@ public static function neutral($reason = NULL) { /** * Creates an AccessResultInterface object with isAllowed() === TRUE. * - * @return \Drupal\Core\Access\AccessResult + * @return \Drupal\Core\Access\AccessResultAllowed * isAllowed() will be TRUE. */ public static function allowed() { @@ -60,7 +60,7 @@ public static function allowed() { * (optional) The reason why access is forbidden. Intended for developers, * hence not translatable. * - * @return \Drupal\Core\Access\AccessResult + * @return \Drupal\Core\Access\AccessResultForbidden * isForbidden() will be TRUE. */ public static function forbidden($reason = NULL) { @@ -335,6 +335,13 @@ public function orIf(AccessResultInterface $other) { if (!$this->isForbidden() || ($this->getCacheMaxAge() === 0 && $other->isForbidden())) { $merge_other = TRUE; } + + if ($this->isForbidden() && $this instanceof AccessResultReasonInterface) { + $result->setReason($this->getReason()); + } + elseif ($other->isForbidden() && $other instanceof AccessResultReasonInterface) { + $result->setReason($other->getReason()); + } } elseif ($this->isAllowed() || $other->isAllowed()) { $result = static::allowed();