Skip to content

CompileConfigHandler

CompileConfigHandler gathers multiple files and puts them into a single file.

Upon creation of the new file, all comments and blank lines are removed.

Migrated to IArrayConfigHandler (phase 2). Canonical schema: [‘resolved_file_path’ => ‘code_to_embed’], exactly the map execute() used to build inline and hand straight to generate() (which concatenates the values). Gathering/reading/ formatting the referenced files still happens in toCanonicalArray() — unlike other handlers’ extraction step, this one is inherently about resolving and reading files the config points at, not just walking the DOM, so there’s little left for executeArray() to do but hand the already-built map to generate().

class CompileConfigHandler extends XmlConfigHandler implements IArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler

ExtendsXmlConfigHandler
ImplementsIArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler
Since1.0.0
SourceConfig/CompileConfigHandler.php
ConstantValueDescription
XML_NAMESPACE'http://quiote.dev/quiote/config/parts/compile/1.1'
MethodDescription
execute(XmlConfigDomDocument $document): mixedExecute this configuration handler.
executeArray(array $config, ?string $sourceRef = null): mixedReturns the canonical map unchanged as the declaration to cache.
schema(): RuleKeyed by resolved file path (dynamic, not a fixed key set) — an open map like SettingConfigHandler’s, but the value type (embedded code string) is fixed.
toCanonicalArray(XmlConfigDomDocument $document): arrayResolves every file the document’s compiles elements name and returns the map of resolved path to the code to embed for it.
toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: array<string, string>, positions: array<string, array{file: string, line: int}>}

public function execute(XmlConfigDomDocument $document): mixed

Execute this configuration handler.

The document to parse.

ParameterTypeDescription
$documentXmlConfigDomDocumentThe document to parse.

Returns mixed — The declaration to be cached.

ThrowsWhen
ParseExceptionIf a requested configuration file is improperly formatted.

public function executeArray(array $config, ?string $sourceRef = null): mixed

Returns the canonical map unchanged as the declaration to cache.

All the work for this config type — resolving, reading and formatting the referenced files — already happened in CompileConfigHandler::toCanonicalArray(), so there is nothing left to compile here.

ParameterTypeDescription
$configarray
$sourceRef?``string

Returns mixed

public function schema(): Rule

Keyed by resolved file path (dynamic, not a fixed key set) — an open map like SettingConfigHandler’s, but the value type (embedded code string) is fixed.

Returns Rule

public function toCanonicalArray(XmlConfigDomDocument $document): array

Resolves every file the document’s compiles elements name and returns the map of resolved path to the code to embed for it.

Each entry’s path is directive-expanded and resolved against the filesystem. In debug mode the embedded code is a require() of the file, so stack traces still point at the original; otherwise the file’s contents are read and stripped of comments, PHP tags and redundant whitespace by CompileConfigHandler::formatFile().

ParameterTypeDescription
$documentXmlConfigDomDocument

Returns array

ThrowsWhen
ParseExceptionif a named file does not exist, is unreadable, or cannot be read.

public function toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: array<string, string>, positions: array<string, array{file: string, line: int}>}

ParameterTypeDescription
$documentXmlConfigDomDocument
$positionsElementPositionIndex

Returns array{data: array<string, string>, positions: array<string, array{file: string, line: int}>}

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.
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.
initialize()XmlConfigHandlerInitialize this ConfigHandler.
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.