API / Minn\Rest / BlockTypesController

BlockTypesController final readonly class

Minn\Rest\BlockTypesController · public/minn/src/Minn/Rest/BlockTypesController.php · 133 lines

wp/v2/block-types as the reference answers it (probe rest-block-types): every registered block type, core's and a plugin's, in registration order, or a namespace's share, for anyone who can edit a type shown in REST. Each carries its registration (attributes, supports, selectors, contexts, asset handles and the first of each as the old single field) with its styles (its own, then those registered for it) and its variations as built when asked; a dynamic block links to its renderer. Served with plugins loaded, since a plugin's blocks come from its code.

Used by 1

Constants and properties

privateNAMESPACE = array ( 'namespace' => array ( 'type' => 'string', 'description' => 'Block namespace.', 'required' => false, ), )
privatereadonly Minn\Rest\RestUrl $url

Promoted from the constructor.

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

Public

new__construct(Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/block-types (public)#

Every block type, or those of one namespace (?namespace=).

methodinNamespace(Minn\Http\Request $request, string $namespace): Minn\Http\ResponseGET /wp/v2/block-types/{namespace:[a-zA-Z0-9_-]+} (public)#

One namespace's block types.

methodsingle(Minn\Http\Request $request, string $namespace, string $name): Minn\Http\ResponseGET /wp/v2/block-types/{namespace:[a-zA-Z0-9_-]+}/{name:[a-zA-Z0-9_-]+} (public)#

One block type.

staticfields(Minn\Objects\BlockType $type): array#

A block type's fields in the reference's order, as the route and WP_REST_Block_Types_Controller show them: its registration (supports {} when it has none), its styles (its own, then those registered for it), its variations as built when asked, and the first handle of each asset kind as the old single field (probe rest-block-controllers).

@return array<string, mixed>

Internals 4

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateitems(Minn\Http\Request $request, string $namespace): Minn\Http\Response#
privateitem(Minn\Objects\BlockType $type): array#
@return array<string, mixed>
privatelinks(Minn\Objects\BlockType $type): array#
@return array<string, list<array<string, mixed>>>
privaterequireViewer(): void#

Only someone who edits a type shown in REST may read block types; the runtime holds them.