Skip to content
docsv0.9.0

StateMachineHtmlRenderer

HTML {@see ComponentRendererInterface} for the `state-machine` contract — the counterpart the dashboard renderer never was (greenhouse decisions/0164). `DashboardHtmlRenderer` renders dashboard primitives and throws for everything else, so a state-machine page had no server renderer; this is it, single-component on purpose (it throws for any contract but `state-machine`), so the page controller dispatches to it by contract name. A state-machine is DECLARABLE by data (its `machine` — initial + transitions — arrives in the props, greenhouse decisions/0095), so this renders the CURRENT state and the transitions available from it as actions the live wire fires over `POST {route}`. The server owns the state; the transition buttons carry the action name for the client to fire and for the endpoint to advance and re-sign.

StateMachineHtmlRenderer::__construct()

public function __construct(Milpa\Live\Contracts\Client\ClientRuntimeAdapterInterface $client, Milpa\Live\Contracts\Transport\StateTransferCodecInterface $codec, ?Milpa\Live\Contracts\Rendering\TemplateRendererInterface $templates = null, ?Milpa\Interfaces\Event\MilpaEventDispatcherInterface $dispatcher = null):

Parameters

Parameters of __construct()
NameTypeDescription
$clientMilpa\Live\Contracts\Client\ClientRuntimeAdapterInterface
$codecMilpa\Live\Contracts\Transport\StateTransferCodecInterface
$templates?Milpa\Live\Contracts\Rendering\TemplateRendererInterface
$dispatcher?Milpa\Interfaces\Event\MilpaEventDispatcherInterface

StateMachineHtmlRenderer::supportsTarget()

public function supportsTarget(Milpa\Live\ValueObjects\RenderTarget $target): bool

This renderer targets HTML only.

Parameters

Parameters of supportsTarget()
NameTypeDescription
$targetMilpa\Live\ValueObjects\RenderTarget

StateMachineHtmlRenderer::render()

public function render(Milpa\Live\Contracts\Component\ComponentDefinitionInterface $component, Milpa\Live\ValueObjects\RenderRequest $request): Milpa\Live\ValueObjects\RenderResult

Render one `state-machine` component to HTML: the signed state envelope plus the current state and the transitions available from it. Throws when handed any contract other than `state-machine` — this renderer is intentionally single-family, and the page controller dispatches to it by contract name.

Parameters

Parameters of render()
NameTypeDescription
$componentMilpa\Live\Contracts\Component\ComponentDefinitionInterface
$requestMilpa\Live\ValueObjects\RenderRequest