W3cubDocs

/Drupal 8

public static function AccessResult::forbiddenIf

public static AccessResult::forbiddenIf($condition)

Creates a forbidden or neutral access result.

Parameters

bool $condition: The condition to evaluate.

Return value

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

File

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

Class

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

Namespace

Drupal\Core\Access

Code

public static function forbiddenIf($condition) {
  return $condition ? static::forbidden() : static::neutral();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Access!AccessResult.php/function/AccessResult::forbiddenIf/8.1.x