API / Minn\Theme / MainQueryBridge

MainQueryBridge final readonly class

Minn\Theme\MainQueryBridge · public/minn/src/Minn/Theme/MainQueryBridge.php · 136 lines

Stands the main query for a themed page and runs the front-end steps around it as WP::main does (FrontLifecycle): the request parsed, the main query through WP_Query (so pre_get_posts and every posts_* filter shape it), the 404 decision, the globals, the headers, then "wp" and template_redirect. A listing's posts are the query's, and so is the 404 for an empty page past the first or an empty date; a single post the query does not find (a preview, a draft its author reads) is the one the engine resolved. When a plugin takes the parse over no query runs, as on the reference, and the page stands empty.

Constants and properties

privateLISTINGS = array ( 0 => \Minn\Front\Kind::Home, 1 => \Minn\Front\Kind::Category, 2 => \Minn\Front\Kind::Tag, 3 => \Minn\Front\Kind::Taxonomy, 4 => \Minn\Front\Kind::PostTypeArchive, 5 => \Minn\Front\Kind::Author, 6 => \Minn\Front\Kind::Date, 7 => \Minn\Front\Kind::Search, )
privatereadonly int $perPage

Promoted from the constructor.

Public

new__construct(int $perPage)#
methodstand(Minn\Front\Resolution $resolution, array $extra = array ( )): Minn\Content\Page#

The page of posts a resolution shows, through the runtime's main query; the variables a request adds of its own (a feed's) win.

$extraarray<string, mixed>
staticverdict(Minn\Front\Resolution $resolution): Minn\Front\Resolution#

The resolution as the main query left it: a 404 when the query decided one (an empty page past the first, an empty date), with the vars it was asked under.

methodperPage(): int#

Posts per page.

Internals 4

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

privatevars(Minn\Front\Resolution $resolution): array#

The variables the request stands on before the parse runs (and in its place, when a plugin takes the parse over): the matched rule's, the posts page by its id.

@return array<string, mixed>
privatepostVars(Minn\Front\Resolution $resolution): array#

The variables that name the post the engine resolved, for a page the query found nothing to stand on (a preview, a draft its author reads).

@return array<string, mixed>
privatequeried(Minn\Front\Resolution $resolution, array $vars): Minn\Content\Page#

The main query for these variables: a listing is its posts; any other page stands on the post the engine resolved when the query has none.

$varsarray<string, mixed>
privateseeded(Minn\Front\Resolution $resolution, array $vars): Minn\Content\Page#

The query globals seeded with no posts of their own (a single the query did not find is looked up by its vars), when no query ran or it found nothing to stand on. @param array<string, mixed> $vars

$varsarray<string, mixed>