/**
  * @param PostFlushEventArgs $args
  */
 public function postFlush(PostFlushEventArgs $args)
 {
     $entityManager = $args->getEntityManager();
     foreach ($entityManager->getUnitOfWork()->getIdentityMap() as $key => $entities) {
         foreach ($entities as $entityId => $entity) {
             $changeSet = $entityManager->getUnitOfWork()->getEntityChangeSet($entity);
             $entityClass = $this->contextService->resolveEntityClass(get_class($entity));
             $contexts = $this->contextService->getEntityContexts($entityClass);
             if (count($contexts) && count($changeSet)) {
                 $queued = $this->contextService->getQueued();
                 if (count($queued)) {
                     if (isset($queued[$entityClass])) {
                         $currentEntity = $queued[$entityClass];
                         $contextRepo = $args->getEntityManager()->getRepository('BigfootContextBundle:Context');
                         /** @var ContextRepository $contextRepo */
                         $context = $contextRepo->findOneByEntityIdEntityClass($entityId, $entityClass);
                         if (!$context) {
                             $context = $this->createContext($entityId, $entityClass, $currentEntity['context_values']);
                         }
                         $entityManager->persist($context);
                         $this->contextService->clearQueue();
                         $entityManager->flush();
                     }
                 }
             }
         }
     }
 }
 /**
  * @param GetResponseEvent $event
  */
 public function onLateKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType() or !in_array($this->kernel->getEnvironment(), array('admin', 'admin_dev'))) {
         return;
     }
     $this->translationListener->setTranslatableLocale($this->context->getDefaultFrontLocale());
 }
Example #3
0
 /**
  * @param GetResponseEvent $event
  */
 public function onLateKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     $locale = $this->context->get('language');
     $request->setLocale($locale);
     $this->translationListener->setTranslatableLocale($locale);
 }
Example #4
0
 /**
  * @param $value
  * @param $key
  * @return mixed
  */
 public function linkBrand($value, $key)
 {
     $currentBrandContext = str_replace('.com', '', $this->bigfootContext->get('brand', true));
     $brandHotelContext = str_replace('.com', '', $this->bigfootContext->get('brand', true, $key));
     $canonicalHotelUrl = str_replace($currentBrandContext['key'], $brandHotelContext['key'], $value);
     return $canonicalHotelUrl;
 }
 /**
  * @param array                        $localeList
  * @param RegistryInterface            $doctrine
  * @param Reader                       $annotationReader
  * @param BigfootTranslationRepository $translationRepository
  * @param string                       $defaultLocale
  * @param ContextService               $context
  */
 public function __construct($localeList, RegistryInterface $doctrine, Reader $annotationReader, BigfootTranslationRepository $translationRepository, $defaultLocale, ContextService $context)
 {
     $this->localeList = $localeList;
     $this->doctrine = $doctrine;
     $this->annotationReader = $annotationReader;
     $this->translationRepository = $translationRepository;
     $this->defaultLocale = $defaultLocale;
     $this->currentLocale = $context->getDefaultFrontLocale();
 }
 /**
  * @param EntityManager $entityManager
  * @param SessionInterface $session
  * @param AuthorizationChecker $securityAuthorizationChecker
  * @param ContextService $contextService
  * @param ContextManager $contextManager
  */
 public function __construct(EntityManager $entityManager, SessionInterface $session, AuthorizationChecker $securityAuthorizationChecker, ContextService $contextService, ContextManager $contextManager)
 {
     $this->entityManager = $entityManager;
     $this->session = $session;
     $this->securityAuthorizationChecker = $securityAuthorizationChecker;
     $this->contextService = $contextService;
     $this->contextManager = $contextManager;
     $this->contexts = $contextService->getContexts();
 }
