dolibarr 25.0.0-alpha
PredicateRule Class Reference

Leaf of the access rule tree: one whitelisted condition on the user. More...

Inheritance diagram for PredicateRule:
Collaboration diagram for PredicateRule:

Public Member Functions

 __construct (string $name)
 
 getName ()
 
 toPhp ()
 Render the predicate as a PHP boolean expression.
 
 toArray ()
 

Public Attributes

const PREDICATES
 PHP rendered for each predicate.
 

Detailed Description

Leaf of the access rule tree: one whitelisted condition on the user.

Definition at line 29 of file PredicateRule.class.php.

Constructor & Destructor Documentation

◆ __construct()

PredicateRule::__construct ( string $name)
Parameters
string$nameName of the predicate, one of the keys of PREDICATES
Exceptions

InvalidArgumentException When the predicate is not whitelisted

Definition at line 58 of file PredicateRule.class.php.

References name.

Member Function Documentation

◆ getName()

PredicateRule::getName ( )
Returns
string Name of the predicate

Definition at line 69 of file PredicateRule.class.php.

◆ toArray()

PredicateRule::toArray ( )
Returns
array{type:string,name:string}

Implements AccessRuleExpression.

Definition at line 87 of file PredicateRule.class.php.

References name.

◆ toPhp()

PredicateRule::toPhp ( )

Render the predicate as a PHP boolean expression.

Returns
string PHP boolean expression

Implements AccessRuleExpression.

Definition at line 79 of file PredicateRule.class.php.

Member Data Documentation

◆ PREDICATES

const PredicateRule::PREDICATES
Initial value:
= array(
self::IS_ADMIN => '!empty($user->admin)',
self::IS_INTERNAL_USER => 'empty($user->socid)',
self::CAN_READ_OBJECT => "\$user->hasRight('mymodule', 'myobject', 'read')",
self::CAN_WRITE_OBJECT => "\$user->hasRight('mymodule', 'myobject', 'write')",
self::CAN_DELETE_OBJECT => "\$user->hasRight('mymodule', 'myobject', 'delete')",
)

PHP rendered for each predicate.

The mymodule and myobject tokens are replaced by the generator with the names of the generated module and object.

Definition at line 43 of file PredicateRule.class.php.


The documentation for this class was generated from the following file: