PageIdClassGenerator
in package
FinalYes
Builds the source of the generated {@see PageId} class from `config/Shared/pages.neon`.
The neon file is the only place where front page ids are written down. Code refers to them
through the generated constants, so renumbering pages in the database means editing the neon
file and regenerating the class (php bin/generate-page-ids.php), not searching the code.
Tests\Unit\Routers\PageIdSyncTest fails when the committed class differs from the neon file.
Table of Contents
Constants
- CLASS_FILE : string = 'app/Core/Routers/PageId.php'
- NEON_FILE : string = 'config/Shared/pages.neon'
Methods
- constantName() : string
- Converts `module` + `camelKey` to `MODULE_CAMEL_KEY`.
- generate() : string
- Returns the PHP source of the {@see PageId} class for the given map.
- readMap() : array<string, array<string, int>>
- Reads the page map from the neon file.
Constants
CLASS_FILE
public
string
CLASS_FILE
= 'app/Core/Routers/PageId.php'
NEON_FILE
public
string
NEON_FILE
= 'config/Shared/pages.neon'
Methods
constantName()
Converts `module` + `camelKey` to `MODULE_CAMEL_KEY`.
public
static constantName(string $module, string $key) : string
Parameters
- $module : string
- $key : string
Return values
stringgenerate()
Returns the PHP source of the {@see PageId} class for the given map.
public
static generate(array<string, array<string, int>> $map) : string
Parameters
- $map : array<string, array<string, int>>
-
module => key => page id
Return values
stringreadMap()
Reads the page map from the neon file.
public
static readMap(string $neonFile) : array<string, array<string, int>>
Parameters
- $neonFile : string
Return values
array<string, array<string, int>> —module => key => page id