API / Minn\Admin / Dashboard

Dashboard final readonly class

Minn\Admin\Dashboard · public/minn/src/Minn/Admin/Dashboard.php · 273 lines

The overview payload: stat cards, the activity chart, and the recent activity feed, plus the per-bar activity drill-down.

Constants and properties

privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Content\Users $users

Promoted from the constructor.

privatereadonly Minn\Auth\Capabilities $capabilities

Promoted from the constructor.

privatereadonly Minn\Admin\ActivityChart $chart

Promoted from the constructor.

privatereadonly Minn\Admin\ActivityFeed $feed

Promoted from the constructor.

privatereadonly string $uploadsDir

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Content\Site $site, Minn\Content\Users $users, Minn\Auth\Capabilities $capabilities, Minn\Admin\ActivityChart $chart, Minn\Admin\ActivityFeed $feed, string $uploadsDir)#
methodoverview(int $userId, int $days): array#

The stat cards, the metric catalog and layout, the chart, and the feed.

methodmetricLayout(int $userId, array $catalog, array $stats): array#

Which cards show: the user's saved picks over the site default over the built-in layout, unknown keys dropped and slots refilled.

$cataloglist<array>
$statslist<array>
@return array{keys: list<string>, defaults: list<string>, custom: bool}
staticcleanMetricKeys(mixed $keys): array#

At most six unique sanitize_key metric ids; anything else drops.

methodactivity(int $userId, string $from, string $to): array#

The events behind one chart bar, (from, to] GMT.

Internals 9

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

privatepostsCard(array $posts, int $userId): array#
$postsarray<string, int>
privatepagesCard(array $pages): array#
$pagesarray<string, int>
privateusersCard(): array#
privatecommentsCard(array $comments, int $userId): array#
$commentsarray<string, int>
privatemediaCard(array $media, int $userId): array#
$mediaarray<string, int>
privatemetricCatalog(int $userId, array $stats, array $posts, array $pages, array $comments, array $media): array#

The full metric catalog behind the Overview cards: the default layout first, then every cap-gated card the caller may pick. The store group needs the WooCommerce runtime and is honestly absent.

$statslist<array>
$postsarray<string, int>
$pagesarray<string, int>
$commentsarray<string, int>
$mediaarray<string, int>
@return list<array>
privateoverlayMetricKeys(array $saved, array $fallback, array $allowed): array#

Overlay saved keys onto a fallback of the same length, dropping keys outside $allowed and de-duplicating left to right.

$savedlist<string>
$fallbacklist<string>
$allowedarray<string, true>
@return list<string>
privatestatusCounts(string $type): array#
@return array<string, int> counts by status for one post type
privatecommentCounts(): array#
@return array{approved: int, moderated: int}