Skip to content

DatabaseConfigHandler

DatabaseConfigHandler allows you to setup database connections in a configuration file that will be created for you automatically upon first request.

Migrated to IArrayConfigHandler (phase 2). Canonical schema: [‘default’ => ‘connection_name’|null, ‘databases’ => [‘connection_name’ => [‘class’ => ‘Some\Class’, ‘parameters’ => […]]]] The “a default must be declared by the time a block is * seen” check is inherently about the order configuration blocks are processed in, not just the final data shape, so it still runs during toCanonicalArray()‘s walk (throwing ParseException exactly as before); the “no databases at all” / “undefined default” checks only depend on the final canonical array and have moved to executeArray().

class DatabaseConfigHandler extends XmlConfigHandler implements IArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler

ExtendsXmlConfigHandler
ImplementsIArrayConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler
Since1.0.0
SourceConfig/DatabaseConfigHandler.php
ConstantValueDescription
XML_NAMESPACE'http://quiote.dev/quiote/config/parts/databases/1.1'
MethodDescription
execute(XmlConfigDomDocument $document): mixedExecute this configuration handler.
[`executeArray(array{default?: (stringnull), databases?: array<string, array{class: string, parameters: array<(int
schema(): Rule“default must exist as a key in databases” and “databases must be * non-empty” stay in executeArray() — cross-field/non-empty checks, not structural shape.
[`toCanonicalArray(XmlConfigDomDocument $document): array{default: (stringnull), databases: array<string, array{class: string, parameters: array<(int
[`toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: array{default: (stringnull), databases: array<string, array{class: string, parameters: array<(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{default?: (string | null), databases?: array<string, array{class: string, parameters: array<(int | string), 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{default?: (stringnull), databases?: array<string, array{class: string, parameters: array<(int
$sourceRef`string““null`

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

public function schema(): Rule

“default must exist as a key in databases” and “databases must be * non-empty” stay in executeArray() — cross-field/non-empty checks, not structural shape.

Returns Rule

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

ParameterTypeDescription
$documentXmlConfigDomDocument

Returns array{default: (string | null), databases: array<string, array{class: string, parameters: array<(int | string), mixed>}>}

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

ParameterTypeDescription
$documentXmlConfigDomDocument
$positionsElementPositionIndex

Returns array{data: array{default: (string | null), databases: array<string, array{class: string, parameters: array<(int | string), 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.