src/Controller/Back/DashboardController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Back;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. /**
  7.  * @Route("/admin")
  8.  */
  9. class DashboardController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/dashboard", name="back_dashboard")
  13.      */
  14.     public function dashboard()
  15.     {
  16.         return $this->render('back/dashboard.html.twig');
  17.     }
  18.     /**
  19.      * @Route("/component/darkmode", name="back_darkmode")
  20.      */
  21.     public function darkMode(SessionInterface $session)
  22.     {
  23.         if ($session->get('darkmode')) {
  24.             $session->remove('darkmode');
  25.             return $this->json([
  26.                 'darkmode' => false
  27.             ]);
  28.         }
  29.         $session->set('darkmode'true);
  30.         return $this->json([
  31.             'darkmode' => true
  32.         ]);
  33.     }
  34. }