Skip to content

Internals Router Factory RouteFactory

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

router\factory\RouteFactory

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/router/factory/RouteFactory.php · Snapshot 8411f4287706.

Routing separates definition, HTTP request snapshot, matching, method policy, execution and error responses. Collaborators can be replaced through constructor injection.

Imports and dependencies

use controller\Controller;
use object\ObjectFactory;
use router\execution\RouteExecutor;
use router\http\GlobalsRequestProvider;
use router\http\HttpMethod;
use router\interface\IMethodPolicy;
use router\interface\IPathMatcher;
use router\interface\IRequestProvider;
use router\interface\IRoute;
use router\interface\IRouteExecutor;
use router\interface\IRouteFactory;
use router\matching\SegmentPathMatcher;
use router\Router;

RouteFactory

Declaration and architectural role

final class RouteFactory implements IRouteFactory

Constants, enum cases, traits and properties

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
$executor private readonly IRouteExecutor $executor; Used by __construct(), make().
Constructor-promoted private readonly IPathMatcher $pathMatcher = new SegmentPathMatcher() Initialized from the constructor argument; default expression is evaluated when the argument is omitted.
Constructor-promoted private readonly IRequestProvider $requests = new GlobalsRequestProvider() Initialized from the constructor argument; default expression is evaluated when the argument is omitted.
Constructor-promoted private readonly IMethodPolicy $methods = new HttpMethod() Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct( private readonly IPathMatcher $pathMatcher = new SegmentPathMatcher(), ?IRouteExecutor $executor = null, private readonly IRequestProvider $requests = new GlobalsRequestProvider(), private readonly IMethodPolicy $methods = new HttpMethod(), )
make public function make(string $path, string $action, ObjectFactory|Controller $controller, bool $service = false): IRoute

__construct

Source line 23

public function __construct(
        private readonly IPathMatcher $pathMatcher = new SegmentPathMatcher(),
        ?IRouteExecutor $executor = null,
        private readonly IRequestProvider $requests = new GlobalsRequestProvider(),
        private readonly IMethodPolicy $methods = new HttpMethod(),
    )

Parameters

Parameter Type, modifiers and default Purpose
$pathMatcher private readonly IPathMatcher $pathMatcher = new SegmentPathMatcher() Operation input; the exact use, validation and propagation are shown in the implementation trace.
$executor ?IRouteExecutor $executor = null Operation input; the exact use, validation and propagation are shown in the implementation trace.
$requests private readonly IRequestProvider $requests = new GlobalsRequestProvider() Operation input; the exact use, validation and propagation are shown in the implementation trace.
$methods private readonly IMethodPolicy $methods = new HttpMethod() Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->executor.

Implementation, validation guards and interaction order
public function __construct(
        private readonly IPathMatcher $pathMatcher = new SegmentPathMatcher(),
        ?IRouteExecutor $executor = null,
        private readonly IRequestProvider $requests = new GlobalsRequestProvider(),
        private readonly IMethodPolicy $methods = new HttpMethod(),
    ) {
        $this->executor = $executor ?? new RouteExecutor(methods: $this->methods);
    }

make

Source line 32

public function make(string $path, string $action, ObjectFactory|Controller $controller, bool $service = false): IRoute

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.
$action string $action Operation input; the exact use, validation and propagation are shown in the implementation trace.
$controller ObjectFactory|Controller $controller Controller instance or lazy ObjectFactory depending on the union type.
$service bool $service = false Operation input; the exact use, validation and propagation are shown in the implementation trace.

Return expressions (including local callbacks): new Router($path, $action, $controller, $service, $this->pathMatcher, $this->executor, $this->requests, $this->methods).

Implementation, validation guards and interaction order
public function make(string $path, string $action, ObjectFactory|Controller $controller, bool $service = false): IRoute
    {
        return new Router($path, $action, $controller, $service,
            $this->pathMatcher, $this->executor, $this->requests, $this->methods);
    }

Related types

Clone this wiki locally