|
dolibarr 25.0.0-alpha
|
Immutable access policy of the pages generated by ModuleBuilder: a rule tree and a deny message. More...

Public Member Functions | |
| __construct (AccessRuleExpression $expression, string $message='') | |
| toJson () | |
| Serialize the policy. | |
| getExpression () | |
| getMessage () | |
Static Public Member Functions | |
| static | fromAlternatives (array $alternatives, string $message='') |
| Build a policy from the editor of ModuleBuilder: the predicates of an alternative are combined with AND, the alternatives with OR. | |
| static | fromJson (string $json) |
| Load a serialized policy, as produced by toJson(). | |
Static Private Member Functions | |
| static | buildNode ($data, int $depth) |
| Build a node of the tree from its serialized form. | |
| static | checkBounds (AccessRuleExpression $node, int $depth, int &$nodecount) |
| Check that a tree stays within MAX_DEPTH and MAX_NODES. | |
Immutable access policy of the pages generated by ModuleBuilder: a rule tree and a deny message.
A policy is always valid once built: every way in (constructor, fromJson(), fromAlternatives()) rejects an unknown node, an unknown predicate, a tree out of bounds or a message that is not a translation key.
Definition at line 36 of file AccessPolicyConfig.class.php.
| AccessPolicyConfig::__construct | ( | AccessRuleExpression | $expression, |
| string | $message = '' ) |
| AccessRuleExpression | $expression | Root of the rule tree |
| string | $message | Translation key shown on deny, empty for the default message |
InvalidArgumentException When the tree is out of bounds or the message is not a translation key
Definition at line 54 of file AccessPolicyConfig.class.php.
References checkBounds().
|
staticprivate |
Build a node of the tree from its serialized form.
| mixed | $data | Serialized node |
| int | $depth | Depth of the node, 1 for the root |
InvalidArgumentException When the node is invalid or too deep
Definition at line 163 of file AccessPolicyConfig.class.php.
References buildNode().
Referenced by buildNode(), and fromJson().
|
staticprivate |
Check that a tree stays within MAX_DEPTH and MAX_NODES.
| AccessRuleExpression | $node | Node to check |
| int | $depth | Depth of the node, 1 for the root |
| int | $nodecount | Number of nodes met so far, updated |
InvalidArgumentException When the tree is out of bounds
Definition at line 201 of file AccessPolicyConfig.class.php.
References checkBounds().
Referenced by __construct(), and checkBounds().
|
static |
Build a policy from the editor of ModuleBuilder: the predicates of an alternative are combined with AND, the alternatives with OR.
Empty alternatives are ignored.
| array<int,string[]> | $alternatives List of alternatives, each one a list of predicate names | |
| string | $message | Translation key shown on deny |
InvalidArgumentException When there are too many alternatives or a predicate is unknown
Definition at line 75 of file AccessPolicyConfig.class.php.
|
static |
Load a serialized policy, as produced by toJson().
| string | $json | Serialized policy |
InvalidArgumentException When the content is not a valid policy
Definition at line 112 of file AccessPolicyConfig.class.php.
References buildNode().
Referenced by getModuleBuilderAccessPolicyFromClassFile().
| AccessPolicyConfig::getExpression | ( | ) |
Definition at line 142 of file AccessPolicyConfig.class.php.
| AccessPolicyConfig::getMessage | ( | ) |
Definition at line 150 of file AccessPolicyConfig.class.php.
Referenced by renderModuleBuilderAccessPolicyBlock().
| AccessPolicyConfig::toJson | ( | ) |
Serialize the policy.
The order of the rules is kept, so the output is deterministic.
Definition at line 134 of file AccessPolicyConfig.class.php.
Referenced by renderModuleBuilderAccessPolicyProperty().