API / Minn\Front / Archives

Archives final readonly class

Minn\Front\Archives · public/minn/src/Minn/Front/Archives.php · 63 lines

The archive periods wp_get_archives lists: months, years, days and weeks that hold a published post of a type, newest first, each with its post count and archive URL, plus the post-by-post and alphabetical listings. Labels come from the caller's date formatter so the site's locale and week start apply; the week label joins the week's first and last day.

Constants and properties

privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Closure $date

Promoted from the constructor.

privatereadonly Closure $dateLink

Promoted from the constructor.

privatereadonly Closure $week

Promoted from the constructor.

Public

new__construct(Minn\Content\Posts $posts, Closure $date, Closure $dateLink, Closure $week)#
$dateClosure(string, string): stringformats a MySQL datetime with a PHP date format
$dateLinkClosure(int, ?int, ?int): stringthe year, month, or day archive URL
$weekClosure(string): array{start: int, end: int}the week's first and last second around a datetime
methodperiods(string $granularity, string $type, string $order, int $limit, Closure $weekLink, string $where = '', string $join = ''): array#

The periods of one granularity: monthly, yearly, daily, or weekly; a WHERE and JOIN given are the query's (Posts::archiveBuckets).

@return list<array{period: array{year: int, month: int, day: int, week: int}, url: string, text: string, count: int}>
methodposts(string $type, string $orderBy, string $order, int $limit, Closure $title, Closure $link, string $where = '', string $join = ''): array#

The posts themselves, by date or by title.

$titleClosure(int, string): stringthe post's title as displayed (or its id when empty)
$linkClosure(int): string
@return list<array{url: string, text: string, count: int, id: int}>

Internals 1

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

privateweekPeriod(array $bucket, Closure $weekLink): array#
$bucketarray{year: int, week: int, first: string, count: int}
@return array{url: string, text: string, count: int}