. */ /* */ /*************************************************************************************/ namespace Front\Controller; use Thelia\Controller\Front\BaseFrontController; use Thelia\Form\Definition\FrontForm; use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Thelia\Model\ConfigQuery; /** * Class ContactController * @package Thelia\Controller\Front * @author Manuel Raynaud */ class ContactController extends BaseFrontController { /** * send contact message */ public function sendAction() { $contactForm = $this->createForm(FrontForm::CONTACT); try { $form = $this->validateForm($contactForm); $this->getMailer()->sendSimpleEmailMessage( [ ConfigQuery::getStoreEmail() => $form->get('name')->getData() ], [ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ], $form->get('subject')->getData(), '', $form->get('message')->getData(), [], [], [ $form->get('email')->getData() => $form->get('name')->getData() ] ); if ($contactForm->hasSuccessUrl()) { return $this->generateSuccessRedirect($contactForm); } return $this->generateRedirectFromRoute('contact.success'); } catch (FormValidationException $e) { $error_message = $e->getMessage(); } Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); $contactForm->setErrorMessage($error_message); $this->getParserContext() ->addForm($contactForm) ->setGeneralError($error_message) ; // Redirect to error URL if defined if ($contactForm->hasErrorUrl()) { return $this->generateErrorRedirect($contactForm); } } }