dolibarr 25.0.0-alpha
RightsSyncCommand Class Reference

Immutable request describing one permissions sync to perform on a module descriptor. More...

Collaboration diagram for RightsSyncCommand:

Static Public Member Functions

static forObjectCreation (string $module, string $descriptorFile, array $permissions, string $objectName)
 Declare the three CRUD rights of a newly generated object.
 
static forObjectDeletion (string $module, string $descriptorFile, array $permissions, string $objectName)
 Drop every right attached to an object being deleted.
 
static forRightAddition (string $module, string $descriptorFile, array $permissions, string $objectName, string $label, string $crud)
 Append one right to the descriptor.
 
static forRightUpdate (string $module, string $descriptorFile, array $permissions, int $rightKey, string $objectName, string $label, string $crud)
 Replace one right, addressed by its index in the rights array.
 
static forRightDeletion (string $module, string $descriptorFile, array $permissions, int $rightKey)
 Remove one right, addressed by its index in the rights array.
 

Private Member Functions

 __construct (string $module, string $descriptorFile, array $permissions, string $objectName, string $scope, string $actionType, ?int $rightKey=null, ?string $rightLabel=null, ?string $rightCrud=null)
 

Detailed Description

Immutable request describing one permissions sync to perform on a module descriptor.

ModuleBuilder triggers project onto two axes, not one: a scope (the three CRUD rights of an object, or a single right) and an action. The five real triggers are the five named factories below; there is no object-scoped update.

The command deliberately carries the current rights array along with the intent. That keeps RightsSyncService free of $db, dol_include_once() and globals, so it stays unit-testable against a throwaway fixture file.

Definition at line 35 of file RightsSyncCommand.class.php.

Constructor & Destructor Documentation

◆ __construct()

RightsSyncCommand::__construct ( string $module,
string $descriptorFile,
array $permissions,
string $objectName,
string $scope,
string $actionType,
?int $rightKey = null,
?string $rightLabel = null,
?string $rightCrud = null )
private
Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
string$objectNameTarget object, may be empty for right deletion
string$scopeOne of SCOPE_*
string$actionTypeOne of ACTION_*
int | null$rightKeyIndex in $permissions
string | null$rightLabelPermission label
string | null$rightCrudPermission crud code
Exceptions

InvalidArgumentException When the command is incomplete for its scope and action

Definition at line 83 of file RightsSyncCommand.class.php.

Member Function Documentation

◆ forObjectCreation()

static RightsSyncCommand::forObjectCreation ( string $module,
string $descriptorFile,
array $permissions,
string $objectName )
static

Declare the three CRUD rights of a newly generated object.

Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
string$objectNameObject being generated
Returns
self

Definition at line 141 of file RightsSyncCommand.class.php.

Referenced by reWriteAllPermissions().

◆ forObjectDeletion()

static RightsSyncCommand::forObjectDeletion ( string $module,
string $descriptorFile,
array $permissions,
string $objectName )
static

Drop every right attached to an object being deleted.

Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
string$objectNameObject being deleted
Returns
self

Definition at line 155 of file RightsSyncCommand.class.php.

Referenced by reWriteAllPermissions().

◆ forRightAddition()

static RightsSyncCommand::forRightAddition ( string $module,
string $descriptorFile,
array $permissions,
string $objectName,
string $label,
string $crud )
static

Append one right to the descriptor.

Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
string$objectNameObject the right belongs to
string$labelPermission label
string$crudPermission crud code
Returns
self

Definition at line 171 of file RightsSyncCommand.class.php.

Referenced by reWriteAllPermissions().

◆ forRightDeletion()

static RightsSyncCommand::forRightDeletion ( string $module,
string $descriptorFile,
array $permissions,
int $rightKey )
static

Remove one right, addressed by its index in the rights array.

Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
int$rightKeyIndex of the right to remove
Returns
self

Definition at line 202 of file RightsSyncCommand.class.php.

Referenced by reWriteAllPermissions().

◆ forRightUpdate()

static RightsSyncCommand::forRightUpdate ( string $module,
string $descriptorFile,
array $permissions,
int $rightKey,
string $objectName,
string $label,
string $crud )
static

Replace one right, addressed by its index in the rights array.

Parameters
string$moduleModule name
string$descriptorFilePath to the descriptor to patch
array<int,array<int,string>>$permissions Current rights array
int$rightKeyIndex of the right to replace
string$objectNameObject the right belongs to
string$labelNew permission label
string$crudNew permission crud code
Returns
self

Definition at line 188 of file RightsSyncCommand.class.php.

Referenced by reWriteAllPermissions().


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