You are here

class AccessResultForbidden in Drupal 10

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

Value object indicating a forbidden access result, with cacheability metadata.

Hierarchy

Expanded class hierarchy of AccessResultForbidden

4 files declare their use of AccessResultForbidden
AccessResultForbiddenTest.php in core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php
book_breadcrumb_test.module in core/modules/book/tests/modules/book_breadcrumb_test/book_breadcrumb_test.module
Test module for testing the book module breadcrumb.
LatestRevisionCheckTest.php in core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php
LocalActionManagerTest.php in core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
Contains \Drupal\Tests\Core\Menu\LocalActionManagerTest.

File

core/lib/Drupal/Core/Access/AccessResultForbidden.php, line 8

Namespace

Drupal\Core\Access
View source
class AccessResultForbidden extends AccessResult implements AccessResultReasonInterface {

  /**
   * The reason why access is forbidden. For use in error messages.
   *
   * @var string
   */
  protected $reason;

  /**
   * Constructs a new AccessResultForbidden instance.
   *
   * @param null|string $reason
   *   (optional) A message to provide details about this access result.
   */
  public function __construct($reason = NULL) {
    $this->reason = $reason;
  }

  /**
   * {@inheritdoc}
   */
  public function isForbidden() {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function getReason() {
    return (string) $this->reason;
  }

  /**
   * {@inheritdoc}
   */
  public function setReason($reason) {
    $this->reason = $reason;
    return $this;
  }

}

Members