src/Controller/IndexController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Controller\CommonController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use App\Form\SupportType;
  9. use App\Service\EmailService;
  10. class IndexController extends CommonController
  11. {
  12.     /**
  13.      * Home Page Route
  14.      *
  15.      * @Route("/", name="home")
  16.      */
  17.     public function indexAction()
  18.     {
  19.         return $this->redirectToRoute('invoice_list');
  20.         $data['table'] = [
  21.             ['task' => 1'progress' => rand(0100)],
  22.             ['task' => 2'progress' => rand(0100)],
  23.             ['task' => 3'progress' => rand(0100)],
  24.             ['task' => 4'progress' => rand(0100)],
  25.         ];
  26.         $data['info'] = $this->getUser();
  27.         $data['menu'] =  'dashboard';
  28.         //check if user is logged in
  29.         $user $this->getUser();
  30.         if (!$user) {
  31.             //$redirect = new RedirectResponse;
  32.             return $this->redirectToRoute('app_login');
  33.         }
  34.         return $this->render('index.html.twig'$data);
  35.     }
  36.     /**
  37.      * Home Page Route
  38.      *
  39.      * @Route("/support",name="support")
  40.      */
  41.     public function supportAction(Request $request,EmailService $mailService)
  42.     {   
  43.         $accessTree $this->getAccessTree();
  44.         $form $this->createForm(SupportType::class);
  45.         $user $this->getUser();
  46.         $name $user->getName();
  47.         $email $user->getUsername();
  48.         $form->get('name')->setData($name);
  49.         $form->get('emailAddress')->setData($email);
  50.         $form->handleRequest($request);
  51.         if ($form->isSubmitted()) {
  52.             $data =$form->getData();
  53.             $to $this->getParameter('support_destination');
  54.             $from $this->getParameter('email_from');
  55.             $mailService->send($from,$to,'New Support Email','email/support.html.twig',$data);
  56.             $this->addFlash('success'"Your message has been sent to our support team");
  57.         }
  58.         $data = [
  59.             'navigation' => $this->getNavigationSections(),
  60.             'menu' => 'support',
  61.             'form' =>  $form->createView(),
  62.         ];
  63.         return $this->render('support.html.twig'$data); 
  64.     }
  65. }