function AccessResult::forbidden

Same name in other branches
  1. 9 core/lib/Drupal/Core/Access/AccessResult.php \Drupal\Core\Access\AccessResult::forbidden()
  2. 10 core/lib/Drupal/Core/Access/AccessResult.php \Drupal\Core\Access\AccessResult::forbidden()
  3. 11.x core/lib/Drupal/Core/Access/AccessResult.php \Drupal\Core\Access\AccessResult::forbidden()

Creates an AccessResultInterface object with isForbidden() === TRUE.

Parameters

string|null $reason: (optional) The reason why access is forbidden. Intended for developers, hence not translatable.

Return value

\Drupal\Core\Access\AccessResultForbidden isForbidden() will be TRUE.

80 calls to AccessResult::forbidden()
AccessAwareRouterTest::testCheckAccessResultWithReason in core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
Tests the matchRequest() function for access denied with reason message.
AccessAwareRouterTest::testMatchRequestDenied in core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
Tests the matchRequest() function for access denied.
AccessGroupAndTest::testGroups in core/modules/block_content/tests/src/Unit/Access/AccessGroupAndTest.php
@covers \Drupal\block_content\Access\AccessGroupAnd
AccessManagerTest::providerTestCheckConjunctions in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Provides data for the conjunction test.
AccessManagerTest::testCheck in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests \Drupal\Core\Access\AccessManager::check().

... See full list

File

core/lib/Drupal/Core/Access/AccessResult.php, line 66

Class

AccessResult
Value object for passing an access result with cacheability metadata.

Namespace

Drupal\Core\Access

Code

public static function forbidden($reason = NULL) {
    assert(is_string($reason) || is_null($reason));
    return new AccessResultForbidden($reason);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.