Skip to content
docsv0.1.0

ComponentContext

The ambient, render-target-agnostic context a component is mounted/rendered within — its identity plus request-scoped facts (principal, locale, route) it may need but does not own. Passed alongside props to {@see \Milpa\Live\Contracts\Component\ComponentDefinitionInterface::mount()} so mount-time logic can depend on "who is asking" without every component needing its own principal/locale plumbing.

ComponentContext::__construct()

public function __construct(string $componentId, ?string $principal = null, ?string $locale = null, ?string $route = null, array $meta = []):

Parameters

Parameters of __construct()
NameTypeDescription
$componentIdstringThe component instance's unique id within the page/response.
$principal(string | null)The requesting {@see SecurityPrincipal}'s id, if authenticated.
$locale(string | null)The request's locale, if the caller resolved one.
$route(string | null)The current route/URL, for components that need it (e.g. active-nav state).
$metaarray<string, mixed>Caller-defined extra context beyond the fields above.