|
dolibarr 24.0.0-beta
|
Immutable value object holding all case variants of a module/object pair. More...
Public Member Functions | |
| __construct (string $moduleName, string $objectName='') | |
| getSubstitutionMap () | |
| Returns the canonical, ordered substitution map. | |
| applyTo (string $content) | |
| Apply the canonical substitution map to a string (file content). | |
| applyToFilename (string $filename) | |
| Apply substitution to a filename (lowercase tokens only). | |
Immutable value object holding all case variants of a module/object pair.
Provides the canonical, ordered substitution map used by modulebuilder template generation. The substitution order in getSubstitutionMap() is deterministic: uppercase and mixed-case tokens always precede lowercase ones, preventing partial matches when str_replace processes entries sequentially on the same string.
applyTo() uses str_replace() directly — NOT make_substitutions() — to avoid unintended processing of Dolibarr's __(key)__ and [key] patterns present in raw template content.
Definition at line 36 of file NamingContract.class.php.
| string | $moduleName | Raw module name — accepts any casing, ucfirst() is applied |
| string | $objectName | Raw object name — empty string creates a module-only contract |
InvalidArgumentException If module and object names are identical (case-insensitive)
Definition at line 61 of file NamingContract.class.php.
| NamingContract::applyTo | ( | string | $content | ) |
Apply the canonical substitution map to a string (file content).
| string | $content | File content to process |
Definition at line 124 of file NamingContract.class.php.
References getSubstitutionMap().
| NamingContract::applyToFilename | ( | string | $filename | ) |
Apply substitution to a filename (lowercase tokens only).
Filenames in Dolibarr are always lowercase — only mymodule/myobject are substituted. For module-only contracts (objectNameLower = ''), myobject is not substituted.
| string | $filename | Template filename containing mymodule/myobject placeholders |
Definition at line 139 of file NamingContract.class.php.
| NamingContract::getSubstitutionMap | ( | ) |
Returns the canonical, ordered substitution map.
Order matters: uppercase and mixed-case tokens precede lowercase tokens so that str_replace sequential processing cannot partially consume a longer token variant. Object tokens (positions 8–12) are omitted for module-only contracts (objectName = '').
Definition at line 95 of file NamingContract.class.php.
Referenced by applyTo().