예제 #1
0
 /**
  * Get array of AddressHandleDTOs with size of one containing the users home address associated with the given
  * user id
  *
  * @param $passengerId
  * @return mixed
  */
 public function getAddressHandleByPassengerId($passengerId)
 {
     $handleDtos = array();
     $passengerRepository = $this->container->get('passenger_repository');
     $passenger = $passengerRepository->find($passengerId);
     if ($passenger) {
         $handleDtos[] = AddressHandleAssembler::toAddressHandleDTO($passenger->getAddress());
     }
     return $handleDtos;
 }
 /**
  * @param $lookupStr
  * @return array|mixed
  */
 protected function getAddressHandlingDTOs($lookupStr)
 {
     $searchString = $this->constructFulltextSearchString($lookupStr);
     $rsm = new ResultSetMappingBuilder($this->getEntityManager());
     $rsm->addRootEntityFromClassMetadata('Tixi\\CoreDomain\\Address', 'a');
     $sql = "SELECT a.id, a.street, a.postalCode, a.city, a.country, a.lat, a.lng, a.source FROM address a\n        WHERE MATCH (name, street, postalCode, city, country, source)\n        AGAINST ('.{$searchString}.' IN BOOLEAN MODE) AND a.isDeleted = 0\n        LIMIT 0, " . $this->getLookupLimit();
     $query = $this->getEntityManager()->createNativeQuery($sql, $rsm);
     $results = $query->getResult();
     $addresses = array();
     /** @var $result Address */
     foreach ($results as $result) {
         $addresses[] = AddressHandleAssembler::toAddressHandleDTO($result);
     }
     return $addresses;
 }
 /**
  * @param $lookupStr
  * @return array|mixed
  */
 protected function getAddressHandlingDTOs($lookupStr)
 {
     $searchString = $this->constructFulltextSearchString($lookupStr);
     $rsm = new ResultSetMappingBuilder($this->getEntityManager());
     $rsm->addRootEntityFromClassMetadata('Tixi\\CoreDomain\\POI', 'p');
     $sql = "SELECT p.id, p.name FROM poi p\n        WHERE MATCH (p.name)\n        AGAINST ('.{$searchString}.' IN BOOLEAN MODE) AND p.isDeleted = 0\n        LIMIT 0, " . $this->getLookupLimit();
     $query = $this->getEntityManager()->createNativeQuery($sql, $rsm);
     $results = $query->getResult();
     $addresses = array();
     /** @var POIRepository $poiRepository */
     $poiRepository = $this->container->get('poi_repository');
     foreach ($results as $result) {
         /** @var POI $poi */
         $id = $result->getId();
         $this->getEntityManager()->close();
         $poi = $poiRepository->find($id);
         $address = $poi->getAddress();
         $addresses[] = AddressHandleAssembler::toAddressHandleDTO($address);
     }
     return $addresses;
 }