Skip to content
docsv0.31.1

PageAssets

Everything the components on one page declared, gathered once and ready to embed. `unreadable` is the reason this is a value object and not two strings. A component that names a stylesheet it does not ship is a packaging defect that otherwise shows up as "the thing renders * but looks wrong" — a symptom no page can tell apart from a styling mistake. Naming it here keeps the page rendering (a missing look is not worth a 500) while leaving the defect machine-readable for whoever asks.

PageAssets::__construct()

public function __construct(string $styles = '', array $scripts = [], array $messages = [], array $emitted = [], array $unreadable = [], array $refused = [], array $components = []):

Parameters

Parameters of __construct()
NameTypeDescription
$stylesstring
$scriptsarray<int, string>Client scripts, in declaration order.
$messagesarray<string, string>Resolved words, keyed `component.key`.
$emittedarray<int, string>`name@version` of every component that contributed.
$unreadablearray<string, string>`name@version` => the path it declared and does not ship.
$refusedarray<string, string>`name@version` => why part of an override was not honoured.
$componentsarray<string, array{styles: string, scripts: list<string>, messages: array<string, string>}>each contract's contribution, kept separate so a live response can add a newly-rendered contract once

PageAssets::styleTag()

public function styleTag(): string

Every contributed stylesheet, already scoped, as one tag — or nothing at all when no component on this page declared one, because an empty `<style>` is noise in the source of every page.

PageAssets::scriptTag()

public function scriptTag(): string

Every contributed script as one tag, in declaration order, or nothing when there is none.

PageAssets::messagesTag()

public function messagesTag(): string

The page's words as a payload the client can read, or nothing when there are none. JSON in a `type="application/json"` script rather than a JS assignment: the browser will not execute it, so a translation carrying an apostrophe or a `</script>` cannot become code.

PageAssets::isEmpty()

public function isEmpty(): bool

Whether this page has nothing to embed — including the case where every component that declared something declared a file it does not ship, which is a defect, not an absence.