src/Controller/SiteController.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Controller;
  11. use App\Form\Type\ChangePasswordType;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. /**
  20.  * Controller used to manage current user.
  21.  *
  22.  * @author Romain Monteil <monteil.romain@gmail.com>
  23.  */
  24. #[Route('/')]
  25. class SiteController extends AbstractController {
  26.     #[Route('/'name'homepage')]
  27.     public function homepageAction() {
  28.         return $this->render('site/homepage.html.twig', array(
  29.         ));
  30.     }
  31.     #[Route('/contact'name'contact')]
  32.     public function contactAction() {
  33.         return $this->render('site/contact.html.twig');
  34.     }
  35.     #[Route('/pricing'name'pricing')]
  36.     public function pricingAction() {
  37.         return $this->render('site/pricing.html.twig');
  38.     }
  39.     #[Route('/about-us'name'about')]
  40.     public function aboutAction() {
  41.         return $this->render('site/about.html.twig');
  42.     }
  43.     #[Route('/time-clocks'name'time_clocks')]
  44.     public function timeClocksAction() {
  45.         return $this->render('site/timeClocks.html.twig');
  46.     }
  47.     #[Route('/access-control'name'access_control')]
  48.     public function accessControlAction() {
  49.         return $this->render('site/accessControl.html.twig');
  50.     }
  51.     #[Route('/contact-send'methods: ['GET''POST'], name'contactSend')]
  52.     public function contactSendAction(Request $request) {
  53.         $em $this->getDoctrine()->getManager();
  54.         $message \Swift_Message::newInstance()
  55.                 ->setSubject('New Message')
  56.                 ->setFrom('contact@actech.ma')
  57.                 ->setTo('support@actech.ma')
  58.                 ->setBody($this->renderView('emails/contactSupport.html.twig', array('form' => $_POST)), 'text/html');
  59.         $this->get('mailer')->send($message);
  60.         $message2 \Swift_Message::newInstance()
  61.                 ->setSubject('Message sent with success')
  62.                 ->setFrom('contact@achtech.ma')
  63.                 ->setTo($_POST['email'])
  64.                 ->setBody($this->renderView('emails/contact.html.twig', array('form' => $_POST)), 'text/html');
  65.         $this->get('mailer')->send($message2);
  66.         $this->addFlash('success''Thank you, Your message has been successfully sent. We will contact you very soon!');
  67.         return $this->redirectToRoute('contact');
  68.     }
  69.     #[Route('/pricing-request'methods: ['GET''POST'] , name'more_info')]
  70.     public function moreInfoAction(Request $request) {
  71.         $em $this->getDoctrine()->getManager();
  72.         $message \Swift_Message::newInstance()
  73.                 ->setSubject('Pricing Request')
  74.                 ->setFrom('contact@actech.ma')
  75.                 ->setTo('support@actech.ma')
  76.                 ->setBody($this->renderView('emails/pricingRequestSupport.html.twig', array('form' => $_POST)), 'text/html');
  77.         $this->get('mailer')->send($message);
  78.         $message2 \Swift_Message::newInstance()
  79.                 ->setSubject('Actech.ma - Pricing request')
  80.                 ->setFrom('contact@achtech.ma')
  81.                 ->setTo($_POST['email'])
  82.                 ->setBody($this->renderView('emails/pricingRequest.html.twig', array('form' => $_POST)), 'text/html');
  83.         $this->get('mailer')->send($message2);
  84.         $this->addFlash('success''Thank you, Your message has been successfully sent. We will contact you very soon!');
  85.         return $this->redirectToRoute('contact');
  86.     }
  87.     #[Route('/trans'name'trans')]
  88.     public function transAction($language null) {
  89.         if ($language != null) {
  90.             $request $this->getRequest();
  91.             $request->setLocale($language);
  92.             $this->get('session')->set('_locale'$language);
  93.         }
  94.         $url $this->container->get('request')->headers->get('referer');
  95.         if ($language == "en") {
  96.             $url str_replace("/fr""/en"$url);
  97.             $url str_replace("/ar""/en"$url);
  98.         } else if ($language == "fr") {
  99.             $url str_replace("/en""/fr"$url);
  100.             $url str_replace("/ar""/fr"$url);
  101.         } else if ($language == "ar") {
  102.             $url str_replace("/en""/ar"$url);
  103.             $url str_replace("/fr""/ar"$url);
  104.         }
  105.         if (empty($url)) {
  106.             $url $this->container->get('router')->generate('homepage');
  107.         }
  108.         return new RedirectResponse($url);
  109.     }
  110. }