Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AccessResultReasonInterface.php

interface 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

  • interface \Drupal\Core\Access\AccessResultInterface
    • interface \Drupal\Core\Access\AccessResultReasonInterface extends \Drupal\Core\Access\AccessResultInterface

Expanded class hierarchy of AccessResultReasonInterface

All classes that implement AccessResultReasonInterface

See also

\Drupal\Core\Access\AccessResultInterface

9 files declare their use of AccessResultReasonInterface
AccessAwareRouter.php in core/lib/Drupal/Core/Routing/AccessAwareRouter.php
EntityAccessChecker.php in core/modules/jsonapi/src/Access/EntityAccessChecker.php
EntityAccessDeniedHttpException.php in core/modules/jsonapi/src/Exception/EntityAccessDeniedHttpException.php
EntityCreateAnyAccessCheck.php in core/lib/Drupal/Core/Entity/EntityCreateAnyAccessCheck.php
EntityResource.php in core/modules/rest/src/Plugin/rest/resource/EntityResource.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 string|null $reason
     *   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

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal