diff --git a/src/Authorization/AbstractAuthorizationService.php b/src/Authorization/AbstractAuthorizationService.php index 28cefd43111b5921df06271befba80bd4a47f482..5daddb85610fc936d88d0669cb975acb3bb2529a 100644 --- a/src/Authorization/AbstractAuthorizationService.php +++ b/src/Authorization/AbstractAuthorizationService.php @@ -78,7 +78,7 @@ abstract class AbstractAuthorizationService { $this->userAuthorizationChecker->init(); - return $this->userAuthorizationChecker->getAttribute($this->currentAuthorizationUser, $attributeName, $defaultValue); + return $this->userAuthorizationChecker->evalAttributeExpression($this->currentAuthorizationUser, $attributeName, $defaultValue); } /** diff --git a/src/Authorization/AuthorizationExpressionChecker.php b/src/Authorization/AuthorizationExpressionChecker.php index c903ff85c947f5bd1bd8284a1b201c806c668ff4..9471bd8af14a74bd25697d21f9a8c87b71bc3057 100644 --- a/src/Authorization/AuthorizationExpressionChecker.php +++ b/src/Authorization/AuthorizationExpressionChecker.php @@ -56,19 +56,19 @@ class AuthorizationExpressionChecker * * @return mixed|null */ - public function getAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null) + public function evalAttributeExpression(AuthorizationUser $currentAuthorizationUser, string $expressionName, $defaultValue = null) { - $this->tryIncreaseRecursionCounter($attributeName); + $this->tryIncreaseRecursionCounter($expressionName); - if (($attributeExpression = $this->attributeExpressions[$attributeName] ?? null) !== null) { - $attribute = $this->expressionLanguage->evaluate($attributeExpression, [ + if (($expression = $this->attributeExpressions[$expressionName] ?? null) !== null) { + $result = $this->expressionLanguage->evaluate($expression, [ 'user' => $currentAuthorizationUser, ]); } else { - throw new AuthorizationException(sprintf('attribute \'%s\' undefined', $attributeName), AuthorizationException::ATTRIBUTE_UNDEFINED); + throw new AuthorizationException(sprintf('expression \'%s\' undefined', $expressionName), AuthorizationException::ATTRIBUTE_UNDEFINED); } - return $attribute ?? $defaultValue; + return $result ?? $defaultValue; } /** @@ -78,7 +78,7 @@ class AuthorizationExpressionChecker * * @throws AuthorizationException */ - public function getCustomAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null) + public function getUserAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null) { return $this->dataMux->getAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue); } diff --git a/src/Authorization/AuthorizationUser.php b/src/Authorization/AuthorizationUser.php index 2fafe5efc218df8327e5ddb1bfc640f2eb06463f..8a6a1361706f2517bd867eaaf1d9b27b75c0fc69 100644 --- a/src/Authorization/AuthorizationUser.php +++ b/src/Authorization/AuthorizationUser.php @@ -37,7 +37,7 @@ class AuthorizationUser */ public function getAttribute(string $attributeName, $defaultValue = null) { - return $this->authorizationChecker->getAttribute($this, $attributeName, $defaultValue); + return $this->authorizationChecker->evalAttributeExpression($this, $attributeName, $defaultValue); } /** @@ -59,6 +59,6 @@ class AuthorizationUser */ public function get(string $attributeName, $defaultValue = null) { - return $this->authorizationChecker->getCustomAttribute($this, $attributeName, $defaultValue); + return $this->authorizationChecker->getUserAttribute($this, $attributeName, $defaultValue); } }