Fields final readonly class
Minn\Rest\Fields · public/minn/src/Minn/Rest/Fields.php · 106 lines
The _fields response filter. Dot paths descend ("title.rendered"); the object's own key order is kept. Applied per item on list responses and to the whole payload otherwise, which is why _fields on the associative types response strips every key and yields [] over HTTP, a reference quirk the engine reproduces by construction.
Used by 25 (show)
Constants and properties
| prop | readonly array $paths | Promoted from the constructor. |
| prop | readonly bool $deferred | Promoted from the constructor. |
Public
| new | __construct(array $paths, bool $deferred = false)# | embedded first and filtered by Embed afterwards
| ||||||
| static | fromQuery(array $query): ?self# | The _fields selection a query carries, or null for everything.
| ||||||
| method | withLinksForEmbedded(): self# | The same paths plus _links whenever _embedded is among them: the reference's single-object rule under _embed. | ||||||
| method | wants(string $field): bool# | Whether a top-level field is among the selection: named whole, below one of its paths (title.rendered), or above one (a path into it). | ||||||
| method | apply(array $object): array# | The object with only the selected fields. | ||||||
| static | select(array $available, array $requested): array# | The fields a response keeps when a caller names some: known fields as given, dotted paths whose root is known, and `id` whenever it exists.
@return list<string> |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | filter(array $object, array $paths): array# |
Nothing matches.