PostInsert final readonly class
Minn\Runtime\PostInsert · public/minn/src/Minn/Runtime/PostInsert.php · 213 lines
The decisions behind wp_insert_post: which columns a postarr fills, when the post counts as empty, the status a publish request lands in, the dates and the slug, the categories a new post gets. The rows are written by Content\PostWriter; the facade fires the hooks around each step.
Constants and properties
| private | COLUMNS = array ( 0 => 'post_author', 1 => 'post_date', 2 => 'post_date_gmt', 3 => 'post_content', 4 => 'post_title', 5 => 'post_excerpt', 6 => 'post_status', 7 => 'comment_status', 8 => 'ping_status', 9 => 'post_password', 10 => 'post_name', 11 => 'to_ping', 12 => 'pinged', 13 => 'post_modified', 14 => 'post_modified_gmt', 15 => 'post_content_filtered', 16 => 'post_parent', 17 => 'guid', 18 => 'menu_order', 19 => 'post_type', 20 => 'post_mime_type', ) | |
| private | readonly Minn\Content\PostWriter $writer | Promoted from the constructor. |
| private | readonly int $userId | Promoted from the constructor. |
| private | readonly Closure $discussion | Promoted from the constructor. |
| private | readonly Closure $supports | Promoted from the constructor. |
| private | readonly Closure $canPublish | Promoted from the constructor. |
| private | readonly Closure $gmtFromDate | Promoted from the constructor. |
| private | readonly Closure $now | Promoted from the constructor. |
Public
| new | __construct(Minn\Content\PostWriter $writer, int $userId, Closure $discussion, Closure $supports, Closure $canPublish, Closure $gmtFromDate, Closure $now)# |
| |||||||||||||||
| method | columns(array $postarr, ?array $existing): array# | The columns the posts table takes, filled from a postarr, with a new post's defaults. @param array<string, mixed>|null $existing @return array<string, string>
| |||||||||||||||
| method | isEmpty(array $columns, ?array $existing): bool# | A post with nothing in title, content, and excerpt is empty when its type supports all three. @param array<string, mixed>|null $existing
| |||||||||||||||
| method | resolve(array $columns, ?array $existing): array# | The columns as they will be written: the status a request lands in (attachments inherit, unprivileged publishes pend, a future date schedules), the dates, the slug (sanitized; not yet free), and the integer columns.
@return array<string, string> | |||||||||||||||
| method | persist(array $columns, ?int $existingId): int# | Writes the resolved columns. @return int the post id | |||||||||||||||
| static | unwritten(array $columns, ?int $existingId): Minn\Objects\Errors# | The error for a post the database door would not write, its text not what the table holds (probe refused-writes): an insert's or an update's (a post that already has an id), naming the first such column.
| |||||||||||||||
| method | fillGuid(int $id, array $columns, Closure $guid): void# | Gives a new post written without a guid its permalink as one, once its slug, terms and meta are in. | |||||||||||||||
| static | categories(array $postarr, int $id, string $type, string $status, bool $update, array $taxonomies): ?array# | The categories a saved post hands wp_set_post_categories: none when its type has no categories (null); an update that names none keeps the ones it has; otherwise the ones given, each empty value dropped. None left is the default category for a post that is not an auto-draft, else an empty list (which wp_set_post_categories decides).
@return array<mixed>|null | |||||||||||||||
| static | categoryIds(mixed $categories, mixed $status, mixed $type, mixed $append): array# | The category ids wp_set_post_categories sets, and whether they add to the post's: none given (null or an empty list) is the default category in place of the post's, for a post of a type that takes one (posts and the types default_category_post_types adds) that is not an auto-draft; a lone blank string is nothing to set (null ids); else each value as an id, any that is none dropped. @return array{0: list<int>|null, 1: bool} |
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | type(array $columns, ?array $existing): string# |
Nothing matches.