BlocksController final readonly class
Minn\Rest\BlocksController · public/minn/src/Minn/Rest/BlocksController.php · 59 lines
wp/v2/blocks: synced patterns and reusable blocks, stored as wp_block posts. The reading and writing is the posts machinery with the post type's own capabilities and the posts list's parameters; what is this type's alone is the reading rule: a pattern is read only by one who may read it (read_post), published or not, so without that the list counts the patterns and shows none, and a single one is refused.
Constants and properties
| private | TYPE = 'wp_block' | |
| private | BASE = 'blocks' | |
| private | readonly Minn\Rest\PostsController $reads | Promoted from the constructor. |
| private | readonly Minn\Rest\PostsWriteController $writes | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Rest\PostsController $reads, Minn\Rest\PostsWriteController $writes, Minn\Rest\Caller $caller)# | |
| method | list(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/{base:blocks} (public)# | The blocks, each shown to a caller who may read it. |
| method | single(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/blocks/{id:[\d]+} (public; block {id} must exist)# | One block. Editing context is the posts machinery's own gate (rest_forbidden_context); a view is refused to anyone who may not read the block, and an unknown one is not found rather than refused. |
| method | create(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/blocks (cap publish_posts)# | Creates a block: a pattern's create_posts is publish_posts. |
| method | update(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/blocks/{id:[\d]+} (cap edit_post on {id}; block {id} must exist)PUT /wp/v2/blocks/{id:[\d]+} (cap edit_post on {id}; block {id} must exist)PATCH /wp/v2/blocks/{id:[\d]+} (cap edit_post on {id}; block {id} must exist)# | Updates a block. |
| method | delete(Minn\Http\Request $request, string $id): Minn\Http\ResponseDELETE /wp/v2/blocks/{id:[\d]+} (cap delete_post on {id}; block {id} must exist)# | Trashes or deletes a block. |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | readable(int $id): bool# | Whether the caller may read a pattern: read_post, whatever its status. |
Nothing matches.