Skip to content

Internals Runtime Api RuntimeControllerAPI

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

runtime\api\RuntimeControllerAPI

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/runtime/api/RuntimeControllerAPI.php · Snapshot 8411f4287706.

Runtime state, package API classes, loader, executor and orchestrator have separate responsibilities. Dependency validation precedes package code and nested execution restores context.

Imports and dependencies

use context\Context;
use controller\Controller;
use object\ObjectFactory;
use runtime\enums\ERuntimeFlags;
use runtime\interface\api\IRuntimeControllerCapabilities;

RuntimeControllerAPI

Declaration and architectural role

abstract class RuntimeControllerAPI extends RuntimeAPI implements IRuntimeControllerCapabilities

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
$controllers public array $controllers = []; Used by addController(), getController().

Method index

Method Signature
environmentSetup public function environmentSetup(): void
addController protected function addController(ObjectFactory|Controller $controller, string $name = ''): void
getController public function getController(string $name): ObjectFactory|Controller

environmentSetup

Source line 11

public function environmentSetup(): void

Delegates to setRuntimeFlag().

Implementation, validation guards and interaction order
public function environmentSetup(): void
    {
        parent::environmentSetup();
        $this->setRuntimeFlag(ERuntimeFlags::Controller);
        $this->setRuntimeFlag(ERuntimeFlags::CreatePassable);
    }

addController

Source line 17

protected function addController(ObjectFactory|Controller $controller, string $name = ''): void

Parameters

Parameter Type, modifiers and default Purpose
$controller ObjectFactory|Controller $controller Controller instance or lazy ObjectFactory depending on the union type.
$name string $name = '' Named key/label selected by this API; its exact scope is shown by the implementation trace.

State writes: $this->controllers[$controller instanceof Controller ? $controller->controllerName : $name].

Explicit exceptions: \InvalidArgumentException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
protected function addController(ObjectFactory|Controller $controller, string $name = ''): void
    {
        if ($controller instanceof ObjectFactory && $controller->type === null) {
            throw new \InvalidArgumentException('Controller factories must declare their expected type.');
        }
        $this->controllers[$controller instanceof Controller ? $controller->controllerName : $name] = $controller;
    }

getController

Source line 24

public function getController(string $name): ObjectFactory|Controller

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Return expressions (including local callbacks): $controller.

Explicit exceptions: \OutOfBoundsException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function getController(string $name): ObjectFactory|Controller
    {
        $controller = $this->controllers[$name] ?? throw new \OutOfBoundsException("Unknown controller: {$name}");
        $context = new Context($this->rootPath, $this->name, (string) $this->id);
        if ($controller instanceof ObjectFactory) {
            $controller->addProperty('packageName', $this->name);
            $controller->addMethodCall('setContext')->addMethodArgs('setContext', [$context]);
        } else {
            $controller->packageName = $this->name;
            $controller->setContext($context);
        }
        return $controller;
    }

Related types

Clone this wiki locally