<?php

use MintyPHP\Buffer;
use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\Service\Access\UiAccessService;
use MintyPHP\Service\Access\UiCapabilityMap;
use MintyPHP\Support\Guard;

$session = app(SessionStoreInterface::class)->all();
Guard::requireAbilityOrForbidden(\MintyPHP\Service\Access\OperationsAuthorizationPolicy::ABILITY_ADMIN_STATS_VIEW);

$viewData = app(\MintyPHP\Service\Stats\AdminStatsViewDataService::class)->build();
if ($viewData) {
    extract($viewData, EXTR_SKIP);
}
$currentUserId = (int) ($session['user']['id'] ?? 0);
$viewAuth['page'] = app(UiAccessService::class)->pageCapabilities($currentUserId, UiCapabilityMap::PAGE_STATS_INDEX);

Buffer::set('title', t('Statistics'));
