<?php
namespace App\Controller;
use App\Controller\FonctionsController;
use App\Controller\StatsController;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Address;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use phpDocumentor\Reflection\Project;
/**
* @Route("/admin")
*/
class AdminController extends AbstractController
{
public function __construct(FonctionsController $fonc, StatsController $stats, MailerInterface $mailer, EntityManagerInterface $em)
{
$this->fonc = $fonc;
$this->stats = $stats;
$this->mailer = $mailer;
$this->em = $em;
}
/**
* @Route("/", name="admin_index")
*/
public function admin_index(UserInterface $user): Response
{
// A. statistiques et securité
$this->stats->enregistreStat("admin_index");
// B stats
$visiteJour = $this->stats->recupVisiteJour();
// 1. affiche la page
return $this->render('admin/index.html.twig', [
'controller_name' => 'admin_index',
'user' => $user,
'visiteJour' => $visiteJour,
]);
}
/**
* @Route("/ff/{slug}", name="admin_slug")
*/
public function admin_slug($slug): Response
{
// 1. recupère adresse url
$adresse = $_SERVER['REQUEST_URI'];
// 2. recupere info de l objet page
$objPage = [];
$objPage["titre"] = "Tableau de bord";
$objPage["template"] = 1;
$objPage["description"] = "Tableau de bord de l'administration";
$objPage["keywords"] = "Blog, Boutique, Clients";
$objPage["userCrea"] = 1;
$objPage["userModif"] = 1;
$objPage["userModif"] = 1;
$objPage["copyright"] = "";
// 3. recupere info de l objet template
$objTemplate = [];
$objTemplate["path"] = "admin/baseAdmin.html.twig";
$objTemplate["favicon"] = "docs/favicon/favicon.png";
$objTemplate["copyright"] = "© template 2023";
$objTemplate["bootstrap"] = "© template 2023";
// 4. recupere info de l objet user
$objUser = [];
$objUser["username"] = "Stef";
// 5. affiche la page
return $this->render('admin/pages/index.html.twig', [
'controller_name' => 'admin_index',
'objPage' => $objPage,
'objTemplate' => $objTemplate,
'objUser' => $objUser,
]);
}
}