RuntimePrepare final class
Minn\Rest\RuntimePrepare · public/minn/src/Minn/Rest/RuntimePrepare.php · 145 lines
An item a REST response carries, through the filter the reference runs as it prepares one (rest_prepare_{type}, rest_prepare_attachment, rest_prepare_user, rest_prepare_comment, rest_prepare_{taxonomy}): the item as a response object, its links on the response rather than in its data, handed with the object it describes and the request; what the filter leaves is the item. With nothing hooked, or a response handed back untouched, the item is Minn's own, byte for byte. Fields plugin code registers for the type are added first, as the reference adds them before the filter runs.
Constants and properties
| const | BLOCK_HOOKS_TYPES = array ( 0 => 'post', 1 => 'page', 2 => 'wp_block', 3 => 'wp_navigation', ) | The post types whose REST answers and saves get their hooked blocks, before plugins say. |
Public
| static | answering(WP_REST_Request $request): void# | Remembers the request a REST call is answering, for the filters its items pass through (on the request's own runtime). | |||||||||
| static | during(WP_REST_Request $request, Closure $run): mixed# | Runs an in-process REST call answering its own request (the filters hand plugins that one), then puts back the request it interrupted.
| |||||||||
| static | postItem(string $filter, array $item, int $postId, string $type): array# | A post-shaped item (a post, a page, a pattern, a navigation, an attachment, any other type) through rest_prepare_{type}, given its hooked blocks first; the post it describes is looked up only when a hook needs it.
@return array<string, mixed> | |||||||||
| static | savedWithHookedBlocks(stdClass $prepared, string $type): void# | A prepared post about to be saved, as rest_block_hooks_post_types has it: a type it lists has its content's ignored hooked blocks marked, a navigation's root list put in meta_input, as the reference's update_ignored_hooked_blocks_postmeta does; asked of every save. | |||||||||
| static | item(string $filter, array $item, Closure $described, ?string $postType = NULL): array# | One item through a rest_prepare filter.
@return array<string, mixed> |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | hookedBlocks(array $item, string $type, Closure $described): array# | A post item as rest_block_hooks_post_types has it (asked of every item the posts controller prepares, with the post it describes): a type it lists has its raw content given its hooked blocks and rendered again from that, a navigation's root list put in its meta, as the reference's insert_hooked_blocks_into_rest_response does (probe hook-inputs-2).
@return array<string, mixed> | ||||||
| private | withHookedBlocks(string $content, mixed $post, string $callback, array $atRoot): string# |
| ||||||
| private | objectType(string $filter): string# | The object type register_rest_field names for the items a prepare filter sees: the post type, taxonomy, or kind of item. |
Nothing matches.