PostEvents final readonly class
Minn\Runtime\PostEvents · public/minn/src/Minn/Runtime/PostEvents.php · 165 lines
What the reference's REST controllers tell plugins about a post they write, for the engine's own controllers: the same actions in the same order with the same arguments, fired through the facade's lifecycle functions so the facade's own writes say the same (contracts/runtime.md "Writes tell plugins"). Without a booted runtime every method does nothing, so a write with no plugins loaded is exactly what it was.
Public
| method | deleteForGood(int $id): mixed# | A post deleted for good through the reference's own deletion, so its hooks fire and its children (revisions, autosaves) go with it: the one path every permanent delete takes. Deleting needs the facade, so unlike the events it runs only under a booted runtime, which the engine's write routes are. Answers what the deletion answered. | |||
| method | trash(int $id): mixed# | A post (an attachment too) sent to the trash through the reference's own trashing, as deleteForGood deletes. | |||
| method | live(): bool# | Whether plugins are loaded to be told anything. | |||
| method | beforeSave(array $columns, ?Minn\Content\PostRecord $existing): void# | Before the row is written: pre_post_insert for a new post, pre_post_update for one that exists. @param array<string, mixed> $columns
| |||
| method | saved(int $id, ?Minn\Content\PostRecord $before): void# | Once the row is written: the caches, the status transition, the edit actions of an update, the save actions. | |||
| method | ensureCategory(Minn\Content\PostWriter $writer, int $id): void# | A post keeps a category through every save, the default when it has none: through wp_set_post_categories with plugins loaded (which tells them, set_object_terms included), quietly without. | |||
| method | applyTerms(Minn\Content\PostWriter $writer, int $id, array $body, string $type = ''): void# | The terms a REST body names, set through wp_set_object_terms with plugins loaded, quietly without: a plugin's type takes its own REST taxonomies under their REST bases (probe rest-plugin-types).
| |||
| method | applyMeta(Minn\Content\PostWriter $writer, int $id, array $body, string $type): void# | The meta a REST body names: through the registered keys with plugins loaded (probe rest-meta; a plugin's type only when it supports custom fields), core's own written directly without.
| |||
| method | attachmentGenerated(int $id, string $file): void# | A new attachment's metadata made by the runtime, as the reference's REST upload makes it: wp_generate_attachment_metadata over the stored file (the sizes cut with the attachment's id, the metadata stored as each one lands, so an optimiser hooked there finds it), then wp_update_attachment_metadata. Every upload has some: an image its sizes, a PDF its previews, any file its size (probe hook-inputs-2). | |||
| method | restInserted(int $id, Minn\Http\Request $request, ?Minn\Content\PostRecord $before): void# | rest_insert_{type}, before the request's own terms and fields are applied; a post with no $before is a new one. | |||
| method | restAfterInsert(int $id, Minn\Http\Request $request, ?Minn\Content\PostRecord $before): void# | rest_after_insert_{type}, once the request's terms and fields are in; a post with no $before is a new one. | |||
| method | afterInsert(int $id, ?Minn\Content\PostRecord $before): void# | wp_after_insert_post, last; the revision of an update is saved from it. | |||
| method | restDeleted(Minn\Content\PostRecord $post, array $data, Minn\Http\Request $request): void# | rest_delete_{type}, after a trash or a delete, with the post as it was answered and the response. @param array<string, mixed> $data
|
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | rest(string $prefix, int $id, Minn\Http\Request $request, ?Minn\Content\PostRecord $before): void# | One of the two REST insert actions, with the post as it stands and the request. |
| private | wpPost(?Minn\Content\PostRecord $post): ?WP_Post# | A record as the runtime's post object, for a state the database no longer holds. |
Nothing matches.