Skip to content

MiddlewareConfigHandler

MiddlewareConfigHandler reads a middleware.{xml,php,yaml,yml} file — a flat list of <use> entries that register app/plugin middleware and/or override the placement or enabled state of any middleware (framework or app) known to #[Quiote\Middleware\Attribute\Middleware] scanning.

The compiled artifact returns the entry list; MiddlewareConfigHandler::apply() records it as a contribution on MiddlewareConfigRegistry, which MiddlewarePipeline::doBuild() merges with attribute-scanned definitions before ordering the pipeline. Fields left unset in an entry (represented as null in the canonical array) don’t override anything — they fall back to the class’s own #[Middleware] attribute, or framework defaults for a class with none.

Canonical schema: list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>, in document order.

class MiddlewareConfigHandler extends XmlConfigHandler implements IArrayConfigHandler, IDeclarationConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler

ExtendsXmlConfigHandler
ImplementsIArrayConfigHandler, IDeclarationConfigHandler, IPositionAwareConfigHandler, ISchemaAwareConfigHandler
Since1.0.0
SourceConfig/MiddlewareConfigHandler.php
ConstantValueDescription
XML_NAMESPACE'http://quiote.dev/quiote/config/parts/middleware/1.1'
MethodDescription
apply(mixed $declaration, string $sourceRef): voidRecord the declared entries as contributions on the registry the pipeline builder reads.
execute(XmlConfigDomDocument $document): mixedExecute this configuration handler.
executeArray(list<array{class: string, phase?: ?string, priority?: ?int, before?: ?string, after?: ?string, enabled?: ?bool, override_framework?: bool}> $config, ?string $sourceRef = null): mixed
schema(): Rule“phase” values per middleware.xsd’s enum.
toCanonicalArray(XmlConfigDomDocument $document): list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>
toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>, positions: array<string, array{file: string, line: int}>}

public function apply(mixed $declaration, string $sourceRef): void

Record the declared entries as contributions on the registry the pipeline builder reads.

The normalized entry list MiddlewareConfigHandler::executeArray() compiles.

ParameterTypeDescription
$declarationmixedThe normalized entry list MiddlewareConfigHandler::executeArray() compiles.
$sourceRefstring

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(list<array{class: string, phase?: ?string, priority?: ?int, before?: ?string, after?: ?string, enabled?: ?bool, override_framework?: bool}> $config, ?string $sourceRef = null): mixed

Hand-authored PHP/YAML sources may omit any field but class; omitted fields normalize to “don’t override” (null), matching the XSD’s own optional attributes.

ParameterTypeDescription
$configlist``<``array{class: string, phase?: ?string, priority?: ?int, before?: ?string, after?: ?string, enabled?: ?bool, override_framework?: bool}``>Hand-authored PHP/YAML sources may omit any field but class; omitted fields normalize to “don’t override” (null), matching the XSD’s own optional attributes.
$sourceRef?``string

Returns mixed

public function schema(): Rule

“phase” values per middleware.xsd’s enum.

Only “class” is required — everything else means “don’t override” when omitted, matching the XSD’s own optional attributes.

Returns Rule

public function toCanonicalArray(XmlConfigDomDocument $document): list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>

ParameterTypeDescription
$documentXmlConfigDomDocument

Returns list``<``array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}``>

public function toCanonicalArrayWithPositions(XmlConfigDomDocument $document, ElementPositionIndex $positions): array{data: list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>, positions: array<string, array{file: string, line: int}>}

ParameterTypeDescription
$documentXmlConfigDomDocument
$positionsElementPositionIndex

Returns array{data: list<array{class: string, phase: ?string, priority: ?int, before: ?string, after: ?string, enabled: ?bool, override_framework: bool}>, 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.