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

Rename customAttributes to just attributes

These are all the attributes we have now.
parent 7ed81087
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ class AuthorizationDataMuxer ...@@ -10,7 +10,7 @@ class AuthorizationDataMuxer
private $authorizationDataProviders; private $authorizationDataProviders;
/** @var array */ /** @var array */
private $customAttributes; private $attributes;
/** /**
* @param iterable<AuthorizationDataProviderInterface> $authorizationDataProviders * @param iterable<AuthorizationDataProviderInterface> $authorizationDataProviders
...@@ -18,7 +18,7 @@ class AuthorizationDataMuxer ...@@ -18,7 +18,7 @@ class AuthorizationDataMuxer
public function __construct(iterable $authorizationDataProviders) public function __construct(iterable $authorizationDataProviders)
{ {
$this->authorizationDataProviders = $authorizationDataProviders; $this->authorizationDataProviders = $authorizationDataProviders;
$this->customAttributes = []; $this->attributes = [];
} }
private function loadUserAttributesFromAuthorizationProvider(?string $userIdentifier, AuthorizationDataProviderInterface $authorizationDataProvider): void private function loadUserAttributesFromAuthorizationProvider(?string $userIdentifier, AuthorizationDataProviderInterface $authorizationDataProvider): void
...@@ -27,7 +27,7 @@ class AuthorizationDataMuxer ...@@ -27,7 +27,7 @@ class AuthorizationDataMuxer
foreach ($authorizationDataProvider->getAvailableAttributes() as $availableAttribute) { foreach ($authorizationDataProvider->getAvailableAttributes() as $availableAttribute) {
if (array_key_exists($availableAttribute, $userAttributes)) { if (array_key_exists($availableAttribute, $userAttributes)) {
$this->customAttributes[$availableAttribute] = $userAttributes[$availableAttribute]; $this->attributes[$availableAttribute] = $userAttributes[$availableAttribute];
} }
} }
} }
...@@ -55,19 +55,19 @@ class AuthorizationDataMuxer ...@@ -55,19 +55,19 @@ class AuthorizationDataMuxer
* *
* @throws AuthorizationException * @throws AuthorizationException
*/ */
public function getCustomAttribute(?string $userIdentifier, string $attributeName, $defaultValue = null) public function getAttribute(?string $userIdentifier, string $attributeName, $defaultValue = null)
{ {
if (array_key_exists($attributeName, $this->customAttributes) === false) { if (array_key_exists($attributeName, $this->attributes) === false) {
$this->loadCustomAttribute($userIdentifier, $attributeName); $this->loadAttribute($userIdentifier, $attributeName);
} }
return $this->customAttributes[$attributeName] ?? $defaultValue; return $this->attributes[$attributeName] ?? $defaultValue;
} }
/** /**
* @throws AuthorizationException * @throws AuthorizationException
*/ */
private function loadCustomAttribute(?string $userIdentifier, string $attributeName): void private function loadAttribute(?string $userIdentifier, string $attributeName): void
{ {
$wasFound = false; $wasFound = false;
foreach ($this->authorizationDataProviders as $authorizationDataProvider) { foreach ($this->authorizationDataProviders as $authorizationDataProvider) {
......
...@@ -77,7 +77,7 @@ class AuthorizationExpressionChecker ...@@ -77,7 +77,7 @@ class AuthorizationExpressionChecker
*/ */
public function getCustomAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null) public function getCustomAttribute(AuthorizationUser $currentAuthorizationUser, string $attributeName, $defaultValue = null)
{ {
return $this->dataMux->getCustomAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue); return $this->dataMux->getAttribute($currentAuthorizationUser->getIdentifier(), $attributeName, $defaultValue);
} }
/** /**
......
...@@ -46,7 +46,7 @@ class DebugCommand extends Command implements LoggerAwareInterface ...@@ -46,7 +46,7 @@ class DebugCommand extends Command implements LoggerAwareInterface
$default = new \stdClass(); $default = new \stdClass();
sort($attrs, SORT_STRING | SORT_FLAG_CASE); sort($attrs, SORT_STRING | SORT_FLAG_CASE);
foreach ($attrs as $attr) { foreach ($attrs as $attr) {
$all[$attr] = $mux->getCustomAttribute($username, $attr, $default); $all[$attr] = $mux->getAttribute($username, $attr, $default);
} }
// Now print them out // Now print them out
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment