Skip to content
docsv0.1.0

DataSourceRegistryInterface

Resolves a {@see DataSourceInterface} by name via a register + supports- based lookup — the same pattern {@see \Milpa\Live\Contracts\Rendering\ComponentRendererRegistryInterface} and {@see \Milpa\Live\Contracts\Tui\TuiNodeRendererRegistryInterface} use for their own targets.

DataSourceRegistryInterface::register()

abstract public function register(Milpa\Live\Contracts\Data\DataSourceInterface $source): void

Registers a data source. Implementations that keep an ordered list and resolve by first match SHOULD prefer the most recently registered source when more than one claims to {@see DataSourceInterface::supports()} the same name.

Parameters

Parameters of register()
NameTypeDescription
$sourceMilpa\Live\Contracts\Data\DataSourceInterface

DataSourceRegistryInterface::resolve()

abstract public function resolve(string $source): Milpa\Live\Contracts\Data\DataSourceInterface

Looks up the data source that {@see DataSourceInterface::supports()} the given name.

Parameters

Parameters of resolve()
NameTypeDescription
$sourcestring

Throws

\RuntimeException If no registered source supports `$source`.