Skip to content

LightweightActionInitContext

The ActionInitContext every dispatch path constructs: the executor, the dispatch, security and validation middleware, the slot dispatcher and the input-schema resolver.

Holds the dispatch identity, request and response as readonly constructor state and adds only what an action needs to write back: the view module and view name, plus the attribute storage inherited from AttributeHolder, which is what a view later reads as the action’s attributes.

The validation manager is resolved lazily from the container and cached, and can be replaced with LightweightActionInitContext::setValidationManager() so an action’s own validate*() methods see the same errors and exports as the XML validators that already ran.

class LightweightActionInitContext extends AttributeHolder implements ActionInitContext

ExtendsAttributeHolder
ImplementsActionInitContext
SourceExecution/LightweightActionInitContext.php

public function __construct(Context $context, string $module, string $action, string $method, string $outputType, ?ServerRequestInterface $requestData, WebResponse $response): mixed

Constructor.

An array of parameters to be set right away.

ParameterTypeDescription
$contextContext
$modulestring
$actionstring
$methodstring
$outputTypestring
$requestData?ServerRequestInterface
$responseWebResponse

Returns mixed

MethodDescription
getActionName(): stringReturns the name of the action being executed.
getContext(): ContextReturns the application Context the action is executing under.
getModuleName(): stringReturns the name of the module the action was dispatched from.
getOutputTypeName(): stringReturns the name of the output type selected for this dispatch.
getRequestData(): ?ServerRequestInterfaceReturns the PSR-7 server request backing this dispatch.
getRequestMethod(): stringReturns the request method token the action was dispatched with.
getResponse(): WebResponseReturns the response the action and its view write into.
getValidationManager(): ?ValidationManagerReturns the validation manager shared by this dispatch, or null when none can be resolved.
getViewModuleName(): ?stringReturns the view module recorded by setViewModuleName(), or null when none was set.
getViewName(): ?stringReturns the view name recorded by setViewName(), or null when none was set.
setValidationManager(?ValidationManager $vm): voidReplace the cached validation manager.
setViewModuleName(?string $module): voidRecords the module hosting the view to render, overriding the action’s own module.
setViewName(?string $name): voidRecords the name of the view to render for this action.

public function getActionName(): string

Returns the name of the action being executed.

Returns string

public function getContext(): Context

Returns the application Context the action is executing under.

Returns Context

public function getModuleName(): string

Returns the name of the module the action was dispatched from.

Returns string

public function getOutputTypeName(): string

Returns the name of the output type selected for this dispatch.

Returns string

public function getRequestData(): ?ServerRequestInterface

Returns the PSR-7 server request backing this dispatch.

Null when the action is executed without a request, as in a slot or test dispatch assembled directly rather than from an incoming HTTP request.

Returns ?ServerRequestInterface

public function getRequestMethod(): string

Returns the request method token the action was dispatched with.

Returns string

public function getResponse(): WebResponse

Returns the response the action and its view write into.

Returns WebResponse

public function getValidationManager(): ?ValidationManager

Returns the validation manager shared by this dispatch, or null when none can be resolved.

The first successful lookup goes through the context’s container and is cached on this instance, so XML validators, the action’s own validate*() methods and error-handling code all observe the same error and export state. A container that cannot supply one — or that throws while trying — yields null rather than propagating, and the lookup is retried on the next call.

Returns ?ValidationManager

public function getViewModuleName(): ?string

Returns the view module recorded by setViewModuleName(), or null when none was set.

Returns ?``string

public function getViewName(): ?string

Returns the view name recorded by setViewName(), or null when none was set.

Returns ?``string

public function setValidationManager(?ValidationManager $vm): void

Replace the cached validation manager.

Called by ValidationService / ActionTestCase to inject the VM that XML validators were executed against, so that the action’s manual validate*() methods see the same errors and exports.

ParameterTypeDescription
$vm?ValidationManager

public function setViewModuleName(?string $module): void

Records the module hosting the view to render, overriding the action’s own module.

Passing null clears the override so the action’s module is used.

ParameterTypeDescription
$module?``string

public function setViewName(?string $name): void

Records the name of the view to render for this action.

Passing null clears the selection, leaving the view to be resolved from the action’s own return value.

ParameterTypeDescription
$name?``string

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendAttribute()AttributeHolderAppend an attribute.
appendAttributeByRef()AttributeHolderAppend an attribute by reference.
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearAttributes()AttributeHolderClear all attributes.
clearParameters()ParameterHolderClear all parameters associated with this request.
getAttribute()AttributeHolderRetrieve an attribute.
getAttributeNames()AttributeHolderRetrieve an array of attribute names.
getAttributeNamespace()AttributeHolderRetrieve all attributes within a namespace.
getAttributeNamespaces()AttributeHolderRetrieve an array of attribute namespaces.
getAttributes()AttributeHolderRetrieve all attributes within a namespace.
getDefaultNamespace()AttributeHolderGet the default namespace name
getFlatAttributeNames()AttributeHolderRetrieve an array of flattened attribute names.
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.
hasAttribute()AttributeHolderIndicates whether or not an attribute exists.
hasAttributeNamespace()AttributeHolderIndicates whether or not an attribute namespace exists.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
removeAttribute()AttributeHolderRemove an attribute.
removeAttributeNamespace()AttributeHolderRemove an attribute namespace and all of its associated attributes.
removeParameter()ParameterHolderRemove a parameter.
reset()ParameterHolderRemoves every parameter held, leaving the holder empty for reuse.
setAttribute()AttributeHolderSet an attribute.
setAttributeByRef()AttributeHolderSet an attribute by reference.
setAttributes()AttributeHolderSet an array of attributes.
setAttributesByRef()AttributeHolderSet an array of attributes by reference.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.