BlocksController final readonly class
Minn\Rest\BlocksController · public/minn/src/Minn/Rest/BlocksController.php · 69 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; what is this type's alone is the reading gate: without edit_posts the list is empty and a single block is refused, published or not.
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\Content\Posts $posts | 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\Content\Posts $posts, Minn\Rest\Caller $caller)# | |
| method | list(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/blocks (public)# | The blocks the caller may edit; an empty list for anyone else. |
| 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 cannot edit posts, and a trashed or unknown block 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. |
Nothing matches.