API / Minn\Rest / BlocksController

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.

Used by 1

Constants and properties

privateTYPE = 'wp_block'
privateBASE = 'blocks'
privatereadonly Minn\Rest\PostsController $reads

Promoted from the constructor.

privatereadonly Minn\Rest\PostsWriteController $writes

Promoted from the constructor.

privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly 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)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/blocks (public)#

The blocks the caller may edit; an empty list for anyone else.

methodsingle(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.

methodcreate(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/blocks (cap publish_posts)#

Creates a block: a pattern's create_posts is publish_posts.

methodupdate(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.

methoddelete(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.