Skip to content
docsv0.17.1

GraphRegistry

The graphs an app declares — the list a reader can see in a diff. Registration is by CLASS, and compilation is lazy: a graph is compiled the first time somebody asks for it, so a malformed declaration fails when it is used and names itself, instead of taking the whole app down at boot for a graph nobody ran. The compiled result is kept, because compiling is reflection and a process may be advanced many times.

GraphRegistry::__construct()

public function __construct(?Closure $resolve = null):

Parameters

Parameters of __construct()
NameTypeDescription
$resolve(\Closure | null)`fn (string $type): object` — how every node's collaborators are found

GraphRegistry::register()

public function register(string $class): self

Declares a graph class. The name is the one its own `#[Graph]` carries.

Parameters

Parameters of register()
NameTypeDescription
$classclass-string

Throws

GraphDeclarationException when the class is not a declared graph, or the name is taken

GraphRegistry::names()

public function names(): array

The names of every graph this app declared.

GraphRegistry::has()

public function has(string $name): bool

Is a graph declared under this name?

Parameters

Parameters of has()
NameTypeDescription
$namestring

GraphRegistry::get()

public function get(string $name): Milpa\Orchestrator\Declaration\CompiledGraph

The compiled graph carrying this name, compiled on first use and kept afterwards.

Parameters

Parameters of get()
NameTypeDescription
$namestring

Throws

CallRefused when no graph carries that name

GraphDeclarationException when the graph that does cannot be compiled