Skip to content
Snippets Groups Projects
Commit f1469c60 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

ExpressionChecker: naming cleanup

Avoid using "attributes" for both the user attributes and the attribute expressions.
Instead call the "user attributes" and "attribute expressions".
parent 1de0ce92
No related branches found
No related tags found
No related merge requests found
Pipeline #211960 passed
...@@ -78,7 +78,7 @@ abstract class AbstractAuthorizationService ...@@ -78,7 +78,7 @@ abstract class AbstractAuthorizationService
{ {
$this->userAuthorizationChecker->init(); $this->userAuthorizationChecker->init();
return $this->userAuthorizationChecker->getAttribute($this->currentAuthorizationUser, $attributeName, $defaultValue); return $this->userAuthorizationChecker->evalAttributeExpression($this->currentAuthorizationUser, $attributeName, $defaultValue);
} }
/** /**
......
...@@ -56,19 +56,19 @@ class AuthorizationExpressionChecker ...@@ -56,19 +56,19 @@ class AuthorizationExpressionChecker
* *
* @return mixed|null * @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) { if (($expression = $this->attributeExpressions[$expressionName] ?? null) !== null) {
$attribute = $this->expressionLanguage->evaluate($attributeExpression, [ $result = $this->expressionLanguage->evaluate($expression, [
'user' => $currentAuthorizationUser, 'user' => $currentAuthorizationUser,
]); ]);
} else { } 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 ...@@ -78,7 +78,7 @@ class AuthorizationExpressionChecker
* *
* @throws AuthorizationException * @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); return $this->dataMux->getAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue);
} }
......
...@@ -37,7 +37,7 @@ class AuthorizationUser ...@@ -37,7 +37,7 @@ class AuthorizationUser
*/ */
public function getAttribute(string $attributeName, $defaultValue = null) 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 ...@@ -59,6 +59,6 @@ class AuthorizationUser
*/ */
public function get(string $attributeName, $defaultValue = null) public function get(string $attributeName, $defaultValue = null)
{ {
return $this->authorizationChecker->getCustomAttribute($this, $attributeName, $defaultValue); return $this->authorizationChecker->getUserAttribute($this, $attributeName, $defaultValue);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment