Skip to content
docsv0.1.0

DashboardViewModelFields

Single seam for deriving dashboard-primitive identity fields (title, description, brand, items, ...) from mounted state meta and request props. Both {@see \Milpa\Live\Rendering\DashboardHtmlRenderer} and {@see \Milpa\Live\Rendering\TuiComponentRenderer} resolve these fields through here instead of re-deriving their own fallback chain, so the two render targets cannot silently disagree on precedence again -- state meta (set at mount time, and possibly mutated since) always wins over the request's current props, which wins over the family default.

DashboardViewModelFields::string()

public static function string(array $meta, array $props, string $key, string $default = ''): string

Resolves a string field, preferring `$meta[$key]`, then `$props[$key]`, then `$default`.

Parameters

Parameters of string()
NameTypeDescription
$metaarray<string, mixed>
$propsarray<string, mixed>
$keystring
$defaultstring

DashboardViewModelFields::bool()

public static function bool(array $meta, array $props, string $key, bool $default = false): bool

Resolves a boolean field, preferring `$meta[$key]`, then `$props[$key]`, then `$default`.

Parameters

Parameters of bool()
NameTypeDescription
$metaarray<string, mixed>
$propsarray<string, mixed>
$keystring
$defaultbool

DashboardViewModelFields::list()

public static function list(array $meta, array $props, string $key): array

Resolves a list-of-records field, preferring `$meta[$key]`, then `$props[$key]`, defaulting to an empty list. Non-array entries within the resolved value are silently dropped rather than causing an error, since list items are expected to each be an associative array (e.g. a sidebar item, an alert entry).

Parameters

Parameters of list()
NameTypeDescription
$metaarray<string, mixed>
$propsarray<string, mixed>
$keystring