Skip to content
docsv0.31.1

ContentComponent

Readable entries — the smallest declaration that lets a house paint narrative content (greenhouse decisions/0464). It knows nothing of what the rows ARE. It knows ROLES: which field is read as the title, which as the body, and optionally which as the lead and which as metadata. The same declaration paints an article, a notice, a changelog entry or a help page, and a new kind of row needs no new code — that is the test this primitive exists to pass. `rows` is the prop a screen binding fills, so a declared screen can bind this to an entity's public rows exactly as it binds a table. The body is plain text: a blank line separates paragraphs and everything is escaped. A body that could carry markup is a separate security question, not a smaller one.

ContentComponent::contract()

public static function contract(): Milpa\Live\ValueObjects\ComponentContract

The contract: rows and the roles that read them; no actions — reading needs no round trip.

ContentComponent::mount()

public function mount(array $props, Milpa\Live\ValueObjects\ComponentContext $context): Milpa\Live\ValueObjects\StateSnapshot

Mounts after checking the roles; a declaration that names no title or body is refused here.

Parameters

Parameters of mount()
NameTypeDescription
$propsarray
$contextMilpa\Live\ValueObjects\ComponentContext

ContentComponent::handle()

public function handle(Milpa\Live\ValueObjects\InteractionRequest $request): Milpa\Live\ValueObjects\InteractionResult

Nothing to do: an entry is read, not operated.

Parameters

Parameters of handle()
NameTypeDescription
$requestMilpa\Live\ValueObjects\InteractionRequest

ContentComponent::roles()

public static function roles(?mixed $roles): array

The roles, checked: `title` and `body` name a field, `lead` may, `meta` is a list of fields.

Parameters

Parameters of roles()
NameTypeDescription
$roles?mixed

ContentComponent::rows()

public static function rows(?mixed $rows, array $roles): array

The rows, checked against the roles: a role that names a field the rows do not carry is refused, because an entry painted without its title reads as a broken page and not as a wrong declaration.

Parameters

Parameters of rows()
NameTypeDescription
$rows?mixed
$rolesarray{title: string, body: string, lead: ?string, meta: list<string>}

ContentComponent::paragraphs()

public static function paragraphs(?mixed $body): array

A body as paragraphs: a blank line separates them, and single line breaks are kept within one.

Parameters

Parameters of paragraphs()
NameTypeDescription
$body?mixed

Returns

paragraphs, each a list of lines