From 75a2ef979680dec84deb538e22573eeadc5b95f3 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 11 Jul 2014 20:10:10 +0200 Subject: [PATCH] Dont set the longitude or latitude if nothing is set. --- .../Controller/EventController.php | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php index 1b0d649..18dd67d 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php @@ -84,16 +84,24 @@ class EventController extends Controller $results = $repo->findBy(['name' => $location]); if (count($results) > 0) { $location_obj = $results[0]; - $location_obj->setLat($location_lat); - $location_obj->setLon($location_lon); + if (strlen($location_lat) > 0) { + $location_obj->setLat($location_lat); + } + if (strlen($location_lon) > 0) { + $location_obj->setLon($location_lon); + } $em->persist($location_obj); $em->flush(); $entity->setLocation($results[0]); } else { $location_obj = new Location(); $location_obj->setName($location); - $location_obj->setLat($location_lat); - $location_obj->setLon($location_lon); + if (strlen($location_lat) > 0) { + $location_obj->setLat($location_lat); + } + if (strlen($location_lon) > 0) { + $location_obj->setLon($location_lon); + } $location_obj->setSlug(\URLify::filter($location_obj->getName(),255,'de')); $em->persist($location_obj); $em->flush(); @@ -253,16 +261,24 @@ class EventController extends Controller $results = $repo->findBy(['name' => $location]); if (count($results) > 0) { $location_obj = $results[0]; - $location_obj->setLat($location_lat); - $location_obj->setLon($location_lon); + if (strlen($location_lat) > 0) { + $location_obj->setLat($location_lat); + } + if (strlen($location_lon) > 0) { + $location_obj->setLon($location_lon); + } $em->persist($location_obj); $em->flush(); $entity->setLocation($results[0]); } else { $location_obj = new Location(); $location_obj->setName($location); - $location_obj->setLat($location_lat); - $location_obj->setLon($location_lon); + if (strlen($location_lat) > 0) { + $location_obj->setLat($location_lat); + } + if (strlen($location_lon) > 0) { + $location_obj->setLon($location_lon); + } $location_obj->setSlug(\URLify::filter($location_obj->getName(),255,'de')); $em->persist($location_obj); $em->flush();