<?php
namespace App\Controller;
use phpDocumentor\Reflection\Types\This;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class LayoutController extends AbstractController
{
/**
* @Route("/", name="app_index")
*/
public function index(): Response
{
return $this->layout([
'title'=>'Welcome'
]);
}
/**
* @Route("/customers", name="customers_layout")
*/
public function customers_list(): Response
{
return $this->layout([
'title'=>'Customers'
]);
}
/**
* @Route("/customer/{slug}/{tabindex}", name="customer_layout", defaults={"slug":null, "tabindex":null}, methods={"GET"})
*/
public function customer_layout(): Response
{
return $this->layout([
'title'=>'Customer'
]);
}
/**
* @Route("/workers/{slug}", name="workers_layout", defaults={"slug":null}, methods={"GET"})
* slug for customer
*/
public function workers_layout(): Response
{
return $this->layout([
'title'=>'Workers list'
]);
}
/**
* @Route("/worker/{slug}/{tabindex}", name="worker_layout", defaults={"slug":null, "tabindex":null}, methods={"GET"})
* slug for worker
*/
public function worker_layout(): Response
{
return $this->layout([
'title'=>'Worker manage'
]);
}
/**
* @Route("/projects", name="projects_list", methods={"GET"})
*/
public function projects_list(): Response
{
return $this->layout([
'title'=>'Projects list'
]);
}
/**
* @Route("/project/{key}", name="project", defaults={"key": null}, methods={"GET"})
*/
public function project(): Response
{
return $this->layout([
'title'=>'Project manage'
]);
}
/**
* @Route("/users", name="app_users")
*/
public function users(): Response
{
return $this->layout([
'title'=>'Users list'
]);
}
private function layout(array $params): Response{
$params = (object)$params;
return $this->render('layout/index.html.twig', [
'title'=> $params->title
]);
}
/**
* @Route("/login", name="app_login")
* @return Response
*/
public function login(): Response{
if( $this->getUser() ){
return $this->redirectToRoute('customers_layout');
}
return $this->render('security/index.html.twig', [
'title'=> 'Login Page'
]);
}
/**
* @Route("/logout", name="app_logout")
*/
public function logout(): Response
{
#throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
// if( !$this->getUser() ){
// // throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
// return $this->render('security/index.html.twig', [
// 'title'=> 'Login Page'
// ]);
// }
return $this->redirectToRoute('app_login');
}
/**
* @Route("/password-forgot", name="app_password_forgot")
*/
public function passwordForgot(): Response
{
if( !$this->getUser() ){
// throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
return $this->render('security/index.html.twig', [
'title'=> 'Login Page'
]);
}
return $this->redirectToRoute('customers_layout');
}
}