Skip to content
Snippets Groups Projects
Commit 93718322 authored by Tobias Gross-Vogt's avatar Tobias Gross-Vogt
Browse files

extended authorization config node defintions by right/attribute info

parent 80a5583d
No related branches found
No related tags found
No related merge requests found
Pipeline #227773 passed
...@@ -90,8 +90,12 @@ abstract class AbstractAuthorizationService ...@@ -90,8 +90,12 @@ abstract class AbstractAuthorizationService
} }
/** /**
* @param array $rights the mapping between right names and right default expressions * Create the 'authorization' config node definition with the given right and attribute definitions.
* @param array $attributes the mapping between attribute names and attribute default expressions * A definition is an array of the following form:
* [0 => <nameString>, 1 => <defaultExpressionString> (optional, default: 'false'), 2 => <infoString> (optional, default: 'null')].
*
* @param array[] $rights the list of right definitions
* @param array[] $attributes the list of attribute definitions
*/ */
public static function getAuthorizationConfigNodeDefinition(array $rights = [], array $attributes = []): NodeDefinition public static function getAuthorizationConfigNodeDefinition(array $rights = [], array $attributes = []): NodeDefinition
{ {
...@@ -100,18 +104,20 @@ abstract class AbstractAuthorizationService ...@@ -100,18 +104,20 @@ abstract class AbstractAuthorizationService
$rightsNodeChildBuilder = $treeBuilder->getRootNode()->children()->arrayNode(AuthorizationExpressionChecker::RIGHTS_CONFIG_NODE) $rightsNodeChildBuilder = $treeBuilder->getRootNode()->children()->arrayNode(AuthorizationExpressionChecker::RIGHTS_CONFIG_NODE)
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children(); ->children();
foreach ($rights as $rightName => $defaultExpression) { foreach ($rights as $right) {
$rightsNodeChildBuilder->scalarNode($rightName) $rightsNodeChildBuilder->scalarNode($right[0])
->defaultValue($defaultExpression ?? 'false') ->defaultValue($right[1] ?? 'false')
->info($right[2] ?? '')
->end(); ->end();
} }
$attributesNodeChildBuilder = $treeBuilder->getRootNode()->children()->arrayNode(AuthorizationExpressionChecker::ATTRIBUTES_CONFIG_NODE) $attributesNodeChildBuilder = $treeBuilder->getRootNode()->children()->arrayNode(AuthorizationExpressionChecker::ATTRIBUTES_CONFIG_NODE)
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children(); ->children();
foreach ($attributes as $attributeName => $defaultExpression) { foreach ($attributes as $attribute) {
$attributesNodeChildBuilder->scalarNode($attributeName) $attributesNodeChildBuilder->scalarNode($attribute[0])
->defaultValue($defaultExpression ?? 'null') ->defaultValue($attribute[1] ?? 'null')
->info($attribute[2] ?? '')
->end(); ->end();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment