PostObject final readonly class
Minn\Rest\PostObject · public/minn/src/Minn/Rest/PostObject.php · 533 lines
Builds the wp/v2 post and page objects in the reference's shape: the view context, the edit context (raw+rendered dual fields, editor-only fields, and cap-gated wp:action-* links), and their _links blocks.
Constants and properties
| private | NAVIGATION = 'wp_navigation' | The one post type whose REST shape is not post-shaped. |
| private | BLOCK = 'wp_block' | The other: a pattern carries its content raw, its category, and its sync status. |
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Content\Users $users | Promoted from the constructor. |
| private | readonly Minn\Front\Permalinks $permalinks | 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\Db $db, Minn\Content\Posts $posts, Minn\Content\Users $users, Minn\Front\Permalinks $permalinks, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)# | |
| method | view(Minn\Content\PostRecord $p, ?Minn\Rest\Fields $fields = NULL): array# | The view-context object, through rest_prepare_{type} when a plugin hooks it; with a _fields selection, the rendered title, content and excerpt only when it asks for them, as the reference renders only what is asked. |
| method | edit(Minn\Content\PostRecord $p, int $userId, ?Minn\Rest\Fields $fields = NULL): array# | The edit-context object, its raw content given its hooked blocks, through rest_prepare_{type} when a plugin hooks it; with a _fields selection, rendered only as far as it asks. |
| method | permalink(Minn\Content\PostRecord $p): string# | A post's permalink as of now: pretty once live with a slug, ?p= (or ?page_id=) before. |
| static | restBase(string $type): string# | The rest_base of a type. |
| method | links(Minn\Content\PostRecord $p): array# | The _links of a post in the view context. |
| method | modifiedUnsaved(Minn\Content\PostRecord $p, int $userId): bool# | Whether a live post carries an autosave newer than its saved revision. |
| method | lockHolder(int $id, int $userId): ?array# | The OTHER user holding a live _edit_lock (150 second window), or null. |
| method | editLinks(Minn\Content\PostRecord $p, int $userId, ?array $viewLinks = NULL): array# | The view links plus the caller's verbs and cap-gated wp:action-* entries. |
| static | date(string $mysql): string# | A MySQL datetime in the reference's ISO form. |
Internals 12
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | meta(Minn\Content\PostRecord $p, string $context): array# | The meta field: the keys registered to show in REST (probe rest-meta), or the footnotes alone without the runtime. @return array<string, mixed> | |||
| private | navigationView(Minn\Content\PostRecord $p): array# | A navigation menu is a post with almost nothing on it: no author, no excerpt, no featured image, no comments, no taxonomies, and so no class list either. What it does carry is a template field and the rendered menu. | |||
| private | blockView(Minn\Content\PostRecord $p): array# | A pattern (wp_block) is read by editors only, so its title and content come raw even in view context: no rendered title, no rendered content. It carries an excerpt, the footnotes meta, its pattern categories, and the sync status core registers beside meta. | |||
| private | viewFields(Minn\Content\PostRecord $p, ?Minn\Rest\Fields $fields = NULL): array# | The view-context object: the shared fields, then the type's own, then class_list and _links. | |||
| private | viewTerms(Minn\Content\PostRecord $p): array# | The taxonomies a non-page carries, each as [term_id, slug] pairs; the format terms only for posts. @return array<string, list<array{0: int, 1: string}>> | |||
| private | typeFields(Minn\Content\PostRecord $p, array $terms): array# | Pages carry parent and menu_order first; posts carry their term ids, and only the post type has sticky and format, among the shared fields.
@return array<string, mixed> | |||
| private | classList(Minn\Content\PostRecord $p, bool $thumbnail, array $terms): array# | The reference's class_list order: identity, type, status, format (posts only), password, thumbnail, hentry, then one class per term.
@return list<string> | |||
| private | format(array $formatTerms): string# |
| |||
| private | termLinks(string $type, int $id): ?array# | The taxonomy links a type carries: posts their categories and tags, patterns their pattern categories, pages and menus none. | |||
| private | editFields(Minn\Content\PostRecord $p, int $userId, ?Minn\Rest\Fields $fields = NULL): array# | The edit-context object for a given caller: raw+rendered dual fields, password, permalink_template, generated_slug, block_version, Minn Admin's registered list fields, and the cap-gated action links. | |||
| private | allow(int $id, ?int $userId = NULL): array# | What the caller may do to this post, which the reference reports in every context: a reader sees GET, an editor of the post sees the write verbs, and DELETE only when they may delete it too. @return list<string> | |||
| private | gmt(string $local, string $gmt): string# | A gmt timestamp for the wire: the stored one, or, when it is the draft zero, the local time converted through the site's offset, the way the reference derives it. |
Nothing matches.