API / Minn\Runtime / TermEvents

TermEvents final readonly class

Minn\Runtime\TermEvents · public/minn/src/Minn/Runtime/TermEvents.php · 114 lines

What the reference's REST terms controller tells plugins, for the engine's own: with plugins loaded a term is saved as that controller saves one (rest_pre_insert_{taxonomy}, then the runtime's wp_insert_term or wp_update_term, and wp_delete_term), and the REST actions follow. Without a booted runtime each write is the engine's own.

Public

methodlive(): bool#

Whether plugins are loaded to be told anything.

methodrestCreate(string $taxonomy, array $body, Minn\Http\Request $request): int#

A term created over REST with plugins loaded, as the reference's controller creates one (probe rest-term-save): the request's fields as the prepared term, through rest_pre_insert_{taxonomy}, into wp_insert_term; a refusal is its REST error.

$bodyarray<string, mixed>
methodrestUpdate(int $termId, string $taxonomy, array $body, Minn\Http\Request $request): void#

A term changed over REST with plugins loaded: the fields the request sends, through rest_pre_insert_{taxonomy}, into wp_update_term (when any are left); a refusal is its REST error.

$bodyarray<string, mixed>
methoddelete(int $termId, string $taxonomy, array $data, Minn\Http\Request $request, Closure $quietly): void#

Deletes a term, then tells plugins over REST with the term as it was and the response.

$dataarray<string, mixed>the response
$quietlyClosure(): voidthe engine's own delete
methodrestSaved(int $termId, string $taxonomy, Minn\Http\Request $request, string $verb): void#

rest_insert_{taxonomy}, then rest_after_insert_{taxonomy}, with the term as it stands and the request.

Internals 2

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

privateprepared(string $taxonomy, array $body, Minn\Http\Request $request): array#

The prepared term: the fields the request sends, in the reference's order, the name and slug cleaned as its schema cleans them; then rest_pre_insert_{taxonomy}.

$bodyarray<string, mixed>
@return array<string, mixed>
privaterefusal(WP_Error $error): Minn\RestError#

A save's refusal as REST serves it: a name in use with the term's id, anything else with its own status or 500.