You are here

interface AccessResultReasonInterface in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Access/AccessResultReasonInterface.php \Drupal\Core\Access\AccessResultReasonInterface
  2. 10 core/lib/Drupal/Core/Access/AccessResultReasonInterface.php \Drupal\Core\Access\AccessResultReasonInterface

Interface for access result value objects with stored reason for developers.

For example, a developer can specify the reason for forbidden access:

new AccessResultForbidden('You are not authorized to hack core');

Hierarchy

Expanded class hierarchy of AccessResultReasonInterface

All classes that implement AccessResultReasonInterface

See also

\Drupal\Core\Access\AccessResultInterface

15 files declare their use of AccessResultReasonInterface
AccessAwareRouter.php in core/lib/Drupal/Core/Routing/AccessAwareRouter.php
AccessResultTest.php in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
Contains \Drupal\Tests\Core\Access\AccessResultTest.
config_test_rest.module in core/modules/rest/tests/modules/config_test_rest/config_test_rest.module
Contains hook implementations for testing REST module.
EntityAccessChecker.php in core/modules/jsonapi/src/Access/EntityAccessChecker.php
EntityAccessDeniedHttpException.php in core/modules/jsonapi/src/Exception/EntityAccessDeniedHttpException.php

... See full list

File

core/lib/Drupal/Core/Access/AccessResultReasonInterface.php, line 15

Namespace

Drupal\Core\Access
View source
interface AccessResultReasonInterface extends AccessResultInterface {

  /**
   * Gets the reason for this access result.
   *
   * @return string|null
   *   The reason of this access result or NULL if no reason is provided.
   */
  public function getReason();

  /**
   * Sets the reason for this access result.
   *
   * @param $reason string|null
   *   The reason of this access result or NULL if no reason is provided.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result instance.
   */
  public function setReason($reason);

}

Members

Namesort descending Modifiers Type Description Overrides
AccessResultInterface::andIf public function Combine this access result with another using AND. 2
AccessResultInterface::isAllowed public function Checks whether this access result indicates access is explicitly allowed. 2
AccessResultInterface::isForbidden public function Checks whether this access result indicates access is explicitly forbidden. 2
AccessResultInterface::isNeutral public function Checks whether this access result indicates access is not yet determined. 2
AccessResultInterface::orIf public function Combine this access result with another using OR. 2
AccessResultReasonInterface::getReason public function Gets the reason for this access result. 2
AccessResultReasonInterface::setReason public function Sets the reason for this access result. 2