RegisteredFields final class
Minn\Rest\RegisteredFields · public/minn/src/Minn/Rest/RegisteredFields.php · 105 lines
The fields plugin code adds to an object type with register_rest_field, as the reference serves them (probe rest-fields). A get callback's value follows the item's own fields, before its links. It is handed the item so far (without links, cut to the fields asked for, id kept), the field's name, the request and the object type. A field is left out when _fields does not name it or its schema's context does not include the request's. A write runs the update callbacks for the fields its body names, with the saved object, before rest_after_insert; an error one returns is the write's answer.
Public
| static | add(array $item, string $type, WP_REST_Request $request): array# | The item with the type's registered fields added, answering the request. @param array<string, mixed> $item @return array<string, mixed>
| |||
| static | update(object $object, string $type, WP_REST_Request $request): void# | Runs the update callbacks for the fields the request's body names; an error one returns is thrown as the write's answer. | |||
| static | context(WP_REST_Request $request, string $type): string# | The context the item is answered in, set on the request as the reference's controllers set it: a write and a delete answer in edit (a term's delete in view); a read in the one asked for, or view. | |||
| static | shownIn(string $type, string $context): array# | The names of the fields registered for the type that show in the context. @return list<string> @return list<string> |
Internals 4
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | of(string $type): array# | @return array<string, array<string, mixed>> | |||
| private | wanted(WP_REST_Request $request): ?array# | The fields _fields names, or null when it names none. @return list<string>|null @return list<string>|null | |||
| private | inContext(array $options, string $context): bool# | A field without a schema, or one whose schema names no context, shows in every context. @param array<string, mixed> $options
| |||
| private | refusal(WP_Error $error): Minn\RestError# |
Nothing matches.