Added voter reason explaination to the other voters

This commit is contained in:
Jan Böhmer 2025-09-06 00:24:55 +02:00
parent 117ff4484d
commit eb4258053e
14 changed files with 65 additions and 35 deletions

View file

@ -54,11 +54,16 @@ final class VoterHelper
* @param TokenInterface $token The token to check
* @param string $permission The permission to check
* @param string $operation The operation to check
* @param Vote|null $vote The vote object to add reasons to (optional). If null, no reasons are added.
* @return bool
*/
public function isGranted(TokenInterface $token, string $permission, string $operation): bool
public function isGranted(TokenInterface $token, string $permission, string $operation, ?Vote $vote = null): bool
{
return $this->isGrantedTrinary($token, $permission, $operation) ?? false;
$tmp = $this->isGrantedTrinary($token, $permission, $operation) ?? false;
if ($tmp === false) {
$this->addReason($vote, $permission, $operation);
}
return $tmp;
}
/**