PostSlugs final readonly class
Minn\Content\PostSlugs · public/minn/src/Minn/Content/PostSlugs.php · 75 lines
Which slug a live post may take beside the others, as the reference settles it (probe insert-defaults). A flat type's slugs are its own: a post, a page and a plugin's type may share one. A hierarchical type's are its own and its attachments' under the same parent. An attachment's are every post's. Never free: the feed names and embed; for a hierarchical type, a number or a page number (2, page2); for posts, a number a date archive would answer to: any number when the permalink structure begins with the post name, a month (below 13) when the post name follows the year, a day (below 32) when it follows the month. A post keeps a number it already has. A taken slug gets the first free -2, -3 form, cut (and stripped of a trailing hyphen) to fit the column's 200 characters. The slug is taken as given, not sanitized.
Constants and properties
| private | LENGTH = 200 | |
| private | FEEDS = array ( 0 => 'feed', 1 => 'rdf', 2 => 'rss', 3 => 'rss2', 4 => 'atom', ) | |
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Site $site | Promoted from the constructor. |
Public
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | taken(string $slug, int $excludeId, string $type, int $parent): bool# | Whether another post in the slug's scope has it. |
| private | reserved(string $slug, int $excludeId, string $type): bool# | Whether the slug names something else: a feed, embeds, a page number, a date archive. |
| private | hierarchical(string $type): bool# |
Nothing matches.