Dont set the longitude or latitude if nothing is set.

This commit is contained in:
Tim Schumacher 2014-07-11 20:10:10 +02:00
parent 2fce8b3cfd
commit 75a2ef9796

View file

@ -84,16 +84,24 @@ class EventController extends Controller
$results = $repo->findBy(['name' => $location]); $results = $repo->findBy(['name' => $location]);
if (count($results) > 0) { if (count($results) > 0) {
$location_obj = $results[0]; $location_obj = $results[0];
$location_obj->setLat($location_lat); if (strlen($location_lat) > 0) {
$location_obj->setLon($location_lon); $location_obj->setLat($location_lat);
}
if (strlen($location_lon) > 0) {
$location_obj->setLon($location_lon);
}
$em->persist($location_obj); $em->persist($location_obj);
$em->flush(); $em->flush();
$entity->setLocation($results[0]); $entity->setLocation($results[0]);
} else { } else {
$location_obj = new Location(); $location_obj = new Location();
$location_obj->setName($location); $location_obj->setName($location);
$location_obj->setLat($location_lat); if (strlen($location_lat) > 0) {
$location_obj->setLon($location_lon); $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')); $location_obj->setSlug(\URLify::filter($location_obj->getName(),255,'de'));
$em->persist($location_obj); $em->persist($location_obj);
$em->flush(); $em->flush();
@ -253,16 +261,24 @@ class EventController extends Controller
$results = $repo->findBy(['name' => $location]); $results = $repo->findBy(['name' => $location]);
if (count($results) > 0) { if (count($results) > 0) {
$location_obj = $results[0]; $location_obj = $results[0];
$location_obj->setLat($location_lat); if (strlen($location_lat) > 0) {
$location_obj->setLon($location_lon); $location_obj->setLat($location_lat);
}
if (strlen($location_lon) > 0) {
$location_obj->setLon($location_lon);
}
$em->persist($location_obj); $em->persist($location_obj);
$em->flush(); $em->flush();
$entity->setLocation($results[0]); $entity->setLocation($results[0]);
} else { } else {
$location_obj = new Location(); $location_obj = new Location();
$location_obj->setName($location); $location_obj->setName($location);
$location_obj->setLat($location_lat); if (strlen($location_lat) > 0) {
$location_obj->setLon($location_lon); $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')); $location_obj->setSlug(\URLify::filter($location_obj->getName(),255,'de'));
$em->persist($location_obj); $em->persist($location_obj);
$em->flush(); $em->flush();