Skip to content

FactoryConfigHandler

FactoryConfigHandler allows you to specify which factory implementation the system will use.

The factory ordering/startup-sequence/must_implement logic in getFactoryDefinitions() is pure PHP with no XML-specific content at all, so it lives in code rather than in the configuration. The canonical array is exactly the per-factory class/params pairs declared in the source (XML, PHP, or YAML): [ ‘validation_manager’ => [‘class’ => ‘Some\Class’, ‘params’ => […]], ‘response’ => [‘class’ => ’…’, ‘params’ => […]], // one entry per child element the XML configuration // (or, for a PHP/YAML file, top-level key) actually declares. ] Every factory getFactoryDefinitions() names is read, so the canonical array is a faithful reading of the source and does not depend on any runtime setting; whether a declared factory is then built is decided in executeArray(). A PHP-array/YAML factories file is simply this same map written directly, e.g. return ['database_manager' => ['class' => ..., 'params' => [...]], ...];.

class FactoryConfigHandler extends XmlConfigHandler implements IArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler

ExtendsXmlConfigHandler
ImplementsIArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler
Since1.0.0
SourceConfig/FactoryConfigHandler.php
ConstantValueDescription
XML_NAMESPACE'http://quiote.dev/quiote/config/parts/factories/1.1'
MethodDescription
execute(XmlConfigDomDocument $document): mixedExecute this configuration handler.
[`executeArray(array<string, array{class: (stringnull), params: array}> $config, string
schema(): RuleNo required list: which factories must be present depends on runtime settings (translation_manager on core.use_translation), so that is a semantic check in executeArray() rather than a static array shape.
[`toCanonicalArray(XmlConfigDomDocument $document): array<string, array{class: (stringnull), params: array}>`](#tocanonicalarray)
[`toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: array<string, array{class: (stringnull), params: array}>, positions: array<string, array{file: string, line: int}>}`](#tocanonicalarraywithpositions)

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<string, array{class: (string | null), params: array<mixed>}> $config, string|null $sourceRef = null): mixed

Origin reference for the compiled cache file’s header comment (a file path for any format; XML’s is $document->documentURI).

ParameterTypeDescription
$config`array<string, array{class: (stringnull), params: array}“>`
$sourceRef`string““null`

Returns mixed — The declaration to be cached, exactly as IXmlConfigHandler::execute() returns.

public function schema(): Rule

No required list: which factories must be present depends on runtime settings (translation_manager on core.use_translation), so that is a semantic check in executeArray() rather than a static array shape.

Returns Rule

public function toCanonicalArray(XmlConfigDomDocument $document): array<string, array{class: (string | null), params: array<mixed>}>

ParameterTypeDescription
$documentXmlConfigDomDocument

Returns array``<``string``, ``array{class: (string | null), params: array<mixed>}``>

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

ParameterTypeDescription
$documentXmlConfigDomDocument
$positionsElementPositionIndex

Returns array{data: array<string, array{class: (string | null), params: array<mixed>}>, 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.