API / Minn\Rest / TermsController

TermsController final readonly class

Minn\Rest\TermsController · public/minn/src/Minn/Rest/TermsController.php · 193 lines

wp/v2 categories, tags, and pattern categories: list, single, and the create/update/delete the taxonomy admin drives.

Constants and properties

privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Content\Terms $terms

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Rest\TermObject $object

Promoted from the constructor.

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Content\Terms $terms, Minn\Content\Site $site, Minn\Rest\TermObject $object, Minn\Rest\Caller $caller)#
methodlist(Minn\Http\Request $request, string $base): Minn\Http\ResponseGET /wp/v2/{base:categories|tags|wp_pattern_category} (public)#

A taxonomy's term list as the reference serves it: the request's get_terms (wp_get_object_terms for a post's) through rest_{taxonomy}_collection_params and rest_{taxonomy}_query, counted by wp_count_terms without the page.

methodsingle(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponseGET /wp/v2/{base:categories|tags|wp_pattern_category}/{id:[\d]+} (public; term {id} must exist; edit context: cap manage_categories)#

One category or tag.

methodcreate(Minn\Http\Request $request, string $base): Minn\Http\ResponsePOST /wp/v2/{base:categories} (cap manage_categories)POST /wp/v2/{base:tags|wp_pattern_category} (cap edit_posts)#

Tags and pattern categories are open to edit_posts holders; categories need manage_categories.

methodupdate(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponsePOST /wp/v2/{base:categories|tags|wp_pattern_category}/{id:[\d]+} (cap manage_categories; term {id} must exist)PUT /wp/v2/{base:categories|tags|wp_pattern_category}/{id:[\d]+} (cap manage_categories; term {id} must exist)PATCH /wp/v2/{base:categories|tags|wp_pattern_category}/{id:[\d]+} (cap manage_categories; term {id} must exist)#

Updates a category or tag.

methoddelete(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponseDELETE /wp/v2/{base:categories|tags|wp_pattern_category}/{id:[\d]+} (cap manage_categories; term {id} must exist)#

The default category is capability-denied before the force check.

staticcreateCapability(string $taxonomy): string#

What creating a term needs (probe rest-plugin-caps): a plugin's taxonomy, its edit_terms when hierarchical and its assign_terms when flat; categories, manage_categories; the others, edit_posts.

Internals 2

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

privaterequireParent(int $parent, string $taxonomy): void#

The reference's refusal of a parent that is not there, before anything is saved.

privatetermsReadable(WP_Post $post, array $objectTypes): bool#

Whether a post's terms may be listed: the taxonomy must be one of its type's, and the post publicly viewable (a public status of a viewable type, a password or not) or one the caller may read, as the reference judges it.

$objectTypeslist<string>the taxonomy's post types