Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Access/AccessResult.php \Drupal\Core\Access\AccessResult::allowedIf()
  2. 9 core/lib/Drupal/Core/Access/AccessResult.php \Drupal\Core\Access\AccessResult::allowedIf()

Creates an allowed or neutral access result.

Parameters

bool $condition: The condition to evaluate.

Return value

\Drupal\Core\Access\AccessResult If $condition is TRUE, isAllowed() will be TRUE, otherwise isNeutral() will be TRUE.

51 calls to AccessResult::allowedIf()
AccessCheck::access in core/modules/system/tests/modules/menu_test/src/Access/AccessCheck.php
Check to see if user accessed this page.
AccessResult::allowedIfHasPermission in core/lib/Drupal/Core/Access/AccessResult.php
Creates an allowed access result if the permission is present, neutral otherwise.
AccessResult::allowedIfHasPermissions in core/lib/Drupal/Core/Access/AccessResult.php
Creates an allowed access result if the permissions are present, neutral otherwise.
AccessResultTest::providerTestAllowedIfHasPermissions in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
Provides data for the testAllowedIfHasPermissions() method.
AccessResultTest::testAccessConditionallyAllowed in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
@covers ::allowedIf @covers ::isAllowed @covers ::isForbidden @covers ::isNeutral

... See full list

File

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

Class

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

Namespace

Drupal\Core\Access

Code

public static function allowedIf($condition) {
  return $condition ? static::allowed() : static::neutral();
}