Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294800

AccessResult::forbiddenIf reason

$
0
0

Problem/Motivation

The AccessResult::forbidden() method takes an optional $reason parameter, but the AccessResult::forbiddenIf() method only takes a $condition boolean.

Proposed resolution

I'm proposing to add an optional parameter to forbiddenIf() that is $reason, which can then be passed to forbidden() when the $condition is true.

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

User interface changes

N/A

API changes

N/A, optional parameter

Wanted to get feedback on this issue before working on it, but I think it's something I can post a patch for...


Viewing all articles
Browse latest Browse all 294800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>