API / Minn\Content / PostSlugs

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

privateLENGTH = 200
privateFEEDS = array ( 0 => 'feed', 1 => 'rdf', 2 => 'rss', 3 => 'rss2', 4 => 'atom', )
privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Content\Site $site)#
methodunique(string $slug, int $excludeId, string $type, int $parent, ?Closure $bad = NULL): string#

The slug, or its first free numbered form.

$badClosure(string): bool|nulla plugin's say over the slug asked for (the bad-slug filters), asked last

Internals 3

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

privatetaken(string $slug, int $excludeId, string $type, int $parent): bool#

Whether another post in the slug's scope has it.

privatereserved(string $slug, int $excludeId, string $type): bool#

Whether the slug names something else: a feed, embeds, a page number, a date archive.

privatehierarchical(string $type): bool#