src/Controller/LayoutController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use phpDocumentor\Reflection\Types\This;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class LayoutController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/", name="app_index")
  12.      */
  13.     public function index(): Response
  14.     {
  15.         return $this->layout([
  16.             'title'=>'Welcome'
  17.         ]);
  18.     }
  19.     /**
  20.      * @Route("/customers", name="customers_layout")
  21.      */
  22.     public function customers_list(): Response
  23.     {
  24.         return $this->layout([
  25.             'title'=>'Customers'
  26.         ]);
  27.     }
  28.     /**
  29.      * @Route("/customer/{slug}/{tabindex}", name="customer_layout", defaults={"slug":null, "tabindex":null}, methods={"GET"})
  30.      */
  31.     public function customer_layout(): Response
  32.     {
  33.         return $this->layout([
  34.             'title'=>'Customer'
  35.         ]);
  36.     }
  37.     /**
  38.      * @Route("/workers/{slug}", name="workers_layout", defaults={"slug":null}, methods={"GET"})
  39.      * slug for customer
  40.      */
  41.     public function workers_layout(): Response
  42.     {
  43.         return $this->layout([
  44.             'title'=>'Workers list'
  45.         ]);
  46.     }
  47.     /**
  48.      * @Route("/worker/{slug}/{tabindex}", name="worker_layout", defaults={"slug":null, "tabindex":null}, methods={"GET"})
  49.      * slug for worker
  50.      */
  51.     public function worker_layout(): Response
  52.     {
  53.         return $this->layout([
  54.             'title'=>'Worker manage'
  55.         ]);
  56.     }
  57.     /**
  58.      * @Route("/projects", name="projects_list", methods={"GET"})
  59.      */
  60.     public function projects_list(): Response
  61.     {
  62.         return $this->layout([
  63.             'title'=>'Projects list'
  64.         ]);
  65.     }
  66.     /**
  67.      * @Route("/project/{key}", name="project", defaults={"key": null}, methods={"GET"})
  68.      */
  69.     public function project(): Response
  70.     {
  71.         return $this->layout([
  72.             'title'=>'Project manage'
  73.         ]);
  74.     }
  75.     /**
  76.      * @Route("/users", name="app_users")
  77.      */
  78.     public function users(): Response
  79.     {
  80.         return $this->layout([
  81.             'title'=>'Users list'
  82.         ]);
  83.     }
  84.     private function layout(array $params): Response{
  85.         $params = (object)$params;
  86.         return $this->render('layout/index.html.twig', [
  87.             'title'=> $params->title
  88.         ]);
  89.     }
  90.     /**
  91.      * @Route("/login", name="app_login")
  92.      * @return Response
  93.      */
  94.     public function login(): Response{
  95.         if( $this->getUser() ){
  96.             return $this->redirectToRoute('customers_layout');
  97.         }
  98.         return $this->render('security/index.html.twig', [
  99.             'title'=> 'Login Page'
  100.         ]);
  101.     }
  102.     /**
  103.      * @Route("/logout", name="app_logout")
  104.      */
  105.     public function logout(): Response
  106.     {
  107.         #throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  108. //        if( !$this->getUser() ){
  109. //            // throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  110. //            return $this->render('security/index.html.twig', [
  111. //                'title'=> 'Login Page'
  112. //            ]);
  113. //        }
  114.         return $this->redirectToRoute('app_login');
  115.     }
  116.     /**
  117.      * @Route("/password-forgot", name="app_password_forgot")
  118.      */
  119.     public function passwordForgot(): Response
  120.     {
  121.         if( !$this->getUser() ){
  122.             // throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  123.             return $this->render('security/index.html.twig', [
  124.                 'title'=> 'Login Page'
  125.             ]);
  126.         }
  127.         return $this->redirectToRoute('customers_layout');
  128.     }
  129. }