class PropsResolver

Traits

Properties

protected Request $request

The current request instance.

protected string $component

The component being rendered.

protected bool $isPartial

Whether this is a partial request for the given component.

protected bool $isInertia

Whether this is an Inertia request.

protected null|array<int, string> $only

The props to include in the partial response.

protected null|array<int, string> $except

The props to exclude from the partial response.

protected array<int, string> $resetProps

The props that should have their merge state reset.

protected array<int, string> $loadedOnceProps

The once-props that the client has already loaded.

protected array<string, array<int, string>> $deferredProps

The deferred props grouped by their defer group.

protected array<int, string> $rescuedProps

The deferred props that were rescued during resolution.

protected array<int, string> $mergeProps

The props that should be appended to existing client-side data.

protected array<int, string> $prependProps

The props that should be prepended to existing client-side data.

protected array<int, string> $deepMergeProps

The props that should be deep merged with existing client-side data.

protected array<int, string> $matchPropsOn

The key matching strategies for mergeable props.

protected array<string, array<string, mixed>> $scrollProps

The scroll pagination metadata for each scroll prop.

protected array<string, array<string, mixed>> $onceProps

The once-prop metadata for each once prop.

protected array<int, string> $sharedPropKeys

The top-level keys of shared props.

Methods

mixed
resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

bool
useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

__construct(Request $request, string $component)

Create a new props resolver instance.

array
resolve(array $shared, array $props)

Resolve the given shared and page props, collecting their metadata.

array
resolveSharedProps(array $shared)

Resolve shared property providers and collect shared prop keys.

array
resolvePropertyProviders(array $props)

Resolve ProvidesInertiaProperties instances into keyed props.

array
buildMetadata()

Build the non-empty metadata arrays for the page response.

array
resolveProps(array $props, string $prefix = '', bool $parentWasResolved = false)

Recursively resolve the props tree, collecting metadata along the way.

bool
shouldIncludeInPartialResponse(mixed $prop, string $path, bool $parentWasResolved)

Determine if a prop should be included in a partial response. AlwaysProp and children of already-resolved values bypass partial filtering.

bool
pathMatchesPartialRequest(string $path)

Determine if the given path matches the current partial request using bidirectional prefix matching on the only/except headers.

bool
excludeFromInitialResponse(mixed $prop, string $path)

Determine if a prop should be excluded from the initial page response.

bool
excludeIgnoredProp(mixed $prop, string $path)

Exclude an IgnoreFirstLoad prop from the initial response while collecting its deferred, merge, and once metadata.

bool
excludeDeferredProp(Deferrable $prop, string $path)

Exclude a deferred prop from the initial response while collecting its deferred-group and merge metadata.

bool
excludeAlreadyLoadedProp(mixed $prop, string $path)

Exclude a once-prop that the client has already loaded while preserving its once metadata for the client.

bool
wasAlreadyLoadedByClient(mixed $prop, string $path)

Determine if a once-prop has already been loaded by the client.

mixed
resolveValue(mixed $value, string $path, array $siblings)

Resolve a single prop value through the resolution pipeline.

bool
isPropType(mixed $value)

Determine if the value is a prop type that requires further filtering or metadata collection.

void
collectMetadata(mixed $prop, string $path)

Collect metadata for a prop that will be included in the response.

void
collectDeferredPropMetadata(string $path, Deferrable $prop)

Collect the deferred prop and its group.

void
collectMergeableMetadata(string $path, Mergeable $prop)

Collect the merge strategy for a mergeable prop.

void
collectScrollMetadata(string $path, ScrollProp $prop)

Collect scroll pagination metadata.

void
collectOnceMetadata(string $path, mixed $prop)

Collect once-prop metadata.

bool
isIncludedInPartialMetadata(string $path)

Determine if the path should contribute metadata during a partial request.

bool
matchesOnly(string $path)

Determine if the path matches or is a descendant of an "only" filter path.

bool
leadsToOnly(string $path)

Determine if the path is an ancestor of an "only" filter path.

bool
matchesExcept(string $path)

Determine if the path matches or is a descendant of an "except" filter path.

array
unpackDotProps(array $props)

Unpack top-level dot-notation keys into nested arrays.

void
ensurePathIsTraversable(array $props, string $dotKey)

Resolve closures and Arrayable values along the intermediate segments of a dot-notation path so that Arr::set can nest into them.

array|null
parseHeader(string $key)

Parse a comma-separated header value into an array.

Details

in ResolvesCallables at line 14
protected mixed resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

Parameters

mixed $value

Return Value

mixed

in ResolvesCallables at line 22
protected bool useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

Parameters

mixed $value

Return Value

bool

at line 135
__construct(Request $request, string $component)

Create a new props resolver instance.

Parameters

Request $request
string $component

at line 155
array resolve(array $shared, array $props)

Resolve the given shared and page props, collecting their metadata.

