src/Controller/AdminController.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Controller\FonctionsController;
  4. use App\Controller\StatsController;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Doctrine\ORM\EntityManagerInterface;
  10. use Symfony\Component\Mailer\MailerInterface;
  11. use Symfony\Component\Mime\Email;
  12. use Symfony\Component\Mime\Address;
  13. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  14. use phpDocumentor\Reflection\Project;
  15. /**
  16.  * @Route("/admin")
  17.  */
  18. class AdminController extends AbstractController
  19. {
  20.     public function __construct(FonctionsController $foncStatsController $statsMailerInterface $mailerEntityManagerInterface $em)
  21.     {
  22.         $this->fonc $fonc;
  23.         $this->stats $stats;
  24.         $this->mailer $mailer;
  25.         $this->em $em;
  26.     }
  27.     /**
  28.      * @Route("/", name="admin_index")
  29.      */
  30.     public function admin_index(UserInterface $user): Response
  31.     {
  32.         // A. statistiques et securité
  33.         $this->stats->enregistreStat("admin_index");
  34.         // B stats
  35.         $visiteJour $this->stats->recupVisiteJour();
  36.         // 1. affiche la page
  37.         return $this->render('admin/index.html.twig', [
  38.             'controller_name' => 'admin_index',
  39.             'user' => $user,
  40.             'visiteJour' => $visiteJour,
  41.         ]);
  42.     }
  43.     /**
  44.      * @Route("/ff/{slug}", name="admin_slug")
  45.      */
  46.     public function admin_slug($slug): Response
  47.     {
  48.         // 1. recupère adresse url
  49.         $adresse $_SERVER['REQUEST_URI'];
  50.         
  51.         // 2. recupere info de l objet page
  52.         $objPage = [];
  53.         $objPage["titre"] = "Tableau de bord";
  54.         $objPage["template"] = 1;
  55.         $objPage["description"] = "Tableau de bord de l'administration";
  56.         $objPage["keywords"] = "Blog, Boutique, Clients";
  57.         $objPage["userCrea"] = 1;
  58.         $objPage["userModif"] = 1;
  59.         $objPage["userModif"] = 1;
  60.         $objPage["copyright"] = "";
  61.         // 3. recupere info de l objet template
  62.         $objTemplate = [];
  63.         $objTemplate["path"] = "admin/baseAdmin.html.twig";
  64.         $objTemplate["favicon"] = "docs/favicon/favicon.png";
  65.         $objTemplate["copyright"] = "© template 2023";
  66.         $objTemplate["bootstrap"] = "© template 2023";
  67.         // 4. recupere info de l objet user
  68.         $objUser = [];
  69.         $objUser["username"] = "Stef";
  70.         // 5. affiche la page
  71.         return $this->render('admin/pages/index.html.twig', [
  72.             'controller_name' => 'admin_index',
  73.             'objPage' => $objPage,
  74.             'objTemplate' => $objTemplate,
  75.             'objUser' => $objUser,
  76.         ]);
  77.     }
  78. }