Repository navigation
Internals Router Execution RouteExecutor
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/router/execution/RouteExecutor.php · Snapshot 8411f4287706.
Routing separates definition, HTTP request snapshot, matching, method policy, execution and error responses. Collaborators can be replaced through constructor injection.
use context\events\RespondContextEvent;
use object\ObjectFactory;
use redirect\Redirect;
use response\Response;
use router\events\RouteEnterEvent;
use router\http\HttpMethod;
use router\interface\IRequest;
use router\interface\ICsrfValidator;
use router\interface\IRouteExecutor;
use router\interface\IRoute;
use router\security\SessionCsrfValidator;
use view\View;final class RouteExecutor implements IRouteExecutorSource description (behavioral corrections are recorded in Known discrepancies):
Executes the route pipeline in security, middleware, event, action order.
Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| Constructor-promoted | private readonly ICsrfValidator $csrfValidator = new SessionCsrfValidator() |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private readonly \router\interface\IMethodPolicy $methods = new HttpMethod() |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private readonly \router\interface\IRouteResponseFactory $responses = new \router\response\RouteResponseFactory() |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct( private readonly ICsrfValidator $csrfValidator = new SessionCsrfValidator(), private readonly \router\interface\IMethodPolicy $methods = new HttpMethod(), private readonly \router\interface\IRouteResponseFactory $responses = new \router\response\RouteResponseFactory(), ) |
| execute | public function execute(IRoute $route, IRequest $request, array $params = []): View|Redirect|Response |
public function __construct(
private readonly ICsrfValidator $csrfValidator = new SessionCsrfValidator(),
private readonly \router\interface\IMethodPolicy $methods = new HttpMethod(),
private readonly \router\interface\IRouteResponseFactory $responses = new \router\response\RouteResponseFactory(),
);| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$csrfValidator |
private readonly ICsrfValidator $csrfValidator = new SessionCsrfValidator() |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$methods |
private readonly \router\interface\IMethodPolicy $methods = new HttpMethod() |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$responses |
private readonly \router\interface\IRouteResponseFactory $responses = new \router\response\RouteResponseFactory() |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
public function execute(IRoute $route, IRequest $request, array $params = []): View|Redirect|Response| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$route |
IRoute $route |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$request |
IRequest $request |
Request snapshot consumed by matching, method and security checks. |
$params |
array $params = [] |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Return expressions (including local callbacks): $this->responses->methodNotAllowed($this->methods->allowed($route->getMethod())); $this->responses->csrfRejected(); $controller->{$route->getAction()}($params).
Implementation, validation guards and interaction order
public function execute(IRoute $route, IRequest $request, array $params = []): View|Redirect|Response
{
if (!$this->methods->allows($route->getMethod(), $request->method())) {
return $this->responses->methodNotAllowed($this->methods->allowed($route->getMethod()));
}
if ($route->requiresCsrf() && !$this->methods->isSafe($request->method())
&& !$this->csrfValidator->validate($request)) {
return $this->responses->csrfRejected();
}
$route->getMiddleware()?->handle();
$controller = $route->getController();
if ($controller instanceof ObjectFactory) {
$controller = $controller->create();
$route->setController($controller);
}
$context = $controller->getContext();
if ($context !== null) {
$route->getEventDispatcher()->addListener('context.get', new RespondContextEvent($context));
}
$route->getEventDispatcher()->dispatch(new RouteEnterEvent($route->getPath(), $route->getAction(), $controller));
$controller->viewName = $route->getAction();
return $controller->{$route->getAction()}($params);
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes