API / Minn\Rest / FontsController

FontsController final readonly class

Minn\Rest\FontsController · public/minn/src/Minn/Rest/FontsController.php · 162 lines

wp/v2/font-families and their font-faces, read and deleted (probe: the font library routes on the reference). Only someone who may edit theme options reads or deletes either, refused as rest_cannot_read or rest_cannot_delete; a family or face that does not exist (the query's id, else the path's) is refused before the caller is judged, a face's family only after. A list is the posts list narrowed to its own parameters: the statuses the caller may read (published and private), newest id first, the ids, offset, slugs (families only) and pages as the posts list reads them, through rest_{type}_query; anything else the request carries is ignored, a search included.

Used by 1

Constants and properties

privateFAMILIES = 'Sorry, you are not allowed to access font families.'
privateFAMILY = 'Sorry, you are not allowed to access this font family.'
privateFACES = 'Sorry, you are not allowed to access font faces.'
privateFACE = 'Sorry, you are not allowed to access this font face.'
privateDELETE = 'Sorry, you are not allowed to delete this post.'
privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Minn\Rest\FontObject $object

Promoted from the constructor.

Public

new__construct(Minn\Content\Posts $posts, Minn\Rest\FontObject $object)#
methodfamilies(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/font-families (cap edit_theme_options)#

The font families.

methodfamily(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/font-families/{id:[\d]+} (cap edit_theme_options; font family {id} must exist)#

One font family.

methodfaces(Minn\Http\Request $request, string $fontFamilyId): Minn\Http\ResponseGET /wp/v2/font-families/{font_family_id:[\d]+}/font-faces (cap edit_theme_options)#

A font family's faces.

methodface(Minn\Http\Request $request, string $fontFamilyId, string $id): Minn\Http\ResponseGET /wp/v2/font-families/{font_family_id:[\d]+}/font-faces/{id:[\d]+} (cap edit_theme_options; font face {id} must exist)#

One font face of a family.

methoddeleteFamily(Minn\Http\Request $request, string $id): Minn\Http\ResponseDELETE /wp/v2/font-families/{id:[\d]+} (cap edit_theme_options; font family {id} must exist)#

A font family deleted for good, its faces with it; there is no trash for either.

methoddeleteFace(Minn\Http\Request $request, string $fontFamilyId, string $id): Minn\Http\ResponseDELETE /wp/v2/font-families/{font_family_id:[\d]+}/font-faces/{id:[\d]+} (cap edit_theme_options; font face {id} must exist)#

A font face deleted for good, its file with it.

Internals 6

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

privatedelete(Minn\Http\Request $request, Minn\Content\PostRecord $post, Closure $shape): Minn\Http\Response#

A delete as the font routes answer it: refused without force (the reference names font faces for a family too), else the post deleted through the reference's own deleting and answered as it was, in the edit context and without its links, then rest_delete_{type}.

$shape\Closure(PostRecord): array<string, mixed>
privatelist(Minn\Http\Request $request, string $type, array $registered, array $fixed, Closure $shape): Minn\Http\Response#

A list of one type, as the posts list reads its parameters.

$registeredarray<string, array<string, mixed>>
$fixedarray<string, mixed>query variables the route sets itself
$shape\Closure(PostRecord): array<string, mixed>
privatetotals(Minn\Objects\Query $query, array $vars): array#

The total and the page count as the posts list gives them: the query's own, or, for a later page that came back empty, a count without the page; a page past the last is refused.

$varsarray<string, mixed>
@return array{0: int, 1: int}
privateparent(int $id): Minn\Content\PostRecord#

The family a face route names, or rest_post_invalid_parent.

privatefound(int $id, string $type): Minn\Content\PostRecord#

A post of the type, or rest_post_invalid_id (the refusal has looked already; this keeps the handler honest).

privateinvalidParent(): Minn\RestError#