Example #7
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $currentBrand = $this->context->get('brand');
     $builder->add('searchString', 'text', array('required' => false, 'label' => 'form.search.searchString.label', 'attr' => array('class' => 'termInput', 'autocomplete' => 'off', 'data-data-source' => $this->router->generate('search_autocomplete_action', array(), UrlGeneratorInterface::ABSOLUTE_URL))))->add('searchMapId', 'hidden', array('required' => false))->add('geolocationLat', 'hidden', array('required' => false, 'attr' => array('class' => 'geolocationLat', 'id' => 'geolocationLat')))->add('geolocationLng', 'hidden', array('required' => false, 'attr' => array('class' => 'geolocationLng', 'id' => 'geolocationLng')))->add('comeFromSearchMap', 'hidden', array('required' => false))->add('datePax', new DatePaxType())->add('flexible_dates', 'checkbox', array('required' => false))->add('accentCard', 'text', array('label' => 'form.search.accentCard.label', 'required' => false, 'attr' => array('class' => 'accentCardSearchField')))->add('services', 'entity', array('class' => 'SehBundle:HotelService', 'required' => false, 'multiple' => true, 'expanded' => true, 'empty_data' => null, 'empty_value' => 'none', 'property' => 'name', 'label' => 'form.search.services.label', 'loader' => $this->serviceLoader))->add('budget_min', 'hidden', array('label' => 'form.search.budget_min.label', 'attr' => array('class' => 'budgetMinValue')))->add('budget_max', 'hidden', array('attr' => array('class' => 'budgetMaxValue')));
     if ($currentBrand == 'seh') {
         $builder->add('radius', 'hidden')->add('brands', 'entity', array('label' => 'form.search.brands.label', 'class' => 'SehBundle:Brand', 'multiple' => true, 'expanded' => true, 'empty_data' => null, 'empty_value' => 'none', 'property' => 'name', 'required' => false, 'query_builder' => function (EntityRepository $er) {
             return $er->createQueryBuilder('b')->where('b.active = true')->orderBy('b.name', 'ASC');
         }));
     }
 }
Example #8
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $langContextCountry = $this->context->get('language') == 'en' ? "gb" : $this->context->get('language');
     $langContextLanguage = $this->context->get('language');
     $titles = $this->entityManager->getRepository('SehBundle:Customer\\Title')->findAll();
     $titleChoices = array();
     foreach ($titles as $title) {
         $titleChoices[$title->getId()] = $title->getName();
     }
     $builder->add('email', 'repeated', array('constraints' => new Assert\Email(), 'required' => true, 'error_bubbling' => false, 'invalid_message' => 'form.customer.account.email.check', 'first_options' => array('label' => 'form.customer.account.email.label'), 'second_options' => array('label' => 'form.customer.account.email.confirm.label'), 'label' => false))->add('title', 'choice', array('label' => 'form.customer.no_account.title.label', 'choices' => $titleChoices, 'multiple' => false, 'expanded' => false, 'required' => true, 'empty_data' => null, 'empty_value' => '-', 'error_bubbling' => false))->add('lastName', 'text', array('label' => 'form.customer.account.lastName.label', 'required' => true, 'error_bubbling' => false))->add('firstName', 'text', array('label' => 'form.customer.account.firstName.label', 'required' => true, 'error_bubbling' => false))->add('language', 'language', array('label' => 'form.label.language', 'required' => true, 'data' => $langContextLanguage, 'error_bubbling' => false))->add('phone', 'text', array('label' => 'form.customer.account.phone.label', 'required' => true, 'error_bubbling' => false))->add('address', 'text', array('label' => 'form.customer.account.address.label', 'required' => true, 'error_bubbling' => false))->add('address2', 'text', array('required' => false, 'error_bubbling' => false))->add('zipCode', 'text', array('label' => 'form.customer.account.zipCode.label', 'required' => true, 'error_bubbling' => false))->add('city', 'text', array('label' => 'form.customer.account.city.label', 'required' => true, 'error_bubbling' => false))->add('birthDate', 'date', array('label' => 'form.customer.account.birthDate.label', 'required' => true, 'widget' => 'choice', 'error_bubbling' => false, 'years' => range(date('Y'), date('Y') - 125), 'empty_value' => '', 'attr' => array('class' => 'select2')))->add('country', 'country', array('label' => 'form.customer.account.country.label', 'required' => true, 'data' => strtoupper($langContextCountry), 'error_bubbling' => false))->add('locale', 'locale', array('required' => true, 'error_bubbling' => false, 'attr' => array('style' => 'display:none')));
 }
