Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 /**
  * @param GetResponseEvent $event
  */
 public function onLateKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     $locale = $this->context->get('language');
     $request->setLocale($locale);
     $this->translationListener->setTranslatableLocale($locale);
 }
Exemplo n.º 3
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');
         }));
     }
 }
Exemplo n.º 4
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')));
 }
Exemplo n.º 5
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')))));
 }
Exemplo n.º 6
0
 /**
  * @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;
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
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 '#';
 }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
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'];
 }
Exemplo n.º 14
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'];
 }
Exemplo n.º 15
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));
 }
Exemplo n.º 16
0
 /**
  * @param array $params
  *
  * @return array
  */
 public function getResults(array $params)
 {
     $locale = $this->context->get('language');
     $brand = $this->context->get('brand');
     $brands = array_keys($this->context->getValues('brand'));
     $results = array();
     $params = array_merge(array('term' => '', 'method' => 'lieu'), $params);
     if ('lieu' == ($method = $params['method'])) {
         $params['term'] = '';
     }
     $term = $params['term'];
     $localizedNameField = sprintf('names.%s', $locale);
     if (!in_array($method, array('lieu', 'location'))) {
         $queryBrands = array($brand);
         $brandTerms = array();
         if ('seh' == $brand) {
             $queryBrands = array_diff($brands, $queryBrands);
         }
         foreach ($queryBrands as $queryBrand) {
             $brandTerms[] = array('term' => array('brandSlug' => $queryBrand));
         }
         $queryArray = array('query' => array('filtered' => array('query' => array('match' => array('name' => array('query' => $term, 'operator' => 'and'))), 'filter' => array('bool' => array('should' => $brandTerms)))), 'sort' => array('name' => 'asc'));
         $query = new Query();
         $query->setParams($queryArray);
         $hotels = $this->hotelType->search($query);
         /** @var Result $hotel */
         foreach ($hotels as $hotel) {
             $hotel = $hotel->getSource();
             if ($hotel['active']) {
                 $result = array('brand' => $hotel['brandName'], 'brandId' => strtolower($hotel['brandSlug']), 'label' => (isset($params['hotel_name_brand']) and $params['hotel_name_brand']) ? sprintf('%s %s', $hotel['brandName'], $hotel['name']) : $hotel['name'], 'typeResult' => 'hotel', 'id' => $hotel['id'], 'activeLocationId' => $hotel['cityId'], 'nbResults' => '', 'category' => $this->translator->trans('form.search.autocomplete.hotels'), 'cssClass' => 'lvl1', 'latLng' => $hotel['latLng']);
                 if ($method == 'lieu') {
                     $result['type'] = 'lieu';
                 }
                 $results[] = $result;
             }
         }
     }
     if (!in_array($method, array('lieu', 'hotel'))) {
         $queryBrands = array($brand);
         $brandTerms = array();
         if ('seh' == $brand) {
             $queryBrands = array_diff($brands, $queryBrands);
         }
         foreach ($queryBrands as $queryBrand) {
             $brandTerms[] = array('range' => array($queryBrand => array('gt' => 0)));
         }
         $queryArray = array('query' => array('filtered' => array('query' => array('match' => array($localizedNameField => array('query' => $term, 'operator' => 'and'))), 'filter' => array('bool' => array('should' => $brandTerms)))), 'sort' => array($localizedNameField => 'asc'));
         $query = new Query();
         $query->setParams($queryArray);
         $cities = $this->cityType->search($query);
         /** @var Result $city */
         foreach ($cities as $city) {
             $city = $city->getSource();
             $results[] = array('label' => $city['names'][$locale], 'typeResult' => 'city', 'id' => $city['id'], 'activeLocationId' => sprintf('city%s', $city['id']), 'nbResults' => '', 'category' => $this->translator->trans('form.search.autocomplete.cities'), 'cssClass' => 'lvl1');
         }
     }
     if (!in_array($method, array('hotel', 'location'))) {
         $queryBrands = array($brand);
         $brandTerms = array();
         if ('seh' == $brand) {
             $queryBrands = array_diff($brands, $queryBrands);
         }
         foreach ($queryBrands as $queryBrand) {
             $brandTerms[] = array('range' => array($queryBrand => array('gt' => 0)));
         }
         $queryArray = array('query' => array('filtered' => array('query' => array('match' => array($localizedNameField => array('query' => $term, 'operator' => 'and'))), 'filter' => array('bool' => array('should' => $brandTerms)))), 'sort' => array($localizedNameField => 'asc'));
         $query = new Query();
         $query->setParams($queryArray);
         $departments = $this->departmentType->search($query);
         /** @var Result $department */
         foreach ($departments as $department) {
             $department = $department->getSource();
             $cityIds = $department['citiesIds'];
             $cityIds = array_map(function ($cityId) {
                 return sprintf('city%s', $cityId);
             }, $cityIds);
             $result = array('label' => $department['names'][$locale], 'typeResult' => 'department', 'id' => $department['id'], 'activeLocationId' => implode(',', $cityIds), 'nbResults' => '', 'category' => $this->translator->trans('form.search.autocomplete.departments'), 'cssClass' => 'lvl1');
             if ($method == 'lieu') {
                 $result['type'] = 'lieu';
                 $result['cssClass'] = 'lvl3';
             }
             $results[] = $result;
         }
     }
     if (!in_array($method, array('hotel'))) {
         $queryBrands = array($brand);
         $brandTerms = array();
         if ('seh' == $brand) {
             $queryBrands = array_diff($brands, $queryBrands);
         }
         foreach ($queryBrands as $queryBrand) {
             $brandTerms[] = array('range' => array($queryBrand => array('gt' => 0)));
         }
         $queryArray = array('query' => array('filtered' => array('query' => array('match' => array($localizedNameField => array('query' => $term, 'operator' => 'and'))), 'filter' => array('bool' => array('should' => $brandTerms)))), 'sort' => array($localizedNameField => 'asc'));
         $query = new Query();
         $query->setParams($queryArray);
         $regions = $this->regionType->search($query);
         /** @var Result $region */
         foreach ($regions as $region) {
             $region = $region->getSource();
             $result = array('label' => $region['names'][$locale], 'typeResult' => 'region', 'id' => $region['id'], 'activeLocationId' => sprintf('region%s', $region['id']), 'nbResults' => '', 'category' => $this->translator->trans('form.search.autocomplete.regions'), 'cssClass' => 'lvl1');
             if ($method == 'lieu') {
                 $result['type'] = 'lieu';
                 $result['cssClass'] = 'lvl2';
             }
             $results[] = $result;
         }
     }
     if (!in_array($method, array('hotel'))) {
         $queryBrands = array($brand);
         $brandTerms = array();
         if ('seh' == $brand) {
             $queryBrands = array_diff($brands, $queryBrands);
         }
         foreach ($queryBrands as $queryBrand) {
             $brandTerms[] = array('range' => array($queryBrand => array('gt' => 0)));
         }
         $queryArray = array('query' => array('filtered' => array('query' => array('match' => array($localizedNameField => array('query' => $term, 'operator' => 'and'))), 'filter' => array('bool' => array('should' => $brandTerms)))), 'sort' => array($localizedNameField => 'asc'));
         $query = new Query();
         $query->setParams($queryArray);
         $countries = $this->countryType->search($query);
         /** @var Result $country */
         foreach ($countries as $country) {
             $country = $country->getSource();
             $result = array('label' => $country['names'][$locale], 'typeResult' => 'country', 'id' => $country['id'], 'activeLocationId' => sprintf('country%s', $country['id']), 'nbResults' => '', 'category' => $this->translator->trans('form.search.autocomplete.countries'), 'cssClass' => 'lvl1');
             if ($method == 'lieu') {
                 $result['type'] = 'lieu';
             }
             $results[] = $result;
         }
     }
     return $results;
 }