Parameters

array $shared
array $props

Return Value

array

at line 171
protected array resolveSharedProps(array $shared)

Resolve shared property providers and collect shared prop keys.

Parameters

array $shared

Return Value

array

at line 196
protected array resolvePropertyProviders(array $props)

Resolve ProvidesInertiaProperties instances into keyed props.

Parameters

array $props

Return Value

array

at line 221
protected array buildMetadata()

Build the non-empty metadata arrays for the page response.

Return Value

array

at line 242
protected array resolveProps(array $props, string $prefix = '', bool $parentWasResolved = false)

Recursively resolve the props tree, collecting metadata along the way.

Parameters

array $props
string $prefix
bool $parentWasResolved

Return Value

array

at line 303
protected bool shouldIncludeInPartialResponse(mixed $prop, string $path, bool $parentWasResolved)

Determine if a prop should be included in a partial response. AlwaysProp and children of already-resolved values bypass partial filtering.

Parameters

mixed $prop
string $path
bool $parentWasResolved

Return Value

bool

at line 316
protected bool pathMatchesPartialRequest(string $path)

Determine if the given path matches the current partial request using bidirectional prefix matching on the only/except headers.

Parameters

string $path

Return Value

bool

at line 333
protected bool excludeFromInitialResponse(mixed $prop, string $path)

Determine if a prop should be excluded from the initial page response.

Each exclusion type collects its metadata before the prop is removed.

Parameters

mixed $prop
string $path

Return Value

bool

at line 363
protected bool excludeIgnoredProp(mixed $prop, string $path)

Exclude an IgnoreFirstLoad prop from the initial response while collecting its deferred, merge, and once metadata.

Parameters

mixed $prop
string $path

Return Value

bool

at line 385
protected bool excludeDeferredProp(Deferrable $prop, string $path)

Exclude a deferred prop from the initial response while collecting its deferred-group and merge metadata.

Parameters

Deferrable $prop
string $path

Return Value

bool

at line 400
protected bool excludeAlreadyLoadedProp(mixed $prop, string $path)

Exclude a once-prop that the client has already loaded while preserving its once metadata for the client.

Parameters

mixed $prop
string $path

Return Value

bool

at line 410
protected bool wasAlreadyLoadedByClient(mixed $prop, string $path)

Determine if a once-prop has already been loaded by the client.

Parameters

mixed $prop
string $path

Return Value

bool

at line 423
protected mixed resolveValue(mixed $value, string $path, array $siblings)

Resolve a single prop value through the resolution pipeline.

Parameters

mixed $value
string $path
array $siblings

Return Value

mixed

at line 472
protected bool isPropType(mixed $value)

Determine if the value is a prop type that requires further filtering or metadata collection.

Parameters

mixed $value

Return Value

bool

at line 484
protected void collectMetadata(mixed $prop, string $path)

Collect metadata for a prop that will be included in the response.

Parameters

mixed $prop
string $path

Return Value

void

at line 502
protected void collectDeferredPropMetadata(string $path, Deferrable $prop)

Collect the deferred prop and its group.

Parameters

string $path
Deferrable $prop

Return Value

void

at line 510
protected void collectMergeableMetadata(string $path, Mergeable $prop)

Collect the merge strategy for a mergeable prop.

Parameters

string $path
Mergeable $prop

Return Value

void

at line 545
protected void collectScrollMetadata(string $path, ScrollProp $prop)

Collect scroll pagination metadata.

Parameters

string $path
ScrollProp $prop

Return Value

void

at line 556
protected void collectOnceMetadata(string $path, mixed $prop)

Collect once-prop metadata.

Parameters

string $path
mixed $prop

Return Value

void

at line 575
protected bool isIncludedInPartialMetadata(string $path)

Determine if the path should contribute metadata during a partial request.

Parameters

string $path

Return Value

bool

at line 591
protected bool matchesOnly(string $path)

Determine if the path matches or is a descendant of an "only" filter path.

Parameters

string $path

Return Value

bool

at line 605
protected bool leadsToOnly(string $path)

Determine if the path is an ancestor of an "only" filter path.

Parameters

string $path

Return Value

bool

at line 619
protected bool matchesExcept(string $path)

Determine if the path matches or is a descendant of an "except" filter path.

Parameters

string $path

Return Value

bool

at line 636
protected array unpackDotProps(array $props)

Unpack top-level dot-notation keys into nested arrays.

Parameters

array $props

Return Value

array

at line 665
protected void ensurePathIsTraversable(array $props, string $dotKey)

Resolve closures and Arrayable values along the intermediate segments of a dot-notation path so that Arr::set can nest into them.

Parameters

array $props
string $dotKey

Return Value

void

at line 698
protected array|null parseHeader(string $key)

Parse a comma-separated header value into an array.

Parameters

string $key

Return Value

array|null