RevisionsController final readonly class
Minn\Rest\RevisionsController · public/minn/src/Minn/Rest/RevisionsController.php · 237 lines
wp/v2 revisions under posts, pages, patterns and navigation menus, and autosaves under those and menu items (probes rest-revisions, rest-autosaves). A revision carries the fields its parent's type supports: a navigation menu's its title and content, a menu item's its title alone.
Constants and properties
| private | TYPES = array ( 'posts' => 'post', 'pages' => 'page', 'blocks' => 'wp_block', 'navigation' => 'wp_navigation', 'menu-items' => 'nav_menu_item', ) | The parents' REST bases and their post types. |
| private | FIELDS = array ( 'wp_navigation' => array ( 0 => 'title', 1 => 'content', ), 'nav_menu_item' => array ( 0 => 'title', ), ) | The fields a revision carries by its parent's type; any other carries title, content and excerpt. |
| private | DELETE_REFUSAL = 'Sorry, you are not allowed to delete revisions of this post.' | |
| private | readonly Minn\Content\Posts $posts | 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. |
| private | readonly ?Minn\Front\Permalinks $permalinks | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\Posts $posts, Minn\Content\Revisions $revisions, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller, ?Minn\Front\Permalinks $permalinks = NULL)# | |
| method | revisions(Minn\Http\Request $request, string $base, string $parent): Minn\Http\ResponseGET /wp/v2/{base:posts|pages|blocks|navigation}/{parent:[\d]+}/revisions (cap edit_post on {parent}; post parent {parent} must exist)# | Real revisions, not autosaves. |
| method | revision(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseGET /wp/v2/{base:posts|pages|blocks|navigation}/{parent:[\d]+}/revisions/{id:[\d]+} (cap edit_post on {parent}; post parent {parent} must exist)# | One revision of a post, page, or block. |
| method | deleteRevision(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseDELETE /wp/v2/{base:posts|pages|blocks|navigation}/{parent:[\d]+}/revisions/{id:[\d]+} (cap delete_post on {parent}; post parent {parent} must exist)# | A revision deleted for good, answered as it was; never trashed. The reference grants deleting a revision to nobody by default, so a request that passes the parent's check is refused at the revision's. |
| method | autosaves(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponseGET /wp/v2/{base:posts|pages|blocks|navigation|menu-items}/{id:[\d]+}/autosaves (cap edit_post on {id}; post parent {id} must exist)# | The autosaves of a post. |
| method | autosave(Minn\Http\Request $request, string $base, string $parent, string $id): Minn\Http\ResponseGET /wp/v2/{base:posts|pages|blocks|navigation|menu-items}/{parent:[\d]+}/autosaves/{id:[\d]+} (cap edit_post on {parent}; post parent {parent} must exist)# | The caller's autosave of the parent, whichever autosave id is asked for; the edit view names its preview. |
| method | createAutosave(Minn\Http\Request $request, string $base, string $id): Minn\Http\ResponsePOST /wp/v2/{base:posts|pages|blocks|navigation|menu-items}/{id:[\d]+}/autosaves (cap edit_post on {id}; post {id} must exist)# | One autosave slot per author; the reply carries a preview link. |
| method | object(Minn\Content\PostRecord|array $r, Minn\Rest\Context $context = Minn\Rest\Context::View): array# | One revision row as wp/v2 serves it (autosaves and revisions alike). |
Internals 6
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | clean(string $markup): string# | |
| private | withPreviewLink(array $object, int $parent): array# | The autosave POST reply names where to preview the draft, just before its links; a revision never carries it. |
| private | previewLink(int $parent): string# | Where to preview the parent with its autosave: its permalink once published, its plain address before; none for a type that is never viewed (a navigation menu, a menu item). |
| private | meta(int $id, string $parentType): array# | A revision's meta: the footnotes, and for a pattern the sync status core revisions too; none for a navigation menu or a menu item. |
| private | requireParent(int $parentId, string $base): int# | The revision surfaces are gated on edit_post of the parent. |
| private | parentOf(int $parentId, string $base): Minn\Content\PostRecord# | The parent, of the type the route's base names, or rest_post_invalid_parent. |
Nothing matches.