Skip to content

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.

abstract class ConfigHandler extends BaseConfigHandler implements ILegacyConfigHandler

ExtendsBaseConfigHandler
ImplementsILegacyConfigHandler
Since1.0.0
SourceConfig/ConfigHandler.php
PropertyTypeDescription
$parsermixedprotected.
$validationFilemixedprotected.
MethodDescription
[`getItemParameters(ConfigValueHolder $itemNode, array<intstring, mixed> $oldValues = [], boolean $literalize = true): array<int
getValidationFile(): ?stringRetrieves the stored validation filename.
initialize(?string $validationFile = null, ?string $parser = null, array<string, mixed> $parameters = []): voidInitialize 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): boolBuilds a proper regular expression from the input pattern to test against the given subject.

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.

ParameterTypeDescription
$itemNodeConfigValueHolderThe node that contains a parameters child.
$oldValues`array<int“string, mixed>`
$literalizebooleanWhether or not values should be literalized.

Returns array``<``int``|``string``, ``mixed``> — An associative array of parameters

public function getValidationFile(): ?string

Retrieves the stored validation filename.

Returns ?``string — An absolute filesystem path to a validation filename.

public function initialize(?string $validationFile = null, ?string $parser = null, array<string, mixed> $parameters = []): void

Initialize this ConfigHandler.

An associative array of initialization parameters.

ParameterTypeDescription
$validationFile?``stringThe path to a validation file for this config handler.
$parser?``stringThe parser class to use.
$parametersarray``<``string``, ``mixed``>An associative array of initialization parameters.
ThrowsWhen
InitializationExceptionIf an error occurs while initializing the ConfigHandler

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.

ParameterTypeDescription
$configurationsConfigValueHolderThe root config element
$environment?``stringAn environment name.
$context?``stringA context name.
$autoloadParserboolWhether the parser class should be autoloaded or not.

Returns array``<``int``, ConfigValueHolder> — An array of ConfigValueHolder configuration elements.

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.

ParameterTypeDescription
$patternstringA regular expression chunk without delimiters/anchors.
$subjectstringThe subject string to test the pattern against.

Returns bool — Whether or not the subject matched the pattern.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
execute()ILegacyConfigHandlerExecute this configuration handler.
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
literalize()BaseConfigHandlerLiteralize a string value.
removeParameter()ParameterHolderRemove a parameter.
replaceConstants()BaseConfigHandlerReplace configuration directive identifiers in a string.
replacePath()BaseConfigHandlerReplace a relative filesystem path with an absolute one.
reset()ParameterHolderRemoves every parameter held, leaving the holder empty for reuse.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.