dolibarr 25.0.0-alpha
DescriptorRightsSyncService Class Reference

Syncs rights straight into the mod<Module>.class.php descriptor file. More...

Inheritance diagram for DescriptorRightsSyncService:
Collaboration diagram for DescriptorRightsSyncService:

Public Member Functions

 sync (RightsSyncCommand $cmd)
 Apply one sync command to a module descriptor.
 

Private Member Functions

 applyCommand (RightsSyncCommand $cmd)
 Produce the rights array the descriptor should now declare.
 
 addObjectRights (array $permissions, string $module, string $objectName)
 Append the three CRUD rights of a freshly generated object.
 
 removeObjectRights (array $permissions, string $objectName)
 Drop every right attached to an object.
 
 addRight (array $permissions, string $objectName, string $label, string $crud)
 Append one right, refusing a crud code the object already declares.
 

Detailed Description

Syncs rights straight into the mod<Module>.class.php descriptor file.

Error-first: every reason not to write is collected before the rights array is touched, and a single conflict aborts the whole run without writing. A half-written permissions section is worse than a stale one.

Definition at line 49 of file RightsSyncService.class.php.

Member Function Documentation

◆ addObjectRights()

DescriptorRightsSyncService::addObjectRights ( array $permissions,
string $module,
string $objectName )
private

Append the three CRUD rights of a freshly generated object.

Parameters
array<int,array<int,string>>$permissions Current rights
string$moduleModule name
string$objectNameObject being generated
Returns
array<int,array<int,string>>|null New rights, or null when the object already owns rights

Definition at line 176 of file RightsSyncService.class.php.

Referenced by applyCommand().

◆ addRight()

DescriptorRightsSyncService::addRight ( array $permissions,
string $objectName,
string $label,
string $crud )
private

Append one right, refusing a crud code the object already declares.

Parameters
array<int,array<int,string>>$permissions Current rights
string$objectNameObject the right belongs to
string$labelPermission label
string$crudPermission crud code
Returns
array<int,array<int,string>> New rights
Exceptions

InvalidArgumentException When the object already declares that crud code

Definition at line 231 of file RightsSyncService.class.php.

Referenced by applyCommand().

◆ applyCommand()

DescriptorRightsSyncService::applyCommand ( RightsSyncCommand $cmd)
private

Produce the rights array the descriptor should now declare.

Parameters
RightsSyncCommand$cmdCommand to apply
Returns
array<int,array<int,string>>|null New rights array, or null when the command is a no-op
Exceptions

InvalidArgumentException When the command targets a right that cannot be addressed

Definition at line 134 of file RightsSyncService.class.php.

References addObjectRights(), addRight(), and removeObjectRights().

Referenced by sync().

◆ removeObjectRights()

DescriptorRightsSyncService::removeObjectRights ( array $permissions,
string $objectName )
private

Drop every right attached to an object.

Filtering, not array_splice() inside a foreach over the same array.

Parameters
array<int,array<int,string>>$permissions Current rights
string$objectNameObject being deleted
Returns
array<int,array<int,string>> Remaining rights
Parameters
array<int,string>$right Right to keep or drop
Returns
bool

Definition at line 205 of file RightsSyncService.class.php.

Referenced by applyCommand().

◆ sync()

DescriptorRightsSyncService::sync ( RightsSyncCommand $cmd)

Apply one sync command to a module descriptor.

Parameters
RightsSyncCommand$cmdCommand to apply
Returns
SyncReport Outcome — a report carrying conflicts means nothing was written

Implements RightsSyncService.

Definition at line 73 of file RightsSyncService.class.php.

References applyCommand(), dol_syslog(), and PermissionsBlock\fromFile().


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