API / Minn\Content / PostRecord

PostRecord final readonly class

Minn\Content\PostRecord · public/minn/src/Minn/Content/PostRecord.php · 156 lines · implements ArrayAccess

One row of the posts table, read by name. The columns keep their WordPress spelling on the way in (row()) and get plain names here: $post->title, $post->slug, $post->status. A record is built from a row and can hand the row back, so a writer or a REST shaper that still works in columns is not disturbed.

Array access is the migration bridge: code that still reads $post['post_title'] keeps working while it is moved over. New code reads the properties. The style suite counts the bracket reads down.

Constants and properties

propreadonly int $id

Promoted from the constructor.

propreadonly int $authorId

Promoted from the constructor.

propreadonly string $date

Promoted from the constructor.

propreadonly string $dateGmt

Promoted from the constructor.

propreadonly string $content

Promoted from the constructor.

propreadonly string $title

Promoted from the constructor.

propreadonly string $excerpt

Promoted from the constructor.

propreadonly string $status

Promoted from the constructor.

propreadonly string $commentStatus

Promoted from the constructor.

propreadonly string $pingStatus

Promoted from the constructor.

propreadonly string $password

Promoted from the constructor.

propreadonly string $slug

Promoted from the constructor.

propreadonly string $modified

Promoted from the constructor.

propreadonly string $modifiedGmt

Promoted from the constructor.

propreadonly int $parentId

Promoted from the constructor.

propreadonly string $guid

Promoted from the constructor.

propreadonly int $menuOrder

Promoted from the constructor.

propreadonly string $type

Promoted from the constructor.

propreadonly string $mimeType

Promoted from the constructor.

propreadonly int $commentCount

Promoted from the constructor.

privatereadonly array $row

Promoted from the constructor.

Public

new__construct(int $id, int $authorId, string $date, string $dateGmt, string $content, string $title, string $excerpt, string $status, string $commentStatus, string $pingStatus, string $password, string $slug, string $modified, string $modifiedGmt, int $parentId, string $guid, int $menuOrder, string $type, string $mimeType, int $commentCount, array $row)#
$rowarray<string, mixed>
staticfromRow(array $row): self#

A record from a posts row; a missing column reads as empty.

$rowarray<string, mixed>a posts-table row, joined columns welcome
staticfromRows(array $rows): array#

A record for every row, in order.

$rowslist<array<string, mixed>>@return list<self>
methodrow(): array#

The stored row, for the writers and shapers that still spell columns.

The row as the table holds it, joined columns and all.

methodstatus(): ?Minn\Content\PostStatus#

The status as an enum case, or null for a status only a plugin knows.

methodisPublished(): bool#

Published, and so public.

methodisLive(): bool#

Publish, future or private: it counts, it links, it is not a draft.

methodisTrashed(): bool#

In the trash.

methodisProtected(): bool#

Behind a password.

methodisPage(): bool#

A page.

methodisAttachment(): bool#

An attachment.

methodcolumn(string $name): mixed#

One stored column by its database name, or null.

A joined column, or any column by its table name.

methodoffsetExists(mixed $offset): bool#

The migration bridge: the record answers to its column names the way the row did.

methodoffsetGet(mixed $offset): mixed#

The migration bridge: one column by its stored name, or null.

methodoffsetSet(mixed $offset, mixed $value): never#

Records are read-only; writes go through the repository.

methodoffsetUnset(mixed $offset): never#

Records are read-only; writes go through the repository.