dolibarr 25.0.0-alpha
PermissionsBlock Class Reference

Text engine for the BEGIN/END MODULEBUILDER PERMISSIONS section of a module descriptor. More...

Collaboration diagram for PermissionsBlock:

Public Member Functions

 getInnerBlock ()
 Raw content between the markers, markers excluded.
 
 detectTextConflicts ()
 List the reasons why rewriting this block would destroy something.
 
 detectRightsShapeConflicts (array $permissions)
 List the rights that cannot be rendered at all.
 

Static Public Member Functions

static fromFile (string $file)
 Read a descriptor and locate its permissions block.
 

Private Member Functions

 __construct (string $file, string $innerBlock)
 

Detailed Description

Text engine for the BEGIN/END MODULEBUILDER PERMISSIONS section of a module descriptor.

Owns everything that touches the raw text of that section: locating it, deciding whether it is safe to rewrite, rendering a new one from a rights array, and writing it back in a single pass.

Definition at line 32 of file PermissionsBlock.class.php.

Constructor & Destructor Documentation

◆ __construct()

PermissionsBlock::__construct ( string $file,
string $innerBlock )
private
Parameters
string$filePath to the descriptor file
string$innerBlockContent between the markers

Definition at line 92 of file PermissionsBlock.class.php.

Member Function Documentation

◆ detectRightsShapeConflicts()

PermissionsBlock::detectRightsShapeConflicts ( array $permissions)

List the rights that cannot be rendered at all.

Parameters
array<int,array<int,string>>$permissions Rights array to inspect
Returns
string[] Plain English reasons, empty when every right is renderable

Definition at line 196 of file PermissionsBlock.class.php.

◆ detectTextConflicts()

PermissionsBlock::detectTextConflicts ( )

List the reasons why rewriting this block would destroy something.

Comments are ignored, which is what makes a brand new module — whose block holds the fully commented-out template — rewritable. Everything else must belong to the whitelist: a block that computes its rights (loop, condition, translation call) cannot be reproduced by render() and must never be flattened into static lines.

Returns
string[] Plain English reasons, empty when the block is safe to rewrite

Definition at line 150 of file PermissionsBlock.class.php.

References $id.

◆ fromFile()

static PermissionsBlock::fromFile ( string $file)
static

Read a descriptor and locate its permissions block.

Parameters
string$filePath to the mod<Module>.class.php descriptor
Returns
self New PermissionsBlock instance
Exceptions

RuntimeException When the file is unreadable or the markers are missing or inverted

Definition at line 105 of file PermissionsBlock.class.php.

References dol_is_file(), dol_strlen(), and dol_substr().

Referenced by deletePerms(), and DescriptorRightsSyncService\sync().

◆ getInnerBlock()

PermissionsBlock::getInnerBlock ( )

Raw content between the markers, markers excluded.

Returns
string Permissions block content without markers

Definition at line 135 of file PermissionsBlock.class.php.


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