BlockRendererController final readonly class
Minn\Rest\BlockRendererController · public/minn/src/Minn/Rest/BlockRendererController.php · 89 lines
wp/v2/block-renderer as the reference answers it (probe rest-block-renderer), the route the editor's ServerSideRender asks: a dynamic block rendered from the attributes sent (query or body), checked against the block's own attributes and filled in with their defaults, inside the post named by post_id when there is one (it becomes the global post, and the block's postId and postType context). Only the edit context is accepted, and asking for none is asking for the view context, which is refused, as on the reference. Arguments are judged before the caller: someone who can edit posts may render, or edit the post named.
Constants and properties
| private | ARGS = array ( 'context' => array ( 'description' => 'Scope under which the request is made; determines fields present in response.', 'type' => 'string', 'enum' => array ( 0 => 'edit', ), 'default' => 'view', 'required' => false, 'handler_validates' => true, ), 'attributes' => array ( 'description' => 'Attributes for the block.', 'type' => 'object', 'default' => array ( ), 'required' => false, 'handler_validates' => true, ), 'post_id' => array ( 'description' => 'ID of the post context.', 'type' => 'integer', 'required' => false, ), ) | |
| private | readonly Minn\Rest\Schema $schema | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Rest\Schema $schema, Minn\Rest\Caller $caller)# | |
| method | render(Minn\Http\Request $request, string $name): Minn\Http\ResponseGET /wp/v2/block-renderer/{name:[a-z0-9-]+/[a-z0-9-]+} (public)POST /wp/v2/block-renderer/{name:[a-z0-9-]+/[a-z0-9-]+} (public)# | The block's markup, as {"rendered": "..."}. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | refuseInvalid(array $args): void# |
| |||
| private | permit(int $postId): void# | Someone who can edit posts may render; with a post named, someone who can edit that post. | |||
| private | rendered(Minn\Objects\BlockType $type, array $attributes, int $postId): string# | The block rendered on its own, inside the post when one is named (the global post put back after). @param array<string, mixed> $attributes
|
Nothing matches.