BatchController final readonly class
Minn\Rest\BatchController · public/minn/src/Minn/Rest/BatchController.php · 159 lines
batch/v1 as the reference answers it (probe rest-batch): up to 25 writes (POST, PUT, PATCH, DELETE) in one request, each answered in turn as {body, status, headers}, the whole as 207. Only routes that take part in batches may be asked: posts, pages and the other post types shown in REST (not media, templates, global styles or fonts), the taxonomies, users, widgets, and a plugin's routes that opt in with allow_batch. Any other route answers rest_batch_not_allowed with its Allow header, a path with no route rest_no_route. With require-all-validate, every request's arguments are judged first and one failure answers the whole batch with the failures alone (null for the rest), nothing written.
Constants and properties
| private | BODY = array ( 'validation' => array ( 'type' => 'string', 'enum' => array ( 0 => 'require-all-validate', 1 => 'normal', ), 'default' => 'normal', 'required' => false, ), 'requests' => array ( 'required' => true, 'type' => 'array', 'maxItems' => 25, 'items' => array ( 'type' => 'object', 'properties' => array ( 'method' => array ( 'type' => 'string', 'enum' => array ( 0 => 'POST', 1 => 'PUT', 2 => 'PATCH', 3 => 'DELETE', ), 'default' => 'POST', ), 'path' => array ( 'type' => 'string', 'required' => true, ), 'body' => array ( 'type' => 'object', 'properties' => array ( ), 'additionalProperties' => true, ), 'headers' => array ( 'type' => 'object', 'properties' => array ( ), 'additionalProperties' => array ( 'type' => array ( 0 => 'string', 1 => 'array', ), 'items' => array ( 'type' => 'string', ), ), ), ), ), ), ) | |
| private | NOT_BATCHED = array ( 0 => 'attachment', 1 => 'wp_template', 2 => 'wp_template_part', 3 => 'wp_global_styles', 4 => 'wp_font_family', 5 => 'wp_font_face', ) | Post types served by controllers that do not take part in batches. |
| private | readonly Minn\Http\Router $router | Promoted from the constructor. |
| private | readonly Closure $dispatch | Promoted from the constructor. |
| private | readonly Minn\Rest\ArgCheck $args | Promoted from the constructor. |
| private | readonly Minn\Rest\Types $types | Promoted from the constructor. |
Public
| new | __construct(Minn\Http\Router $router, Closure $dispatch, Minn\Rest\ArgCheck $args, Minn\Rest\Types $types)# |
| |||
| method | batch(Minn\Http\Request $request): Minn\Http\ResponsePOST /batch/v1 (public)# | The requests answered in turn. |
Internals 7
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | refusal(Minn\Http\Request $sub): ?array# | A request a batch may not carry, as its envelope: no route, or a route that does not take part. @return array<string, mixed>|null @return array<string, mixed>|null | |||
| private | invalid(Minn\Http\Request $sub): ?array# | A request whose arguments do not validate, as its envelope (no headers); null when they do. @return array<string, mixed>|null @return array<string, mixed>|null | |||
| private | claims(Minn\Http\Route $route, array $captures): bool# | A {base} route answers only for a type an extension declared, as the gate's Access::Type has it. @param array<string, string> $captures
| |||
| private | batchablePath(string $path): bool# | Whether an engine path belongs to a route that takes part in batches. | |||
| private | subRequest(Minn\Http\Request $parent, array $entry): Minn\Http\Request# | One entry of the batch as a request of its own: its method, path and query, its body as JSON, the caller's session. @param array<string, mixed> $entry
| |||
| private | error(Minn\RestError $error, array $allow): array# |
| |||
| private | envelope(Minn\Http\Response $response): array# | A sub-request's answer as {body, status, headers}: the headers its route set, not the server's own. @return array<string, mixed> @return array<string, mixed> |
Nothing matches.