murph-skeleton/core/Controller/Analytic/AnalyticController.php

39 lines
1.1 KiB
PHP
Raw Normal View History

2022-02-20 21:05:46 +01:00
<?php
namespace App\Core\Controller\Analytic;
use App\Core\Analytic\DateRangeAnalytic;
2022-02-21 09:09:57 +01:00
use App\Core\Entity\Site\Node;
2022-02-20 21:05:46 +01:00
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/admin/analytic")
*/
class AnalyticController extends AbstractController
{
/**
* @Route("/stats/{node}/{range}", name="admin_analytic_stats")
*/
public function stats(Node $node, DateRangeAnalytic $analytic, string $range = '7days'): Response
2022-02-20 21:05:46 +01:00
{
if (!in_array($range, ['7days', '30days', '90days', '1year'])) {
throw $this->createNotFoundException();
}
$analytic
2022-02-21 09:09:57 +01:00
->setDateRange(new \DateTime('now - '.$range), new \DateTime())
->setNode($node)
;
2022-02-20 21:05:46 +01:00
return $this->render('@Core/analytic/stats.html.twig', [
'range' => $range,
'views' => $analytic->getViews(),
'pathViews' => $analytic->getPathViews(),
'referers' => $analytic->getReferers(),
2022-02-20 21:05:46 +01:00
'node' => $node,
]);
}
}