<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller;
use App\Form\Type\ChangePasswordType;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
/**
* Controller used to manage current user.
*
* @author Romain Monteil <monteil.romain@gmail.com>
*/
#[Route('/')]
class SiteController extends AbstractController {
#[Route('/', name: 'homepage')]
public function homepageAction() {
return $this->render('site/homepage.html.twig', array(
));
}
#[Route('/contact', name: 'contact')]
public function contactAction() {
return $this->render('site/contact.html.twig');
}
#[Route('/pricing', name: 'pricing')]
public function pricingAction() {
return $this->render('site/pricing.html.twig');
}
#[Route('/about-us', name: 'about')]
public function aboutAction() {
return $this->render('site/about.html.twig');
}
#[Route('/time-clocks', name: 'time_clocks')]
public function timeClocksAction() {
return $this->render('site/timeClocks.html.twig');
}
#[Route('/access-control', name: 'access_control')]
public function accessControlAction() {
return $this->render('site/accessControl.html.twig');
}
#[Route('/contact-send', methods: ['GET', 'POST'], name: 'contactSend')]
public function contactSendAction(Request $request) {
$em = $this->getDoctrine()->getManager();
$message = \Swift_Message::newInstance()
->setSubject('New Message')
->setFrom('contact@actech.ma')
->setTo('support@actech.ma')
->setBody($this->renderView('emails/contactSupport.html.twig', array('form' => $_POST)), 'text/html');
$this->get('mailer')->send($message);
$message2 = \Swift_Message::newInstance()
->setSubject('Message sent with success')
->setFrom('contact@achtech.ma')
->setTo($_POST['email'])
->setBody($this->renderView('emails/contact.html.twig', array('form' => $_POST)), 'text/html');
$this->get('mailer')->send($message2);
$this->addFlash('success', 'Thank you, Your message has been successfully sent. We will contact you very soon!');
return $this->redirectToRoute('contact');
}
#[Route('/pricing-request', methods: ['GET', 'POST'] , name: 'more_info')]
public function moreInfoAction(Request $request) {
$em = $this->getDoctrine()->getManager();
$message = \Swift_Message::newInstance()
->setSubject('Pricing Request')
->setFrom('contact@actech.ma')
->setTo('support@actech.ma')
->setBody($this->renderView('emails/pricingRequestSupport.html.twig', array('form' => $_POST)), 'text/html');
$this->get('mailer')->send($message);
$message2 = \Swift_Message::newInstance()
->setSubject('Actech.ma - Pricing request')
->setFrom('contact@achtech.ma')
->setTo($_POST['email'])
->setBody($this->renderView('emails/pricingRequest.html.twig', array('form' => $_POST)), 'text/html');
$this->get('mailer')->send($message2);
$this->addFlash('success', 'Thank you, Your message has been successfully sent. We will contact you very soon!');
return $this->redirectToRoute('contact');
}
#[Route('/trans', name: 'trans')]
public function transAction($language = null) {
if ($language != null) {
$request = $this->getRequest();
$request->setLocale($language);
$this->get('session')->set('_locale', $language);
}
$url = $this->container->get('request')->headers->get('referer');
if ($language == "en") {
$url = str_replace("/fr", "/en", $url);
$url = str_replace("/ar", "/en", $url);
} else if ($language == "fr") {
$url = str_replace("/en", "/fr", $url);
$url = str_replace("/ar", "/fr", $url);
} else if ($language == "ar") {
$url = str_replace("/en", "/ar", $url);
$url = str_replace("/fr", "/ar", $url);
}
if (empty($url)) {
$url = $this->container->get('router')->generate('homepage');
}
return new RedirectResponse($url);
}
}