Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Access / AccessResult.php
index 1cd6b8bacdc7f78562a8809df124aadb2c8b8bcd..0070e089320cdb2883b4ca54bdf4d791e9ea8730 100644 (file)
@@ -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();
   }
 
   /**