diff core/lib/Drupal/Core/Access/AccessResult.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children c2387f117808
line wrap: on
line diff
--- a/core/lib/Drupal/Core/Access/AccessResult.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/core/lib/Drupal/Core/Access/AccessResult.php	Mon Apr 23 09:46:53 2018 +0100
@@ -39,7 +39,7 @@
    *   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 @@
    *   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 @@
    *
    * @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();
   }
 
   /**