Skip to content

ActionInitContext

What an action is handed by Action::initialize(): the identity of the dispatch it is running under, the request and response it works with, and the slot for the view it wants rendered.

Constructed by whoever is dispatching — the executor, the middleware pipeline, the slot dispatcher — and never resolved from the container, which does not own per-execution state and refuses to autowire this type into a #[Required] method.

Implementors must answer the module, action, request method and output type of the current dispatch, expose the Context and the WebResponse being written into, and remember the view module and view name set on them so the dispatcher can read them back after the action returns. Attribute storage comes from AttributeHolder on the implementations rather than from this interface.

interface ActionInitContext

Implemented byLightweightActionInitContext
SourceExecution/ActionInitContext.php
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 carrying this dispatch’s error state, or null when none is available.
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.
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.

abstract public function getActionName(): string

Returns the name of the action being executed.

Returns string

abstract public function getContext(): Context

Returns the application Context the action is executing under.

Returns Context

abstract public function getModuleName(): string

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

Returns string

abstract public function getOutputTypeName(): string

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

Returns string

abstract 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

abstract public function getRequestMethod(): string

Returns the request method token the action was dispatched with.

Returns string

abstract public function getResponse(): WebResponse

Returns the response the action and its view write into.

Returns WebResponse

abstract public function getValidationManager(): ?ValidationManager

Returns the validation manager carrying this dispatch’s error state, or null when none is available.

Returns ?ValidationManager

abstract public function getViewModuleName(): ?string

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

Returns ?``string

abstract public function getViewName(): ?string

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

Returns ?``string

abstract 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

abstract 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