Resolver final readonly class
Minn\Front\Resolver · public/minn/src/Minn/Front/Resolver.php · 325 lines
Turns a public URL into a Resolution the way the reference's request parse does: the root by its query string, any other path by the first of the site's rewrite rules it fits (Front\RuleTable), whose query vars name what it is (Front\RuleRoutes). What is left here are the reference's canonical answers around that (redirect_canonical, wp_old_slug_redirect):
- Unpaged content and archives without a trailing slash redirect to the slashed form, as typed (case kept), as do an embed's and an endpoint's addresses; paged views, search, and 404s do not. - Query-var forms redirect to the pretty form when the target is public: a single's (?p=, ?page_id=, ?name=, ?pagename=; SingleQueries) and an archive's (?m=, ?year=, ?author=, one taxonomy's term; QueryMoves), unless a search is asked for. - A single asked for under a category it is not in (where the structure names one), or with an old-style page number, moves to its own address; a trackback address goes to the post; the front page answers only at the root. - A name the site no longer has: the post that used to have it, else the closest published page or post whose name starts with it, pages before posts, newest first. Archives never guess. - Non-public posts are 404 to anonymous readers and served to a reader who can edit them.
Constants and properties
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Posts $posts | Promoted from the constructor. |
| private | readonly Minn\Content\Terms $terms | Promoted from the constructor. |
| private | readonly Minn\Front\Permalinks $permalinks | Promoted from the constructor. |
| private | readonly Closure $canReadUnpublished | Promoted from the constructor. |
| private | readonly int $perPage | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Minn\Content\Posts $posts, Minn\Content\Terms $terms, Minn\Front\Permalinks $permalinks, Closure $canReadUnpublished, int $perPage)# |
| |||
| static | fromDb(Minn\Db $db, Closure $canReadUnpublished): self# | A resolver over the site's own settings. | |||
| method | permalinks(): Minn\Front\Permalinks# | The link builder. | |||
| method | perPage(): int# | Posts per page. | |||
| method | resolve(Minn\Http\Request $request, ?Minn\Front\Redirects $mode = NULL): Minn\Front\Resolution# | $canonical mirrors the reference's redirect_canonical rule: only GET and HEAD get trailing-slash, pretty-URL, and 404-guess redirects; every other method renders what the query alone finds, as typed. | |||
| static | viewableTypes(): array# | The post types a guess looks among: those a reader can view that searches include. @return list<string> |
Internals 12
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | resolvePath(Minn\Http\Request $request, Minn\Front\Redirects $redirects): Minn\Front\Resolution# | ||||
| private | canonical(Minn\Front\Resolution $resolution, Minn\Http\Request $request, string $path, Minn\Front\Redirects $redirects): Minn\Front\Resolution# | The canonical answer for what a path's rule found: the found thing as typed, or where it should be asked for instead. | |||
| private | pagedMove(Minn\Front\Resolution $resolution, Minn\Http\Request $request, string $path): ?Minn\Front\Resolution# | A listing page that is not one: a post (not a page) asked for with a page of listing (/hello-world/page/2/, ?paged=2) moves to the post, the rest of the query along but that; the first page of any listing or page drops its /page/1/. Null when neither applies. | |||
| private | missing(array $vars, Minn\Front\Redirects $redirects): ?Minn\Front\Resolution# | A name the site does not have: where the post that used to have it lives now (as typed too, where wp_old_slug_redirect makes the move), else, on a single's rule, the closest match. Null when there is none.
| |||
| private | endpointIn(array $vars): bool# | Whether the vars carry a rewrite endpoint's var. @param array<string, string> $vars
| |||
| private | segments(string $path): array# | @return list<string> | |||
| private | resolveQueryVars(Minn\Http\Request $request, Minn\Front\Redirects $redirects): Minn\Front\Resolution# | The root by its query string, in the grammar a path's rule vars are read in (RuleRoutes): a single's vars first (SingleQueries makes their moves), then the archive forms that move (QueryMoves), then what the vars name, an id form read as the name it stands for. | |||
| private | rootVars(Minn\Http\Request $request): ?array# | The root's query vars as RuleRoutes reads them: the query string's (error is not the query string's to set), ?cat= as the category's slug, ?author= as the author's name, ?m= as its year, month and day. Null when an id names nothing the site has. @return array<string, string>|null | |||
| private | archives(): Minn\Front\ArchiveAddresses# | The archives a request may stand for. | |||
| private | attachments(): Minn\Front\AttachmentAddresses# | The addresses an attachment's page answers to. | |||
| private | elsewhere(): Minn\Front\SingleAddresses# | The addresses a single answers to besides its own. | |||
| private | readable(Minn\Content\PostRecord $post): bool# |
Nothing matches.