ComponentRendererRegistry
The default in-memory {@see ComponentRendererRegistryInterface}: resolves a renderer by target, preferring the most recently {@see register()}ed renderer that {@see ComponentRendererInterface::supportsTarget()} it. It is also the pair of a {@see \Milpa\Live\Runtime\CompositeComponentRegistry} (greenhouse decisions/0211): a renderer may be registered FOR a component name ({@see registerFor()}), and {@see resolveFor()} answers "who renders * this component at this target" — the per-name renderer when it supports the target, else nothing. The target-wide {@see resolve()} is a different question and is deliberately NOT its fallback: every shipped HTML renderer is single-family and throws for the rest, so handing a name to whatever renderer happens to support the target turns a missing registration into an uncaught exception in the endpoint instead of a null. A host with a general renderer registers it for each name it serves. That is how one live endpoint re-renders every plugin's components without a hand-wired name → renderer array — the registry answers exactly what the array did.
ComponentRendererRegistry::register()
public function register(Milpa\Live\Contracts\Rendering\ComponentRendererInterface $renderer): voidRegisters `$renderer`, taking precedence over any already-registered renderer for the same target.
Parameters
| Name | Type | Description |
|---|---|---|
| $renderer | Milpa\Live\Contracts\Rendering\ComponentRendererInterface |
ComponentRendererRegistry::registerFor()
public function registerFor(string $componentName, Milpa\Live\Contracts\Rendering\ComponentRendererInterface $renderer): voidRegisters `$renderer` for the component named `$componentName` — it takes precedence, for that name, over any target-wide renderer and over any renderer registered for the name earlier.
Parameters
| Name | Type | Description |
|---|---|---|
| $componentName | string | |
| $renderer | Milpa\Live\Contracts\Rendering\ComponentRendererInterface |
ComponentRendererRegistry::resolve()
public function resolve(Milpa\Live\ValueObjects\RenderTarget $target): ?Milpa\Live\Contracts\Rendering\ComponentRendererInterfaceReturns the most recently registered renderer that supports `$target`, or `null` if none does.
Parameters
| Name | Type | Description |
|---|---|---|
| $target | Milpa\Live\ValueObjects\RenderTarget |
ComponentRendererRegistry::resolveFor()
public function resolveFor(string $componentName, Milpa\Live\ValueObjects\RenderTarget $target): ?Milpa\Live\Contracts\Rendering\ComponentRendererInterfaceThe renderer for `$componentName` at `$target`: the most recently {@see registerFor()}ed one that supports the target, else `null`. A target-wide {@see register()}ed renderer is not consulted — see the class docblock for why.
Parameters
| Name | Type | Description |
|---|---|---|
| $componentName | string | |
| $target | Milpa\Live\ValueObjects\RenderTarget |