ConfigHandler
ConfigHandler allows a developer to create a custom formatted configuration file pertaining to any information they like and still have it auto-generate PHP code.
Synopsis
Section titled “Synopsis”abstract class ConfigHandler extends BaseConfigHandler implements ILegacyConfigHandler
| Extends | BaseConfigHandler |
| Implements | ILegacyConfigHandler |
| Since | 1.0.0 |
| Source | Config/ConfigHandler.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$parser | mixed | protected. |
$validationFile | mixed | protected. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
| [`getItemParameters(ConfigValueHolder $itemNode, array<int | string, mixed> $oldValues = [], boolean $literalize = true): array<int |
getValidationFile(): ?string | Retrieves the stored validation filename. |
initialize(?string $validationFile = null, ?string $parser = null, array<string, mixed> $parameters = []): void | Initialize this ConfigHandler. |
orderConfigurations(ConfigValueHolder $configurations, ?string $environment = null, ?string $context = null, bool $autoloadParser = true): array<int, ConfigValueHolder> | Returns a properly ordered array of ConfigValueHolder configuration elements for given env and context. |
testPattern(string $pattern, string $subject): bool | Builds a proper regular expression from the input pattern to test against the given subject. |
getItemParameters()
Section titled “getItemParameters()”protected function getItemParameters(ConfigValueHolder $itemNode, array<int|string, mixed> $oldValues = [], boolean $literalize = true): array<int|string, mixed>
Retrieve the parameter node values of the given item’s parameters element.
Whether or not values should be literalized.
| Parameter | Type | Description |
|---|---|---|
$itemNode | ConfigValueHolder | The node that contains a parameters child. |
$oldValues | `array<int“ | string, mixed>` |
$literalize | boolean | Whether or not values should be literalized. |
Returns array``<``int``|``string``, ``mixed``> — An associative array of parameters
getValidationFile()
Section titled “getValidationFile()”public function getValidationFile(): ?string
Retrieves the stored validation filename.
Returns ?``string — An absolute filesystem path to a validation filename.
initialize()
Section titled “initialize()”public function initialize(?string $validationFile = null, ?string $parser = null, array<string, mixed> $parameters = []): void
Initialize this ConfigHandler.
An associative array of initialization parameters.
| Parameter | Type | Description |
|---|---|---|
$validationFile | ?``string | The path to a validation file for this config handler. |
$parser | ?``string | The parser class to use. |
$parameters | array``<``string``, ``mixed``> | An associative array of initialization parameters. |
| Throws | When |
|---|---|
InitializationException | If an error occurs while initializing the ConfigHandler |
orderConfigurations()
Section titled “orderConfigurations()”public function orderConfigurations(ConfigValueHolder $configurations, ?string $environment = null, ?string $context = null, bool $autoloadParser = true): array<int, ConfigValueHolder>
Returns a properly ordered array of ConfigValueHolder configuration elements for given env and context.
Whether the parser class should be autoloaded or not.
| Parameter | Type | Description |
|---|---|---|
$configurations | ConfigValueHolder | The root config element |
$environment | ?``string | An environment name. |
$context | ?``string | A context name. |
$autoloadParser | bool | Whether the parser class should be autoloaded or not. |
Returns array``<``int``, ConfigValueHolder> — An array of ConfigValueHolder configuration elements.
testPattern()
Section titled “testPattern()”public static function testPattern(string $pattern, string $subject): bool
Builds a proper regular expression from the input pattern to test against the given subject.
The subject string to test the pattern against.
| Parameter | Type | Description |
|---|---|---|
$pattern | string | A regular expression chunk without delimiters/anchors. |
$subject | string | The subject string to test the pattern against. |
Returns bool — Whether or not the subject matched the pattern.
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
execute() | ILegacyConfigHandler | Execute this configuration handler. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
literalize() | BaseConfigHandler | Literalize a string value. |
removeParameter() | ParameterHolder | Remove a parameter. |
replaceConstants() | BaseConfigHandler | Replace configuration directive identifiers in a string. |
replacePath() | BaseConfigHandler | Replace a relative filesystem path with an absolute one. |
reset() | ParameterHolder | Removes every parameter held, leaving the holder empty for reuse. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |