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.
Synopsis
Section titled “Synopsis”class LightweightActionInitContext extends AttributeHolder implements ActionInitContext
| Extends | AttributeHolder |
| Implements | ActionInitContext |
| Source | Execution/LightweightActionInitContext.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”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.
| Parameter | Type | Description |
|---|---|---|
$context | Context | |
$module | string | |
$action | string | |
$method | string | |
$outputType | string | |
$requestData | ?ServerRequestInterface | |
$response | WebResponse |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
getActionName(): string | Returns the name of the action being executed. |
getContext(): Context | Returns the application Context the action is executing under. |
getModuleName(): string | Returns the name of the module the action was dispatched from. |
getOutputTypeName(): string | Returns the name of the output type selected for this dispatch. |
getRequestData(): ?ServerRequestInterface | Returns the PSR-7 server request backing this dispatch. |
getRequestMethod(): string | Returns the request method token the action was dispatched with. |
getResponse(): WebResponse | Returns the response the action and its view write into. |
getValidationManager(): ?ValidationManager | Returns the validation manager shared by this dispatch, or null when none can be resolved. |
getViewModuleName(): ?string | Returns the view module recorded by setViewModuleName(), or null when none was set. |
getViewName(): ?string | Returns the view name recorded by setViewName(), or null when none was set. |
setValidationManager(?ValidationManager $vm): void | Replace the cached validation manager. |
setViewModuleName(?string $module): void | Records the module hosting the view to render, overriding the action’s own module. |
setViewName(?string $name): void | Records the name of the view to render for this action. |
getActionName()
Section titled “getActionName()”public function getActionName(): string
Returns the name of the action being executed.
Returns string
getContext()
Section titled “getContext()”public function getContext(): Context
Returns the application Context the action is executing under.
Returns Context
getModuleName()
Section titled “getModuleName()”public function getModuleName(): string
Returns the name of the module the action was dispatched from.
Returns string
getOutputTypeName()
Section titled “getOutputTypeName()”public function getOutputTypeName(): string
Returns the name of the output type selected for this dispatch.
Returns string
getRequestData()
Section titled “getRequestData()”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
getRequestMethod()
Section titled “getRequestMethod()”public function getRequestMethod(): string
Returns the request method token the action was dispatched with.
Returns string
getResponse()
Section titled “getResponse()”public function getResponse(): WebResponse
Returns the response the action and its view write into.
Returns WebResponse
getValidationManager()
Section titled “getValidationManager()”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
getViewModuleName()
Section titled “getViewModuleName()”public function getViewModuleName(): ?string
Returns the view module recorded by setViewModuleName(), or null when none was set.
Returns ?``string
getViewName()
Section titled “getViewName()”public function getViewName(): ?string
Returns the view name recorded by setViewName(), or null when none was set.
Returns ?``string
setValidationManager()
Section titled “setValidationManager()”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.
| Parameter | Type | Description |
|---|---|---|
$vm | ?ValidationManager |
setViewModuleName()
Section titled “setViewModuleName()”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.
| Parameter | Type | Description |
|---|---|---|
$module | ?``string |
setViewName()
Section titled “setViewName()”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.
| Parameter | Type | Description |
|---|---|---|
$name | ?``string |
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
appendAttribute() | AttributeHolder | Append an attribute. |
appendAttributeByRef() | AttributeHolder | Append an attribute by reference. |
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearAttributes() | AttributeHolder | Clear all attributes. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
getAttribute() | AttributeHolder | Retrieve an attribute. |
getAttributeNames() | AttributeHolder | Retrieve an array of attribute names. |
getAttributeNamespace() | AttributeHolder | Retrieve all attributes within a namespace. |
getAttributeNamespaces() | AttributeHolder | Retrieve an array of attribute namespaces. |
getAttributes() | AttributeHolder | Retrieve all attributes within a namespace. |
getDefaultNamespace() | AttributeHolder | Get the default namespace name |
getFlatAttributeNames() | AttributeHolder | Retrieve an array of flattened attribute names. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
hasAttribute() | AttributeHolder | Indicates whether or not an attribute exists. |
hasAttributeNamespace() | AttributeHolder | Indicates whether or not an attribute namespace exists. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
removeAttribute() | AttributeHolder | Remove an attribute. |
removeAttributeNamespace() | AttributeHolder | Remove an attribute namespace and all of its associated attributes. |
removeParameter() | ParameterHolder | Remove a parameter. |
reset() | ParameterHolder | Removes every parameter held, leaving the holder empty for reuse. |
setAttribute() | AttributeHolder | Set an attribute. |
setAttributeByRef() | AttributeHolder | Set an attribute by reference. |
setAttributes() | AttributeHolder | Set an array of attributes. |
setAttributesByRef() | AttributeHolder | Set an array of attributes by reference. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |