<?php
namespace Aviatur\GeneralBundle\EventListener;
use Aviatur\AgencyBundle\Entity\Agency;
use Aviatur\CustomerBundle\Entity\Customer;
use Aviatur\CustomerBundle\Models\CustomerModel;
use Aviatur\FlightBundle\Entity\ConfigFlightAgency;
use Aviatur\GeneralBundle\Entity\Parameter;
use Aviatur\GeneralBundle\Entity\SeoHeader;
use Aviatur\GeneralBundle\Entity\SeoIndex;
use Aviatur\GeneralBundle\Entity\Whitemark;
use Aviatur\GeneralBundle\Services\AviaturAthServices;
use Aviatur\GeneralBundle\Services\AviaturChangeCoin;
use Aviatur\GeneralBundle\Services\AviaturErrorHandler;
use Aviatur\GeneralBundle\Services\AviaturLogSave;
use Aviatur\GeneralBundle\Services\AviaturWebService;
use Aviatur\GeneralBundle\Services\ExceptionLog;
use Aviatur\HotelBundle\Entity\ConfigHotelAgency;
use Doctrine\Persistence\ManagerRegistry;
use Firebase\JWT\JWT;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class RequestListener
{
private \Symfony\Component\HttpFoundation\RequestStack $requestStack;
private \Symfony\Component\HttpFoundation\Session\SessionInterface $session;
private \Aviatur\GeneralBundle\Services\AviaturLogSave $aviaturLogSave;
private \Swift_Mailer $mailer;
private \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker;
private \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage;
private \Aviatur\GeneralBundle\Services\ExceptionLog $exceptionLog;
private \Aviatur\GeneralBundle\Services\AviaturChangeCoin $changeCoin;
private \Aviatur\GeneralBundle\Services\AviaturWebService $aviaturWebService;
private $projectDir;
private $env;
private $em;
private $aviaturAthServices;
private $aviaturErrorHandler;
private $router;
protected $twig;
private $aviaturSufixAssetsFolder;
private $aviaturDefaultAssetsFolder;
private $emailNotification;
private string $sessionSufixParameters = '[parameters]';
private string $wwwPrefix = 'www.';
public function __construct(
RequestStack $requestStack, SessionInterface $session, AviaturLogSave $aviaturLogSave, \Swift_Mailer $mailer, AuthorizationCheckerInterface $authorizationChecker, TokenStorageInterface $tokenStorage,
ExceptionLog $exceptionLog, AviaturChangeCoin $changeCoin, AviaturWebService $aviaturWebService, ManagerRegistry $registry, AviaturAthServices $aviaturAthServices, AviaturErrorHandler $aviaturErrorHandler,
RouterInterface $router, $twig, $aviaturSufixAssetsFolder, $aviaturDefaultAssetsFolder, $emailNotification, $projectDir, $env
) {
$this->requestStack = $requestStack;
$this->session = $session;
$this->aviaturLogSave = $aviaturLogSave;
$this->mailer = $mailer;
$this->authorizationChecker = $authorizationChecker;
$this->tokenStorage = $tokenStorage;
$this->exceptionLog = $exceptionLog;
$this->changeCoin = $changeCoin;
$this->aviaturWebService = $aviaturWebService;
$this->projectDir = $projectDir;
$this->env = $env;
$this->em = $registry->getManager();
$this->aviaturAthServices = $aviaturAthServices;
$this->aviaturErrorHandler = $aviaturErrorHandler;
$this->router = $router;
$this->twig = $twig;
$this->aviaturSufixAssetsFolder = $aviaturSufixAssetsFolder;
$this->aviaturDefaultAssetsFolder = $aviaturDefaultAssetsFolder;
$this->emailNotification = $emailNotification;
$this->loginKey = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Parameter::class)->findOneByName('aval_public_key_auth')->getDescription();
}
public function onKernelRequest(RequestEvent $event)
{
apc_clear_cache();
apc_clear_cache('user');
$request = $event->getRequest();
$domain = $request->getHost();
if (('www.aviatur.com' != $domain) && ('ecommprod.grupoaviatur.com' != $domain) && ('agenciadeviajes.compensar.com' != $domain) && ('compensar.grupoaviatur.com' != $domain) && ('mobile.aviatur.com' != $domain) && ('mobile.grupoaviatur.com' != $domain)) {
$this->aviaturLogSave->logSave($domain.' '.$request->server->get('REQUEST_URI').' '.$request->attributes->get('_route').' '.microtime(), 'DomainTime', 'RQ', microtime());
}
if (('www.aviaturcolombia.com' == $domain) && !$request->getQueryString() && ('/' == $request->getPathInfo())) {
$response = new RedirectResponse('http://www.aviaturcolombia.com/en/');
return $event->setResponse($response);
}
$post = $request->request;
$securityContext = $this->authorizationChecker;
$server = $this->requestStack->getCurrentRequest()->server;
$referer = str_replace('www.', '', parse_url($server->get('HTTP_REFERER'), PHP_URL_HOST));
$whitemarkAgency = null;
$requestQuery = $request->query;
$protocol = 'domain';
if ($request->isSecure()) {
$protocol = 'domainsecure';
}
$this->session->set('emailNoReply', 'noreply@aviatur.com.co');
$agency = $this->em->getRepository(Agency::class)->findOneBy(
[$protocol => [$domain, str_replace($this->wwwPrefix, '', $domain)]]
);
// ?? $this->em->getRepository(Agency::class)->findOneBy(
// ['domain' => [$domain, str_replace($this->wwwPrefix, '', $domain)]]
//)
if ($agency) {
$isAgency = true;
$onlySearcherSite = $this->em->getRepository(Whitemark::class)->findOneBy(['agency' => $agency, 'url' => $referer]);
if (null != $onlySearcherSite) {
if (2 == $onlySearcherSite->getEmbebed()) {
$this->session->set('onlySearcherSite', true);
}
}
if ('' != $post->get('detailWhitemarkReferer')) {
$requestQuery->set('whitemark', $post->get('detailWhitemarkReferer'));
}
// if ($post->get('hotelWhitemarkReferer') != "") {
// $requestQuery->set('whitemark', $post->get('hotelWhitemarkReferer'));
// }
// if ($post->get('packageWhitemarkReferer') != "") {
//
// $requestQuery->set('whitemark', $post->get('packageWhitemarkReferer'));
// }
if ('' != $post->get('loginWhitemark')) {
$requestQuery->set('whitemark', $post->get('loginWhitemark'));
$this->session->set('whitemarkLogin', $post->get('loginWhitemark'));
} else {
if ($this->session->has('whitemarkLogin')) {
$whitemarkAgency = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['referer' => $this->session->get('whitemarkLogin')]);
$requestQuery->set('whitemark', $this->session->get('whitemarkLogin'));
}
}
// if (!$this->session->has('agencyDataInfo')) {
$agencyDataInfo = [
'agency_id' => $agency->getId(),
'agency_name' => $agency->getName(),
'agency_nit' => $agency->getNit(),
'agency_phone' => $agency->getPhone(),
'agency_email' => $agency->getMailContact(),
'address' => $agency->getAddress(),
'agency_phones' => json_decode($agency->getPhonesContact(), true),
'socialmedia' => json_decode($agency->getSocialmedia(), true)
];
// if (count($agencyDataInfo) > 0) {
$this->session->set('agencyDataInfo', $agencyDataInfo);
// }
// }
} else {
$whitemarkAgency = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['url' => str_replace($this->wwwPrefix, '', $domain)]);
if (null != $whitemarkAgency) {
$agency = $whitemarkAgency->getAgency();
$isAgency = true;
$requestQuery->set('whitemark', $whitemarkAgency->getReferer());
if (!$this->session->has('whitemarkDataInfo')) {
$whitemarkAgencyDataInfo = [
'whitemark_id' => $whitemarkAgency->getId(),
'whitemark_name' => $whitemarkAgency->getName(),
'whitemark_phone' => $whitemarkAgency->getPhone(),
'whitemark_email' => $whitemarkAgency->getEmail(),
'whitemark_address' => $whitemarkAgency->getAddress(),
'whitemark_phones' => json_decode($whitemarkAgency->getPhonesContact(), true),
];
if (count($whitemarkAgencyDataInfo) > 0) {
$this->session->set('whitemarkDataInfo', $whitemarkAgencyDataInfo);
}
}
} else {
$isAgency = false;
}
}
if ($isAgency) {
$post = $request->request;
if ($requestQuery->has('whitemark') || '' != $this->session->get('whitemark')) {
$refererInfo = $requestQuery->get('whitemark');
if (null == $whitemarkAgency) {
if (false !== strpos($agency->getDomainsecure(), 'whitemark') && '' == $refererInfo) {
$whitemark = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['referer' => $this->session->get('whitemark')]);
if (!$requestQuery->has('whitemark')) {
$requestQuery->set('whitemark', $this->session->get('whitemark'));
if (0 == $whitemark->getEmbebed()) {
$this->session->set('homeWhitemark', 'https://'.$whitemark->getUrl());
}
}
} else {
if (false !== strpos($referer, 'whitemark')) {
$whitemark = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['referer' => $refererInfo]);
} else {
$whitemark = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['url' => $referer, 'referer' => $refererInfo]);
}
if ('' != $this->session->get('whitemark')) {
$whitemark = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Whitemark::class)->findOneBy(['referer' => $this->session->get('whitemark')]);
$requestQuery->set('whitemark', $this->session->get('whitemark'));
}
}
} else {
$whitemark = $whitemarkAgency;
}
if (null == $whitemark) {
$response = new RedirectResponse('https://www.aviatur.com');
return $event->setResponse($response);
} else {
$this->session->set('whitemark', $requestQuery->get('whitemark'));
$this->session->set('whitemarkSite', $whitemark->getEmbebed());
$this->session->set('whitemarkName', $whitemark->getName());
$this->session->set('whitemarkMail', $whitemark->getEmail());
if (0 == $whitemark->getEmbebed()) {
$wmData = [];
$wmData['direccion'] = $whitemark->getAddress();
$wmData['telefono'] = $whitemark->getPhone();
$wmData['correo'] = $whitemark->getEmail();
$this->session->set('whitemarkData', $wmData);
$this->session->set('homeWhitemark', 'https://'.$whitemark->getUrl());
$query = $this->em->createQuery('SELECT a FROM AviaturContentBundle:Content a WHERE a.agency = :agency and a.url LIKE :menu ORDER BY a.creationdate DESC');
$query = $query->setParameter('agency', $agency);
$query = $query->setParameter('menu', '%'.$refererInfo.'%');
$content = $query->getResult();
$menu = [];
foreach ($content as $item) {
$menu[$item->getTitle()] = $item->getUrl();
}
$this->session->set('whitemarkMenu', $menu);
}
}
}
if ($requestQuery->has('special_campaing')) {
$this->session->set('special_campaing', $requestQuery->get('special_campaing'));
}
if ($post->has('flightSpecialReferer')) {
$this->session->set('special_campaing', $post->get('flightSpecialReferer'));
}
// if ((strpos($agency->getDomainsecure(), 'whitemark') !== false) && (!$this->session->has('whitemark'))) {
// $response = new RedirectResponse("http://www.aviatur.com");
// return $event->setResponse($response);
// }
if ('claro' == $agency->getAssetsFolder()) {
$specialMenuData = file_get_contents($this->projectDir.'/web/contenido/json_claro.txt');
$specialMenuData = json_decode($specialMenuData, true);
$this->session->set('agency_special_header', $specialMenuData);
}
$_route = $request->attributes->get('_route');
$this->session->set('agencyId', $agency->getId());
$this->session->set('agencyShortName', ucwords(str_replace('_', ' ', $agency->getAssetsfolder())));
$this->session->set('domain', $agency->getDomain());
$this->session->set('domainsecure', $agency->getDomainsecure());
$this->session->set('domainport', $agency->getCustomport());
$this->session->remove('notEnableFlightSearch');
$this->session->remove('notEnableHotelSearch');
$this->session->remove('notEnableMultiHVSearch');
$configFlightAgency = $this->em->getRepository(ConfigFlightAgency::class)->findByAgency($agency);
if ((is_countable($configFlightAgency) ? count($configFlightAgency) : 0) < 1) {
$this->session->set('notEnableFlightSearch', true);
}
$configHotelAgency = $this->em->getRepository(ConfigHotelAgency::class)->findByAgency($agency);
if ((is_countable($configHotelAgency) ? count($configHotelAgency) : 0) < 1) {
$this->session->set('notEnableHotelSearch', true);
}
if ((is_countable($configFlightAgency) ? count($configFlightAgency) : 0) < 1 || (is_countable($configHotelAgency) ? count($configHotelAgency) : 0) < 1) {
$this->session->set('notEnableMultiHVSearch', true);
}
if (null != $this->tokenStorage->getToken() && !$this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
// authenticated REMEMBERED, FULLY will imply REMEMBERED (NON anonymous)
/* if ($agency->getDomain() == "aviatur.com"){
var_dump($request);
var_dump($request->isSecure());
var_dump($request->isSecure() != TRUE);
VAR_DUMP(($agency->getCustomport() == 443) && ($agency->getDomain() === $agency->getDomainsecure()) && (strpos($agency->getDomainsecure(), 'whitemark') === false) && (strpos($agency->getDomainsecure(), 'wm.') === false) && (strpos($agency->getDomainsecure(), 'mb.') === false) && ($request->isSecure() != TRUE));
exit();
} */
if ((443 == $agency->getCustomport()) && ($agency->getDomain() === $agency->getDomainsecure()) && (false === strpos($agency->getDomainsecure(), 'whitemark')) && (false === strpos($agency->getDomainsecure(), 'wm.')) && (false === strpos($agency->getDomainsecure(), 'mb.')) && (!$request->isSecure())) {
$response = new RedirectResponse('https://'.$agency->getDomainsecure().$request->server->get('REQUEST_URI'));
return $event->setResponse($response);
} elseif ((false === strpos($_route, '_nocheck')) && (false === strpos($_route, 'fos_user_')) && ($agency->getDomainsecure() != $agency->getDomain())) {
if (((false !== strpos($_route, '_secure')) || (false !== strpos($_route, 'sonata_')) || (false !== strpos($_route, 'admin_aviatur_'))) && (true != $request->isSecure())) {
$response = new RedirectResponse('https://'.$agency->getDomainsecure().$request->server->get('REQUEST_URI'));
return $event->setResponse($response);
} elseif ((false === strpos($_route, '_secure')) && (false === strpos($_route, 'sonata_')) && (false === strpos($_route, 'admin_aviatur_')) && (true == $request->isSecure())) {
$response = new RedirectResponse('http://'.$agency->getDomain().$request->server->get('REQUEST_URI'));
return $event->setResponse($response);
}
}
}
$search = ['?_ga=', '&_ga='];
$tempUrl = explode('|||||', str_replace($search, '|||||', $_SERVER['REQUEST_URI']));
$finalUrl = trim($tempUrl[0], '/');
$seoIndex = $this->em->getRepository(SeoIndex::class)->findBy(['agency' => $agency]);
$seoUrlIndex = [];
if (null != $seoIndex) {
foreach ($seoIndex as $item) {
if ($item->getUrl() == $finalUrl) {
$seoUrlIndex['url'] = $item->getUrl();
$seoUrlIndex['name'] = $item->getName();
$seoUrlIndex['content'] = $item->getContent();
}
}
$this->twig->addGlobal('seoUrlIndex', $seoUrlIndex);
}
$seoHeader = $this->em->getRepository(SeoHeader::class)->findByWithNull($finalUrl, $agency);
if (null != $seoHeader) {
$this->twig->addGlobal('seo_title', $seoHeader->getTitle());
$this->twig->addGlobal('seo_description', $seoHeader->getDescription());
$this->twig->addGlobal('seo_meta_title', $seoHeader->getMetatitle());
$this->twig->addGlobal('seo_keywords', $seoHeader->getKeywords());
}
$now = new \Datetime();
$agencyJson = json_encode([
'id' => $agency->getId(),
'name' => $agency->getName(),
'date' => $now->format('l, Y-F-d H:i:s'),
]);
// verificar assets folder
$sessionSufixAssetsFolder = $this->aviaturSufixAssetsFolder;
$defaultAssetsFolder = $this->aviaturDefaultAssetsFolder;
if ('' == $agency->getAssetsFolder() || null == $agency->getAssetsFolder()) {
// set default assets folder
$this->session->set($domain.$sessionSufixAssetsFolder, $defaultAssetsFolder);
} elseif (!$this->session->has($domain.$sessionSufixAssetsFolder)) {
$this->session->set($domain.$sessionSufixAssetsFolder, $agency->getAssetsFolder());
}
// verificar parametros por defecto y especificos para la agencia.
// if (!$this->session->has($domain . $this->sessionSufixParameters)) {
$parameters = $this->em->getRepository(Parameter::class)->findParameters($agency);
if ($parameters) {
$array = [];
foreach ($parameters as $item) {
$array += [
$item['name'] => $item['value'],
];
}
$this->session->set($domain.$this->sessionSufixParameters, json_encode($array));
} else {
$this->exceptionLog->log(
'Error Fatal',
'No hay parametros por defecto ni especificos para asignar a la agencia: '.$agencyJson,
null,
false
);
}
if ($this->changeCoin->validateChangeCoin($_route)) {
if ($request->query->has('currency') || $request->request->has('typeCoin')) {
$this->changeCoin->removeSessionValues();
$typeCoin = $request->query->has('currency') ? $request->query->get('currency') : $request->request->get('typeCoin');
$sessionVariables = [
'typeCoin' => $typeCoin,
'typeCoinMemory' => $typeCoin,
'typeCountry' => strtolower(mb_substr($typeCoin, 0, 2)),
];
$this->changeCoin->setSessionValues($sessionVariables);
} else {
if (!$this->session->has('typeCoin')) {
if ($this->session->has('typeCoinMemory')) {
$typeCoin = $this->session->get('typeCoinMemory');
$sessionVariables = [
'typeCoin' => $typeCoin,
'typeCountry' => strtolower(mb_substr($typeCoin, 0, 2)),
];
} else {
$sessionVariables = [
'typeCoin' => 'COP',
'typeCountry' => 'co',
];
}
$this->changeCoin->setSessionValues($sessionVariables);
}
}
$this->changeCoin->InfoCoin('COP');
}
if ($post->has('operatorId')) {
$this->session->set('operatorId', $post->get('operatorId'));
$this->session->set('operatorName', $post->get('operatorName'));
$this->session->set('airlineFront', $post->get('airline'));
if ($post->has('adapterId')) {
$this->session->set('flightAdapterId', $post->get('adapterId'));
} elseif ($post->get('flightProviderIds')) {
$this->session->set('flightAdapterId', $post->get('flightProviderIds'));
$this->session->set('officeId', $post->get('officeId'));
$this->session->set('externalId', $post->get('externalId'));
}
if ($post->has('cencosud')) {
$this->session->set('frontCencosud', '1');
} elseif ($this->session->has('frontCencosud')) {
$this->session->remove('frontCencosud');
}
$this->session->set('hotelAdapterId', $post->get('hotelProviderIds'));
$customerModel = new CustomerModel();
$this->aviaturWebService->setUrls(json_decode($this->session->get($domain.$this->sessionSufixParameters)));
$responseAgent = $this->aviaturWebService->callWebService('GENERALLAVE', 'dummy|http://www.aviatur.com.co/dummy/', $customerModel->getXmlAgent($post->get('operatorId')));
$this->session->set('front_user', $responseAgent->asXml());
$responseAgentAdditionals = $this->aviaturWebService->callWebService('GENERALLAVE', 'dummy|http://www.aviatur.com.co/dummy/', $customerModel->getXmlAgentAdditionals($post->get('operatorId')));
$this->session->set('front_user_additionals', $responseAgentAdditionals->asXml());
}
// Validar agencia aval y token para inicio de sesion
if (strpos($agency->getName(), 'Aval')) {
if (isset($_GET['authorization']) || $this->session->has('token')) {
$response = $this->aviaturAthServices->validateToken(["token" => $_GET['authorization'] ?? $this->session->get('token')], FALSE);
if (!isset($response['error'])) {
if ($response['ok']['code'] != 0) {
$this->session->remove('token');
$this->session->remove('userAth');
$redirectError = $this->aviaturErrorHandler->errorRedirectNoEmail($this->router->generate('homepage'), 'Sesión Inactiva', 'La sesión ha caducado');
return new RedirectResponse($redirectError);
} else {
if (!$this->session->has('token')) {
$this->session->set('token', $_GET['authorization'] ?? $this->session->get('token'));
$decodedToken = json_encode(JWT::decode($_GET['authorization'], $this->loginKey, ['RS256'], TRUE));
$this->session->set('userAth', $decodedToken);
} else {
if (isset($_GET['authorization']) && $this->session->has('token') && $this->session->get('token') != $_GET['authorization']) {
$this->session->set('token', $_GET['authorization']);
$decodedToken = json_encode(JWT::decode($_GET['authorization'], $this->loginKey, ['RS256'], TRUE));
$this->session->set('userAth', $decodedToken);
}
}
}
} else {
$this->session->remove('token');
$this->session->remove('userAth');
$redirectError = $this->aviaturErrorHandler->errorRedirectNoEmail($this->router->generate('homepage'), 'Sesión Inactiva', 'La sesión ha caducado');
return new RedirectResponse($redirectError);
}
}
} else {
if ($post->has('token')) {
$this->session->set('token', $post->get('token'));
}
}
if ((false !== strpos($agency->getDomainsecure(), 'b2t')) && (!$this->session->has('operatorId'))) {
if (false === strpos($server->get('REQUEST_URI'), 'trenes/confirmar-reserva')) {
$response = new RedirectResponse('http://miavianet.aviatur.com.co');
return $event->setResponse($response);
}
}
// }
} else {
$response = new RedirectResponse('https://www.aviatur.com');
return $event->setResponse($response);
}
if (null != $this->tokenStorage->getToken() && $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$customer = $this->tokenStorage->getToken()->getUser();
if ($customer instanceof Customer) {
$city = $customer->getCity();
$this->em->persist($customer);
$this->em->flush();
if (null == $city) {
$dataCity = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\City::class)->findOneBy(['id' => '2164']);
$dataCountry = $this->em->getRepository(\Aviatur\GeneralBundle\Entity\Country::class)->findOneBy(['id' => '165']);
$customer->setCity($dataCity);
$customer->setCountry($dataCountry);
$customer->setAviaturclientid(0);
$customer->setAcceptInformation(0);
$customer->setAcceptSms(0);
$customer->setPersonType(8);
$customer->setFrecuencySms(0);
if (!$customer->getBirthdate()) {
$date = new \DateTime();
$date->sub(new \DateInterval('P19Y'));
$customer->setBirthdate($date);
$this->fieldCompletionAlert($customer, 'Birthdate', $date);
}
$this->em->persist($customer);
$this->em->flush();
}
if (!$customer->getCity()) {
$customer->completeCity($this->em);
$this->em->flush();
$this->cityNullAlert($customer, $request);
}
}
}
if (!$this->session->has('headerPromoStart')) {
$homePromoTime = $this->em->getRepository(\Aviatur\EditionBundle\Entity\HomePromoTime::class)->findOneByHomePromoList(2);
$this->session->set('headerPromoStart', $homePromoTime->getStartDate());
$this->session->set('headerPromoEnd', $homePromoTime->getEndDate());
}
}
private function fieldCompletionAlert($customer, $field, $newval)
{
$env = $this->env;
$message = (new \Swift_Message())
->setContentType('text/html')
->setFrom('errors.'.$env.'@aviatur.com')
->setTo([$this->emailNotification, 'jorge.ubaque@aviatur.com'])
->setSubject('Customer Registration Issue: '.$field)
->setBody('The system has automatically set a new value to field ('.$field.') for user:<br><br>
username: '.$customer->getUsername().'<br>
customer_id: '.$customer->getId().'<br><br>
The field was set to: '.print_r($newval, true).'
');
$this->mailer->send($message);
return true;
}
private function cityNullAlert($customer, $request)
{
$env = $this->env;
$message = (new \Swift_Message())
->setContentType('text/html')
->setFrom('errors.'.$env.'@aviatur.com')
->setTo([$this->emailNotification, 'jorge.ubaque@aviatur.com'])
->setSubject('Customer Registration Issue: City NULL')
->setBody('The system has detected that City is still null after all filters. The entity has set the default values, please check.<br><br>Customer Info:<br><br>
Username: '.$customer->getUsername().'<br>
Customer_id: '.$customer->getId().'<br><br>
Server info: <pre>'.print_r($request->server, true).'</pre><br><br>
');
$this->mailer->send($message);
return true;
}
}