You are here

public static function AccessResult::forbidden in Drupal 8

Same name and namespace in other branches
  1. 9 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.

79 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);
}