You are here

interface AccessResultReasonInterface in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Access/AccessResultReasonInterface.php \Drupal\Core\Access\AccessResultReasonInterface
  2. 9 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

14 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
   *   The reason of this access result or an empty string 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