Skip to content
docsv0.1.0

ComponentRegistryInterface

A name-keyed lookup of {@see ComponentDefinitionInterface} instances. Every render path (HTML compiler, TUI component node, HTTP live endpoint) resolves components exclusively through here — by contract name, never by class reference — so a component's implementation can be swapped without touching call sites.

ComponentRegistryInterface::has()

abstract public function has(string $name): bool

Whether a component is registered under this name.

Parameters

Parameters of has()
NameTypeDescription
$namestring

ComponentRegistryInterface::get()

abstract public function get(string $name): Milpa\Live\Contracts\Component\ComponentDefinitionInterface

Looks up a registered component by name.

Parameters

Parameters of get()
NameTypeDescription
$namestring

Throws

\RuntimeException If no component is registered under `$name`. Callers MUST check {@see has()} first when a missing component is an expected, recoverable case rather than a programming error.

ComponentRegistryInterface::register()

abstract public function register(string $name, Milpa\Live\Contracts\Component\ComponentDefinitionInterface $component): void

Registers a component under the given name, replacing any existing registration for that name.

Parameters

Parameters of register()
NameTypeDescription
$namestring
$componentMilpa\Live\Contracts\Component\ComponentDefinitionInterface