Example #9
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $langContextCountry = $this->context->get('language') == 'en' ? "gb" : $this->context->get('language');
     $langContextLanguage = $this->context->get('language');
     $titles = $this->entityManager->getRepository('SehBundle:Customer\\Title')->findAll();
     $titleChoices = array();
     foreach ($titles as $title) {
         $titleChoices[$title->getId()] = $title->getName();
     }
     $builder->add('title', 'choice', array('label' => 'form.customer.no_account.title.label', 'choices' => $titleChoices, 'multiple' => false, 'expanded' => false, 'required' => true, 'empty_data' => null, 'empty_value' => '-', 'error_bubbling' => false))->add('lastName', 'text', array('label' => 'form.customer.no_account.lastName.label', 'required' => true, 'error_bubbling' => false))->add('firstName', 'text', array('label' => 'form.customer.no_account.firstName.label', 'required' => true, 'error_bubbling' => false))->add('phone', 'text', array('label' => 'form.customer.no_account.phone.label', 'required' => true, 'error_bubbling' => false))->add('email', 'repeated', array('constraints' => new Assert\Email(), 'required' => true, 'error_bubbling' => false, 'invalid_message' => 'form.customer.account.email.check', 'first_options' => array('label' => 'form.customer.account.email.label'), 'second_options' => array('label' => 'form.customer.account.email.confirm.label')))->add('country', 'country', array('label' => 'form.customer.no_account.country.label', 'required' => true, 'data' => strtoupper($langContextCountry), 'error_bubbling' => false))->add('lang', 'hidden', array('required' => true, 'data' => $langContextLanguage, 'error_bubbling' => false))->add('accentCard', 'text', array('label' => 'form.customer.no_account.accentCard.label', 'required' => false))->add('policy', 'checkbox', array('label' => 'form.customer.no_account.policy.label', 'error_bubbling' => false, 'mapped' => false, 'constraints' => array(new True(array('message' => 'form.customer.no_account.policy.true')))));
 }
Example #10
0
 /**
  * @param City $city
  *
  * @return $this
  */
 public function updateCity($city)
 {
     $locale = $this->locale;
     $em = $this->entityManager;
     /** @var TranslationRepository $translationRepo */
     $translationRepo = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');
     $availableLocales = array_keys($this->context->getValues('language'));
     $translations = $translationRepo->findTranslations($city);
     $names = array($locale => $city->getName());
     foreach ($translations as $transLocale => $transValue) {
         $names[$transLocale] = $transValue['name'];
     }
     foreach ($availableLocales as $availableLocale) {
         if (!isset($names[$availableLocale])) {
             $names[$availableLocale] = $city->getName();
         }
     }
     $newData = array('names' => $names);
     $document = $this->cityType->getDocument($city->getId());
     $data = $document->getData();
     $newData = array_merge($data, $newData);
     $document->setData($newData);
     $this->cityType->updateDocument($document);
     return $this;
 }
 /**
  * @param array $link
  * @param bool $absolute
  * @return string
  */
 public function getLink($link, $absolute = true)
 {
     $url = '#';
     if (isset($link['name'])) {
         $parameters = array();
         $locale = $this->context->get('language');
         $route = $link['name'];
         if ($this->router instanceof \BeSimple\I18nRoutingBundle\Routing\Router and $this->router->getRouteCollection()->get(sprintf('%s.%s', $route, $locale))) {
             $parameters['locale'] = $locale;
             $options = $this->router->getRouteCollection()->get($route . '.' . $locale)->getOptions();
         } else {
             $options = $this->router->getRouteCollection()->get($route)->getOptions();
         }
         $iParameters = isset($link['parameters']) ? $link['parameters'] : array();
         if (isset($options['parameters'])) {
             foreach ($options['parameters'] as $parameter) {
                 if (isset($parameter['type']) && preg_match('/Bundle/i', $parameter['type'])) {
                     $entity = $this->entityManager->getRepository($parameter['type'])->find($iParameters[$parameter['name']]);
                     $method = 'get' . ucfirst($parameter['field']);
                     $parameters[$parameter['name']] = $entity->{$method}();
                     if (isset($parameter['children'])) {
                         foreach ($parameter['children'] as $child) {
                             $method = 'get' . ucfirst($child);
                             $parameters[$child] = $entity->{$method}()->getSlug();
                         }
                     }
                 } else {
                     if (isset($parameter['name']) && isset($parameters[$parameter['name']])) {
                         $parameters[$parameter['name']] = $iParameters[$parameter['name']];
                     }
                 }
             }
         }
         try {
             $url = $this->router->generate($route, $parameters, $absolute);
         } catch (\Exception $e) {
             $url = '#';
         }
     } elseif (isset($link['externalLink']) and $link['externalLink']) {
         $url = $link['externalLink'];
         if (($httpPos = strpos($link['externalLink'], 'http')) === false or $httpPos != 0) {
             $url = sprintf('http://%s', $link['externalLink']);
         }
     }
     return $url;
 }
Example #12
0
 /**
  * @return string
  * @throws \Bigfoot\Bundle\ContextBundle\Exception\NotImplementedException
  * @throws \Exception
  */
 protected function getBrandSlug()
 {
     if (null === $this->brandSlug) {
         $brand = $this->context->get('brand');
         $this->brandSlug = $brand;
     }
     return $this->brandSlug;
 }
