Ejemplo n.º 1
0
 /**
  * Converts PHP representation to the SQL value.
  *
  * @param Point            $value    specific point
  * @param AbstractPlatform $platform DB platform
  *
  * @return string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return;
     }
     return sprintf('(%F,%F)', $value->getLatitude(), $value->getLongitude());
 }
Ejemplo n.º 2
0
 /**
  * Converts PHP representation to the SQL value.
  *
  * @param Point            $value    specific point
  * @param AbstractPlatform $platform DB platform
  *
  * @return string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return null;
     }
     if ($platform instanceof MySqlPlatform) {
         $format = "POINT(%F %F)";
     } else {
         $format = "(%F, %F)";
     }
     return sprintf($format, $value->getLatitude(), $value->getLongitude());
 }
Ejemplo n.º 3
0
 protected function getEventManager()
 {
     $em = new EventManager();
     $em->addEventSubscriber(new \Knp\DoctrineBehaviors\ORM\Geocodable\GeocodableSubscriber(new ClassAnalyzer(), false, 'Knp\\DoctrineBehaviors\\Model\\Geocodable\\Geocodable', function ($entity) {
         if ($location = $entity->getLocation()) {
             return $location;
         }
         return Point::fromArray(['longitude' => 47.7, 'latitude' => 7.9]);
     }));
     return $em;
 }
Ejemplo n.º 4
0
 protected function getEventManager()
 {
     $em = new EventManager();
     $em->addEventSubscriber(new \Knp\DoctrineBehaviors\ORM\Geocodable\GeocodableListener(function ($entity) {
         if ($location = $entity->getLocation()) {
             return $location;
         }
         return Point::fromArray(['longitude' => 47.7, 'latitude' => 7.9]);
     }));
     return $em;
 }
 public function findByDistanceQB(Point $point, $distanceMax)
 {
     return $this->createQueryBuilder('e')->andWhere('DISTANCE(e.location, :latitude, :longitude) <= :distanceMax')->setParameter('latitude', $point->getLatitude())->setParameter('longitude', $point->getLongitude())->setParameter('distanceMax', $distanceMax);
 }