File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ private function geocodeEntity($entity)
9494 $ address = $ metadata ->addressProperty ->getValue ($ entity );
9595 }
9696
97+ if (empty ($ address )) {
98+ return ;
99+ }
100+
97101 $ results = $ this ->geocoder ->geocodeQuery (GeocodeQuery::create ($ address ));
98102
99103 if (!empty ($ results )) {
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ protected function setUp()
7575 $ sm = new SchemaTool ($ this ->em );
7676 $ sm ->createSchema ([
7777 $ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithProperty ' ),
78+ $ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithEmptyProperty ' ),
7879 $ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithGetter ' ),
7980 $ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithInvalidGetter ' ),
8081 ]);
@@ -133,6 +134,18 @@ public function testPersistForInvalidGetter()
133134
134135 $ this ->em ->flush ();
135136 }
137+
138+ public function testPersistForEmptyProperty ()
139+ {
140+ $ dummy = new DummyWithEmptyProperty ();
141+ $ dummy ->address = '' ;
142+
143+ $ this ->em ->persist ($ dummy );
144+ $ this ->em ->flush ();
145+
146+ $ this ->assertNull ($ dummy ->latitude );
147+ $ this ->assertNull ($ dummy ->longitude );
148+ }
136149}
137150
138151/**
@@ -291,3 +304,34 @@ public function setLongitude($longitude)
291304 $ this ->longitude = $ longitude ;
292305 }
293306}
307+
308+ /**
309+ * @Geocodeable
310+ * @Entity
311+ */
312+ class DummyWithEmptyProperty
313+ {
314+ /**
315+ * @Id @GeneratedValue
316+ * @Column(type="integer")
317+ */
318+ public $ id ;
319+
320+ /**
321+ * @Latitude
322+ * @Column(nullable=true)
323+ */
324+ public $ latitude ;
325+
326+ /**
327+ * @Longitude
328+ * @Column(nullable=true)
329+ */
330+ public $ longitude ;
331+
332+ /**
333+ * @Address
334+ * @Column
335+ */
336+ public $ address ;
337+ }
You can’t perform that action at this time.
0 commit comments