Example #13
0
 /**
  * @param $parameters
  * @param null $brandExtender
  * @return mixed
  */
 public function generateReservitRequest($parameters = array())
 {
     $brandParameters = $this->context->get('brand', true);
     if ($this->getBrandExtender()) {
         $requestorId = 0;
     } else {
         $requestorId = $brandParameters['parameters']['requestor.id'];
     }
     $defaultParameters = array('requestor.id' => $requestorId, 'max_responses' => 75, 'filter' => array('bstay' => 'false', 'bpromo' => 'false', 'rate_range' => 'true', 'rate_range_name' => 'true'));
     return $this->otaFactory->createRequest('HotelSearch', array_merge($defaultParameters, $parameters, $this->parameters));
 }
Example #14
0
 public function generatePageUrl($slug, $absolute = false)
 {
     $em = $this->entityManager;
     $page = $em->getRepository('BigfootContentBundle:Page')->createQueryBuilder('p')->where('p.slug = :slug')->setParameter(':slug', $slug)->getQuery()->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, 'en')->getOneOrNullResult();
     if ($page) {
         $lang = $this->context->get('language');
         $page->setTranslatableLocale($lang);
         $em->refresh($page);
         return $this->router->generate('seh_page', array('slug' => $page->getSlug()), $absolute);
     }
     return '#';
 }
Example #15
0
 private function buildItems(Menu $menu, MenuItem $knpMenu)
 {
     $locale = $this->bigfootContext->get('language');
     /**
      * @var Item $item
      */
     foreach ($menu->getItems() as $item) {
         $itemParameters = array('label' => $item->getLabel());
         $link = $item->getLink();
         if (isset($link['name'])) {
             $itemParameters['route'] = $link['name'];
             if ($this->router instanceof \BeSimple\I18nRoutingBundle\Routing\Router and $this->router->getRouteCollection()->get(sprintf('%s.%s', $link['name'], $locale))) {
                 $parameters['locale'] = $locale;
                 $options = $this->router->getRouteCollection()->get($link['name'] . '.' . $locale)->getOptions();
             } else {
                 $options = $this->router->getRouteCollection()->get($link['name'])->getOptions();
             }
             if (isset($options['label'])) {
                 $parameters = array();
                 $iParameters = $link['parameters'];
                 if (isset($options['parameters'])) {
                     foreach ($options['parameters'] as $key => $parameter) {
                         if (preg_match('/Bundle/i', $parameter['type'])) {
                             $entity = $this->entityManager->getRepository($parameter['type'])->find($iParameters[$parameter['name']]);
                             $method = 'get' . ucfirst($parameter['field']);
                             $parameters[$parameter['name']] = $entity->{$method}();
                             if (isset($parameter['childs'])) {
                                 foreach ($parameter['childs'] as $child) {
                                     $method = 'get' . ucfirst($child);
                                     $parameters[$child] = $entity->{$method}()->getSlug();
                                 }
                             }
                         } else {
                             $parameters[$parameter['name']] = $iParameters[$parameter['name']];
                         }
                     }
                 }
                 $itemParameters['routeParameters'] = $parameters;
                 $itemParameters['routeAbsolute'] = true;
             }
         } else {
             $itemParameters['uri'] = isset($link['externalLink']) ? $link['externalLink'] : '#';
         }
         $child = $knpMenu->addChild($item->getSlug(), $itemParameters);
         foreach ($item->getAttributesByType(Attribute::LINK) as $attribute) {
             $child->setLinkAttribute($attribute->getName(), $attribute->getValue());
         }
     }
     return $menu;
 }
Example #16
0
 /**
  * @param $entity
  * @param $name
  * @return mixed
  */
 private function getEntityByName($entity, $name)
 {
     $em = $this->entityManager;
     $query = sprintf('SELECT e FROM %s e WHERE (REPLACE(e.name, \'-\', \' \') = REPLACE(:name, \'-\', \' \') OR REPLACE(e.name, \'-\', \' \') = :transformedName)', $entity);
     if ($entity == 'SehBundle:Hotel' && ($brand = $this->context->get('brand')) != 'seh') {
         $brand = $em->getRepository('SehBundle:Brand')->findOneBy(array('artsysID' => strtoupper($brand)));
         $query .= sprintf(' AND IDENTITY(e.brand) = %s', $brand->getId());
     }
     $query = $em->createQuery($query);
     $query->setParameters(array(':name' => $name, ':transformedName' => $this->transformSearchString($name)));
     $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $results = array_values($query->getResult());
     return array_shift($results);
 }
