Skip to content

ActionExecutor

ActionExecutor: container-less execution of an action+view producing ActionExecutionContext.

Current scope (incremental): - Security + validation (optional) via services when enabled. - Simple actions: execute() method. - Non-simple actions: use ActionResolver for method dispatch. - View resolution via ViewNameResolver (pure). - View initialization via legacy container (temporary) if needed until ViewFactory extracted. Future work will remove any dependency on containers entirely.

final class ActionExecutor

SourceExecution/ActionExecutor.php

public function __construct(Controller $controller, ?ActionResolver $actionResolver = null, ?ValidationService $validationService = null, ?SecurityService $securityService = null, ?ViewFactory $viewFactory = null, ?ViewNameResolver $viewNameResolver = null): mixed

ParameterTypeDescription
$controllerController
$actionResolver?ActionResolver
$validationService?ValidationService
$securityService?SecurityService
$viewFactory?ViewFactory
$viewNameResolver?ViewNameResolver

Returns mixed

MethodDescription
buildRequestDataFromPsr(ServerRequestInterface $psr, ?Context $context = null): WebRequestBuild an WebRequest (preferred) from a PSR-7 ServerRequest.
execute(ActionDescriptor $desc, ServerRequestInterface $request, ExecutionState $state, array<string, mixed> $parameters = [], ?Action $preInstantiatedAction = null): ActionExecutionContextExecute an action given its descriptor and request data, mutating ExecutionState accordingly.

public static function buildRequestDataFromPsr(ServerRequestInterface $psr, ?Context $context = null): WebRequest

Build an WebRequest (preferred) from a PSR-7 ServerRequest.

The Context actually handling this request (e.g. $this->controller->getContext() from a middleware that has a Controller). Its existing canonical WebRequest is reused when present (avoids rebuilding one already created earlier in the same request’s pipeline). Previously this always reused Context::getInstance('web')’s request regardless of which context was actually dispatching — harmless for single-context apps, but for any app using more than one named Context, every dispatch after “web” had handled its first request would silently reuse “web“‘s stale WebRequest (wrong parameter whitelist, wrong prior values) instead of the current request’s own. Omitting $context always builds a fresh WebRequest from $psr — correct, if slightly less optimized, rather than guessing a context that might be wrong.

ParameterTypeDescription
$psrServerRequestInterface
$context?ContextThe Context actually handling this request (e.g. $this->controller->getContext() from a middleware that has a Controller). Its existing canonical WebRequest is reused when present (avoids rebuilding one already created earlier in the same request’s pipeline). Previously this always reused Context::getInstance('web')’s request regardless of which context was actually dispatching — harmless for single-context apps, but for any app using more than one named Context, every dispatch after “web” had handled its first request would silently reuse “web“‘s stale WebRequest (wrong parameter whitelist, wrong prior values) instead of the current request’s own. Omitting $context always builds a fresh WebRequest from $psr — correct, if slightly less optimized, rather than guessing a context that might be wrong.

Returns WebRequest

public function execute(ActionDescriptor $desc, ServerRequestInterface $request, ExecutionState $state, array<string, mixed> $parameters = [], ?Action $preInstantiatedAction = null): ActionExecutionContext

Execute an action given its descriptor and request data, mutating ExecutionState accordingly.

ParameterTypeDescription
$descActionDescriptor
$requestServerRequestInterface
$stateExecutionState
$parametersarray``<``string``, ``mixed``>
$preInstantiatedAction?Action

Returns ActionExecutionContext