File tree 2 files changed +48
-0
lines changed
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)
94
94
$ address = $ metadata ->addressProperty ->getValue ($ entity );
95
95
}
96
96
97
+ if (empty ($ address )) {
98
+ return ;
99
+ }
100
+
97
101
$ results = $ this ->geocoder ->geocodeQuery (GeocodeQuery::create ($ address ));
98
102
99
103
if (!empty ($ results )) {
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ protected function setUp()
75
75
$ sm = new SchemaTool ($ this ->em );
76
76
$ sm ->createSchema ([
77
77
$ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithProperty ' ),
78
+ $ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithEmptyProperty ' ),
78
79
$ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithGetter ' ),
79
80
$ this ->em ->getClassMetadata ('Bazinga\GeocoderBundle\Tests\Doctrine\ORM\DummyWithInvalidGetter ' ),
80
81
]);
@@ -133,6 +134,18 @@ public function testPersistForInvalidGetter()
133
134
134
135
$ this ->em ->flush ();
135
136
}
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
+ }
136
149
}
137
150
138
151
/**
@@ -291,3 +304,34 @@ public function setLongitude($longitude)
291
304
$ this ->longitude = $ longitude ;
292
305
}
293
306
}
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