TemplateRevisionsController final readonly class
Minn\Rest\TemplateRevisionsController · public/minn/src/Minn/Rest/TemplateRevisionsController.php · 197 lines
wp/v2/templates and wp/v2/template-parts revisions and autosaves: the revision rows of a template the site saved, each shown as the template it once was (the template's own shape, its parent's id, a self link and a parent link). The template is judged before the caller, as on the reference: one nobody saved is no parent, one only a theme file holds cannot have revisions; then the caller must be signed in and able to edit the saved row. The routes are listed ahead of the templates' own, whose id pattern would take these paths too.
Uses 30 (show)
Constants and properties
| private | ID = '([^\\/:<>\\*\\?"\\|]+(?:\\/[^\\/:<>\\*\\?"\\|]+)?)[\\/\\w%-]+' | |
| private | READ_REFUSAL = 'Sorry, you are not allowed to view revisions of this post.' | |
| private | AUTOSAVES_REFUSAL = 'Sorry, you are not allowed to view autosaves of this post.' | |
| private | DELETE_REFUSAL = 'Sorry, you are not allowed to delete revisions of this post.' | |
| private | MANAGE_REFUSAL = 'Sorry, you are not allowed to access the templates on this site.' | |
| private | readonly Minn\Theme\TemplateIndex $index | Promoted from the constructor. |
| private | readonly Minn\Rest\TemplateObject $object | Promoted from the constructor. |
| private | readonly Minn\Content\Revisions $revisions | Promoted from the constructor. |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Theme\TemplateIndex $index, Minn\Rest\TemplateObject $object, Minn\Content\Revisions $revisions, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)# | |
| method | revisions(Minn\Http\Request $request, string $base, string $parent): Minn\Http\ResponseGET /wp/v2/{base:templates|template-parts}/{parent:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/revisions (public)# | Every revision of a saved template, its autosaves among them, filtered, ordered and paged as the request asks (RevisionCollection). |
| method | revision(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseGET /wp/v2/{base:templates|template-parts}/{parent:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/revisions/{id:[\d]+} (public)# | One revision of a saved template; a revision of another post is a mismatch. |
| method | deleteRevision(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseDELETE /wp/v2/{base:templates|template-parts}/{parent:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/revisions/{id:[\d]+} (public)# | A template's revision deleted for good, answered as it was; never trashed, so without force it is refused. One of another post is not this template's to delete. |
| method | autosaves(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponseGET /wp/v2/{base:templates|template-parts}/{id:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/autosaves (public)# | The autosaves of a saved template, every author's, newest first. |
| method | autosave(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseGET /wp/v2/{base:templates|template-parts}/{parent:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/autosaves/{id:[\d]+} (public)# | The template's newest autosave, whoever saved it and whichever autosave id is asked for. |
| method | createAutosave(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponsePOST /wp/v2/{base:templates|template-parts}/{id:([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+}/autosaves (cap edit_posts + edit_theme_options)# | An autosave of a saved template (probe rest-template-autosave): the caller's own draft is saved in place, and published; any other keeps one autosave per author, holding only what the body sends (a field it leaves out is stored empty). The caller is judged before the template. The reply is what was saved, shown as the template, in the edit context. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | readable(string $base, string $id, string $refusal): Minn\Theme\TemplateRecord# | The saved template, then the caller judged: signed in, and able to edit it. |
| private | saved(string $base, string $id): Minn\Theme\TemplateRecord# | The template the id names, refused when there is none or when only a file (or a plugin) provides it. |
| private | shaped(string $base, Minn\Theme\TemplateRecord $template, Minn\Content\PostRecord $revision, Minn\Rest\Context $context, string $kind): array# | A revision row shown as the template it held: the template's own shape with the revision's content, title, description, author and dates, its parent's id, and links to itself and its template. The embed view has no dates and an empty content. @return array<string, mixed> |
Nothing matches.