src/Controller/Admin/DashboardController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  7. use App\Service\Admin\AdminStatsService;
  8. /**
  9.  * @Route("/admin")
  10.  * @IsGranted("ROLE_ADMIN")
  11.  */
  12. class DashboardController extends AbstractController
  13. {
  14.     private $statsService;
  15.     public function __construct(AdminStatsService $statsService)
  16.     {
  17.         $this->statsService $statsService;
  18.     }
  19.     /**
  20.      * @Route("/", name="app_admin_root")
  21.      */
  22.     public function indexRedirect(): Response
  23.     {
  24.         return $this->redirectToRoute('app_admin_dashboard');
  25.     }
  26.     /**
  27.      * @Route("/dashboard", name="app_admin_dashboard")
  28.      */
  29.     public function index(): Response
  30.     {
  31.         $stats $this->statsService->getGlobalStats();
  32.         return $this->render('admin/dashboard/index.html.twig', [
  33.             'stats' => $stats
  34.         ]);
  35.     }
  36. }