You are here

public static function AccessResult::allowedIf in Drupal 8

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

16 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.
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
BlockHasOverridesAccessCheck::access in core/modules/settings_tray/src/Access/BlockHasOverridesAccessCheck.php
Checks access for accessing a block's 'settings_tray' form.
BlockPluginHasSettingsTrayFormAccessCheck::accessBlockPlugin in core/modules/settings_tray/src/Access/BlockPluginHasSettingsTrayFormAccessCheck.php
Checks access for accessing a block plugin's 'settings_tray' form.

... See full list

File

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

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