CommentsController final readonly class
Minn\Rest\CommentsController · public/minn/src/Minn/Rest/CommentsController.php · 294 lines
wp/v2/comments: the status tabs with pagination headers, single, signed-in replies, moderation updates, trash, and force delete.
Constants and properties
| private | readonly Minn\Content\Comments $comments | Promoted from the constructor. |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Rest\CommentObject $object | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\Comments $comments, Minn\Content\Posts $posts, Minn\Rest\CommentObject $object, Minn\Rest\Caller $caller)# | |
| method | list(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/comments (public)# | The comments list as the reference serves it: the request's WP_Comment_Query through rest_comment_query, its totals (counted again when a page comes back empty), and the comments the caller may read. |
| method | single(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/comments/{id:[\d]+} (public; comment {id} must exist)# | One comment, if the caller may read it. |
| method | create(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/comments (signed in)# | A signed-in reply; the author fields come from the user. |
| method | update(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/comments/{id:[\d]+} (cap moderate_comments; comment {id} must exist)PUT /wp/v2/comments/{id:[\d]+} (cap moderate_comments; comment {id} must exist)PATCH /wp/v2/comments/{id:[\d]+} (cap moderate_comments; comment {id} must exist)# | Status flips and content or author edits, for moderators. |
| method | delete(Minn\Http\Request $request, string $id): Minn\Http\ResponseDELETE /wp/v2/comments/{id:[\d]+} (cap moderate_comments; comment {id} must exist)# | Trash remembers where the comment came from; force removes it outright. |
Internals 7
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | totals(WP_Comment_Query $query, array $args, int $perPage): array# | The total and the page count: the query's own, or, when it found nothing (a page past the end), a count without the page.
@return array{0: int, 1: int} | |||
| private | events(): Minn\Runtime\CommentEvents# | Tells plugins about the writes, through the runtime's comment functions. | |||
| private | allowed(WP_REST_Request $wp, Minn\Rest\Context $context, string $email): void# | What this caller may ask the list for: the edit context and other statuses are for moderators and editors; comments without a post belong to moderators, an unreadable post's to those who may read it (or who give its password); type, author, author_exclude and author_email to anyone who can edit posts (the email judged as sent, before sanitizing empties a bad one). | |||
| private | readablePost(Minn\Content\PostRecord $post, string $password): bool# | A post whose comments this caller may read: a protected one only with its password or for someone who may edit it, as the reference reads it; otherwise one it may read, or any published one. | |||
| private | readable(WP_Comment $comment, string $password): bool# | A listed comment this caller may read: a moderator any, its author their own, anyone an approved one on a post they may read. | |||
| private | plainComment(int $id): Minn\Content\CommentRecord# | A comment row of the plain kind, or the reference's invalid-id error. | |||
| private | prepared(array $body, Minn\Http\Request $request): array# | The fields a request sends, as the reference's controller prepares them for the runtime: the content, the author fields, the address (a moderator may name one) and the browser.
@return array<string, mixed> |
Nothing matches.