Skip to content

Internals Router Facade Router

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

router\facade\Router

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/router/facade/Router.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\factory\RouteFactory;
use router\interface\IRoute;
use router\interface\IRouteFactory;

Router

Declaration and architectural role

final class Router

Source description (behavioral corrections are recorded in Known discrepancies):

Static entry point; creation is delegated to a replaceable instance factory.

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
$factory private static ?IRouteFactory $factory = null; Used by setFactory(), make().

Method index

Method Signature
__construct private function __construct()
setFactory public static function setFactory(?IRouteFactory $factory): void
make public static function make(string $path, string $action, ObjectFactory|Controller $controller, bool $service = false): IRoute

__construct

Source line 15

private function __construct();

Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.

setFactory

Source line 17

public static function setFactory(?IRouteFactory $factory): void

Parameters

Parameter Type, modifiers and default Purpose
$factory ?IRouteFactory $factory Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: self::$factory.

Implementation, validation guards and interaction order
public static function setFactory(?IRouteFactory $factory): void
    {
        self::$factory = $factory;
    }

make

Source line 22

public static 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.

State writes: self::$factory.

Return expressions (including local callbacks): (self::$factory ??= new RouteFactory())->make($path, $action, $controller, $service).

Implementation, validation guards and interaction order
public static function make(string $path, string $action, ObjectFactory|Controller $controller, bool $service = false): IRoute
    {
        return (self::$factory ??= new RouteFactory())->make($path, $action, $controller, $service);
    }

Related types

Clone this wiki locally