API / Minn\Rest / Subjects

Subjects final readonly class

Minn\Rest\Subjects · public/minn/src/Minn/Rest/Subjects.php · 53 lines

Whether the record a route capture names exists, for the policy gate to ask before it judges the caller. A post kind reads its type from the {base} capture when the route has one, a term kind its taxonomy; the fixed kinds name their own. Status is not consulted: a trashed post exists, and what the caller may do with it is the policy's question.

Constants and properties

privatePOST_TYPES = array ( 'posts' => 'post', 'pages' => 'page', 'blocks' => 'wp_block', 'media' => 'attachment', 'navigation' => 'wp_navigation', 'menu-items' => 'nav_menu_item', )
privateTAXONOMIES = array ( 'categories' => 'category', 'tags' => 'post_tag', 'wp_pattern_category' => 'wp_pattern_category', )
privatereadonly Minn\Db $db

Promoted from the constructor.

Public

new__construct(Minn\Db $db)#
methodexists(Minn\Http\Subject $subject, int $id, array $captures): bool#

Whether the record exists.

$capturesarray<string, string>the route's captures, for the {base} a kind reads
methodpostOfType(int $id, string $type): bool#

Whether a post of the type exists.

methodtermOf(int $id, string $taxonomy): bool#

Whether a term of the taxonomy exists.

Internals 2

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatepost(int $id, string $type): bool#
privateterm(int $id, string $taxonomy): bool#