Example #17
0
 /**
  * @param BookingUserSelection $booking
  * @param DatePaxData $datePax
  */
 public function initializeBookingFromSearch(BookingUserSelection $booking, DatePaxData $datePax)
 {
     $hotel = $this->getHotel();
     $langContext = $this->context->get('language');
     $brandContext = $this->context->get('brand', true, strtolower($hotel->getBrand()->getArtsysID()));
     $requestorId = $brandContext['parameters']['requestor.id'];
     if ($this->context->get('brand') != strtolower($hotel->getBrand()->getArtsysID())) {
         $requestorId = 0;
     }
     $parameters = array('lang' => $langContext, 'requestor.id' => $requestorId);
     if ($code = $datePax->getPromoCode()) {
         $parameters['promoCode'] = array('exclusive' => true, 'code' => $code);
     }
     $hotelAvailData = $this->reservitUtils->requestHotelAvailData($datePax, $hotel->getReservitId(), $parameters);
     if ($code && $hotelAvailData->hasWarning('U03.RIT')) {
         $booking->setPromoCodeError(true);
     } else {
         $booking->setPromoCodeError(false);
     }
     $booking->setHotelAvailData($hotelAvailData);
     $booking->setDatePaxData($datePax);
     $booking->initRoomsList();
     $booking->initSelectedRooms();
 }
 /**
  * @param ContextService $context
  */
 public function __construct(ContextService $context)
 {
     $config = $context->get('language_back', true);
     $this->format = $config['parameters']['date_format'];
 }
Example #19
0
 /**
  * Constructor.
  */
 public function __construct(ContextService $context, EntityManager $entityManager, GalittProvider $galittProvider, $defaultValues)
 {
     $this->datePax = new DatePaxData();
     $brandContext = $context->get('brand');
     if (($currentContext = $brandContext) != 'seh') {
         $repo = $entityManager->getRepository('SehBundle:Brand');
         $brand = $repo->findOneByArtsysID($currentContext);
         $this->brands = new ArrayCollection(array($brand));
     } else {
         $this->brands = new ArrayCollection();
     }
     $this->services = new ArrayCollection();
     $this->galittProvider = $galittProvider;
     $this->budget_min = $defaultValues['search'][$brandContext]['min_budget']['default'];
     $this->budget_max = $defaultValues['search'][$brandContext]['max_budget']['default'];
 }
Example #20
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $langContext = $this->context->get('language') == 'en' ? "gb" : $this->context->get('language');
     $builder->add('email', 'email', array('label' => 'form.customer.account.email.label', 'required' => true, 'error_bubbling' => false))->add('title')->add('birthDate', 'birthday', array('label' => 'form.customer.account.birthDate.label', 'widget' => 'choice', 'years' => range(date('Y'), date('Y') - 125), 'empty_value' => '', 'attr' => array('class' => 'select2')))->add('lastName', 'text', array('label' => 'form.customer.account.lastName.label', 'required' => true, 'error_bubbling' => false))->add('firstName', 'text', array('label' => 'form.customer.account.firstName.label', 'required' => true, 'error_bubbling' => false))->add('phone', 'text', array('label' => 'form.customer.account.phone.label', 'required' => false, 'error_bubbling' => false))->add('address', 'text', array('label' => 'form.customer.account.address.label', 'required' => true, 'error_bubbling' => false))->add('address2', 'text', array('label' => 'form.customer.account.address2.label', 'required' => false, 'error_bubbling' => false))->add('zipCode', 'text', array('label' => 'form.customer.account.zipCode.label', 'required' => true, 'error_bubbling' => false))->add('city', 'text', array('label' => 'form.customer.account.city.label', 'required' => true, 'error_bubbling' => false))->add('country', 'country', array('label' => 'form.customer.account.country.label', 'required' => true, 'data' => strtoupper($langContext), 'error_bubbling' => false))->add('locale', 'locale', array('required' => true, 'error_bubbling' => false));
 }
Example #21
0
 /**
  * Constructor
  *
  * @param AuthorizationChecker $securityContext
  * @param ContextService $context
  * @param EventDispatcherInterface $eventDispatcher
  */
 public function __construct(AuthorizationChecker $securityContext, ContextService $context, EventDispatcherInterface $eventDispatcher)
 {
     $this->authorizationChecker = $securityContext;
     $this->languages = $context->getValues('language_back');
     $this->eventDispatcher = $eventDispatcher;
 }