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.
Constants and properties
| private | FAMILIES = 'Sorry, you are not allowed to access font families.' | |
| private | FAMILY = 'Sorry, you are not allowed to access this font family.' | |
| private | FACES = 'Sorry, you are not allowed to access font faces.' | |
| private | FACE = 'Sorry, you are not allowed to access this font face.' | |
| private | DELETE = 'Sorry, you are not allowed to delete this post.' | |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Rest\FontObject $object | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\Posts $posts, Minn\Rest\FontObject $object)# | |
| method | families(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/font-families (cap edit_theme_options)# | The font families. |
| method | family(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. |
| method | faces(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. |
| method | face(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. |
| method | deleteFamily(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. |
| method | deleteFace(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.
| private | delete(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}.
| |||||||||
| private | list(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.
| |||||||||
| private | totals(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.
@return array{0: int, 1: int} | |||||||||
| private | parent(int $id): Minn\Content\PostRecord# | The family a face route names, or rest_post_invalid_parent. | |||||||||
| private | found(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). | |||||||||
| private | invalidParent(): Minn\RestError# |
Nothing matches.