X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FAccess%2FAccessResult.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FAccess%2FAccessResult.php;h=0070e089320cdb2883b4ca54bdf4d791e9ea8730;hp=1cd6b8bacdc7f78562a8809df124aadb2c8b8bcd;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/lib/Drupal/Core/Access/AccessResult.php b/web/core/lib/Drupal/Core/Access/AccessResult.php index 1cd6b8bac..0070e0893 100644 --- a/web/core/lib/Drupal/Core/Access/AccessResult.php +++ b/web/core/lib/Drupal/Core/Access/AccessResult.php @@ -39,7 +39,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable * isNeutral() will be TRUE. */ public static function neutral($reason = NULL) { - assert('is_string($reason) || is_null($reason)'); + assert(is_string($reason) || is_null($reason)); return new AccessResultNeutral($reason); } @@ -64,7 +64,7 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable * isForbidden() will be TRUE. */ public static function forbidden($reason = NULL) { - assert('is_string($reason) || is_null($reason)'); + assert(is_string($reason) || is_null($reason)); return new AccessResultForbidden($reason); } @@ -87,13 +87,16 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable * * @param bool $condition * The condition to evaluate. + * @param string|null $reason + * (optional) The reason why access is forbidden. Intended for developers, + * hence not translatable * * @return \Drupal\Core\Access\AccessResult * If $condition is TRUE, isForbidden() will be TRUE, otherwise isNeutral() * will be TRUE. */ - public static function forbiddenIf($condition) { - return $condition ? static::forbidden() : static::neutral(); + public static function forbiddenIf($condition, $reason = NULL) { + return $condition ? static::forbidden($reason) : static::neutral(); } /**