API / Minn\Rest / RuntimeEnvelope

RuntimeEnvelope final readonly class

Minn\Rest\RuntimeEnvelope · public/minn/src/Minn/Rest/RuntimeEnvelope.php · 123 lines · implements Minn\Http\Envelope

The REST server's filters around one of Minn's own routes, as the reference runs them around every route (contracts/runtime.md, "The REST server's envelope"): rest_request_before_callbacks is handed the argument check's error or null and may refuse; the route's permission is the next refusal; rest_dispatch_request may answer in place of the route; rest_request_after_callbacks sees whatever came of it and may change it. A value other than an error from the first filter does not answer: the route still runs. With nothing hooked on any of the three, the route answers as it would without plugins, unconverted; and before the runtime boots (the API is built first) there are no plugins to ask.

Used by 1

Constants and properties

privateFILTERS = array ( 0 => 'rest_request_before_callbacks', 1 => 'rest_dispatch_request', 2 => 'rest_request_after_callbacks', )
privatereadonly Minn\Rest\Types $types

Promoted from the constructor.

Public

new__construct(Minn\Rest\Types $types)#
$typesTypesthe declared types, for naming a {base} route as the reference does
methodaround(Minn\Http\Matched $matched, Minn\Http\Request $request, ?Minn\RestError $invalid, ?Minn\RestError $refusal, Closure $invoke): Minn\Http\Response#

The route's answer with the server's filters around it, or as the route gives it when no plugin can hear.

Internals 6

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

privateplain(?Minn\RestError $invalid, ?Minn\RestError $refusal, Closure $invoke): Minn\Http\Response#

The route answering as it does without plugins: the refusals thrown in the router's own order.

privaterun(Closure $invoke): WP_REST_Response|WP_Error#

The route's answer as the server's filters hand it on: a response object, or the error it refused with.

privaterouteName(Minn\Http\Matched $matched, Minn\Http\Request $request): string#

The route as the reference names it in its table: the form of the pattern this request matched.

privatehandler(Minn\Http\Matched $matched, ?Minn\RestError $refusal): array#

The handler as plugins read it from the filters: its methods, its arguments as the index publishes them, and callables for the route and its permission.

@return array<string, mixed>
privatedefaults(array $args): array#
$argsarray<string, mixed>@return array<string, mixed>
privatetyped(array $captures): array#

The captures as the reference holds them once its arguments passed: a number is an integer.

$capturesarray<string, string>
@return array<string, int|string>