Skip to content

ReturnArrayConfigHandler

ReturnArrayConfigHandler allows you to retrieve the contents of a config file as an array.

Assumes that the content elements are in no XML namespace; if you want to use an XML namespace for your elements, define the namespace URI using the “namespace_uri” parameter.

Migrated to IArrayConfigHandler (phase 2). This handler’s whole purpose is “turn a config file into a * plain array” — for XML that means the recursive convertToArray() walk below; for a PHP/YAML source the canonical array is the source (there is nothing left to convert), so toCanonicalArray() and executeArray() are a near-trivial split here.

Deliberately does not implement ISchemaAwareConfigHandler: its whole point is arbitrary, app-defined XML-to-array conversion driven by caller-supplied parameters (id_attribute/value_key/force_array_values/ attribute_prefix), so there is no fixed canonical shape to describe — same reasoning as SettingConfigHandler’s open, dynamically-keyed shape.

class ReturnArrayConfigHandler extends XmlConfigHandler implements IArrayConfigHandler

ExtendsXmlConfigHandler
ImplementsIArrayConfigHandler
Since1.0.0
SourceConfig/ReturnArrayConfigHandler.php
MethodDescription
execute(XmlConfigDomDocument $document): mixedExecute this configuration handler.
executeArray(array $config, ?string $sourceRef = null): mixedReturns the canonical array unchanged as the declaration to cache.
toCanonicalArray(XmlConfigDomDocument $document): arrayConverts the document’s configuration elements into a plain array.

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 array unchanged as the declaration to cache.

This handler’s purpose is to surface a config file as a plain array, so once the array exists there is nothing further to compile.

ParameterTypeDescription
$configarray
$sourceRef?``string

Returns mixed

public function toCanonicalArray(XmlConfigDomDocument $document): array

Converts the document’s configuration elements into a plain array.

Elements are read from the namespace named by the namespace_uri parameter, which defaults to none. Each top-level configuration block is converted recursively and merged into one array, so a later block’s keys win over an earlier one’s. The conversion itself is driven by the handler’s id_attribute, value_key, force_array_values, attribute_prefix and literalize parameters.

ParameterTypeDescription
$documentXmlConfigDomDocument

Returns array

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.