FontWritesController final readonly class
Minn\Rest\FontWritesController · public/minn/src/Minn/Rest/FontWritesController.php · 151 lines
wp/v2/font-families written (probe font-writes): a family created and updated, a face created under its family, each saved as the reference saves it. The settings are judged before the caller (Rest\FontSettings); only someone who may edit theme options writes. A family is stored as its name (the title), its slug and the rest of its settings as JSON content, refused when another family has the slug (an empty slug matches any); its update merges what it names over what is stored. A face is stored under its identity (Theme\FontNames::faceSlug), refused when a face of any family already has it, its uploaded files moved into the fonts folder in the order its sources name them (a refused file leaves the ones before it in place) and recorded once the answer is shaped. Each save fires the post's own hooks, then rest_insert_{type}, rest_after_insert_{type} and wp_after_insert_post.
Uses 29 (show)
Constants and properties
| private | CREATE = 'Sorry, you are not allowed to create posts as this user.' | |
| private | EDIT = 'Sorry, you are not allowed to edit this post.' | |
| private | FILE_META = '_wp_font_face_file' | |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Rest\FontObject $object | Promoted from the constructor. |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\Posts $posts, Minn\Rest\FontObject $object, Minn\Rest\RestUrl $url)# | |
| method | createFamily(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/font-families (cap edit_theme_options)# | A font family created from its settings. |
| method | updateFamily(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/font-families/{id:[\d]+} (cap edit_theme_options; font family {id} must exist)PUT /wp/v2/font-families/{id:[\d]+} (cap edit_theme_options; font family {id} must exist)PATCH /wp/v2/font-families/{id:[\d]+} (cap edit_theme_options; font family {id} must exist)# | A font family's name, font-family list or preview changed; what the settings leave out stays. |
| method | createFace(Minn\Http\Request $request, string $fontFamilyId): Minn\Http\ResponsePOST /wp/v2/font-families/{font_family_id:[\d]+}/font-faces (cap edit_theme_options)# | A font face created under its family, from remote sources or files the request uploads. |
Internals 4
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | stored(mixed $src, Minn\Http\Request $request): array# | A face's sources with each file the request uploads moved into the fonts folder and named by its address (a remote one is cleaned), and the stored files' names. A refused file ends the save; those before it stay where they were moved. @return array{0: string|list<string>, 1: list<string>} | |||
| private | saved(array $columns, Minn\Http\Request $request, ?Minn\Content\PostRecord $before): int# | A font post saved through the post's own save, its hooks and then the REST insert actions; a save that fails is answered with its error.
| |||
| private | found(array $vars): bool# | Whether a post matches the query, as the reference looks for a family's slug or a face's identity (an empty value narrows nothing). @param array<string, mixed> $vars
| |||
| private | post(int $id): Minn\Content\PostRecord# | The post just saved. |
Nothing matches.