Skip to content

Commit 63f5a76

Browse files
committed
Added missing step in Doctrine documentation
1 parent e368c4e commit 63f5a76

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Resources/doc/doctrine.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Wouldn't it be great if you could automatically save the coordinates of a users
66
address every time it is updated? Wait not more here is the feature you been always
77
wanted.
88

9+
First of all, update your entity:
10+
911
```php
1012

1113
use Bazinga\GeocoderBundle\Mapping\Annotations as Geocoder;
@@ -30,7 +32,30 @@ class User
3032
*/
3133
private $longitude;
3234
}
35+
```
36+
37+
Secondly, register the Doctrine event listener and its dependencies in your `services.yaml` file.
38+
You have to indicate which provider to use to reverse geocode the address. Here we use `acme` provider we declared in bazinga_geocoder configuration earlier.
39+
40+
```yaml
41+
Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver:
42+
class: Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver
43+
arguments:
44+
- '@annotations.reader'
3345

46+
Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener:
47+
class: Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener
48+
arguments:
49+
- '@bazinga_geocoder.provider.acme'
50+
- '@Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver'
51+
tags:
52+
- doctrine.event_subscriber
53+
```
54+
55+
It is done!
56+
Now you can use it:
57+
58+
```php
3459
$user = new User();
3560
$user->setAddress('Brandenburger Tor, Pariser Platz, Berlin');
3661

0 commit comments

Comments
 (0)