You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/doctrine.md
+13-21Lines changed: 13 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
-
# Doctrine annotation support
1
+
# Doctrine support
2
2
3
3
*[<< Back to documentation index](/doc/index.md)*
4
4
5
-
Wouldn't it be great if you could automatically save the coordinates of a users
6
-
address every time it is updated? Wait not more here is the feature you been always
7
-
wanted.
5
+
Wouldn't it be great if you could automatically save the coordinates of a user's
6
+
address every time it is updated? Well, wait no more—here is the feature you've
7
+
always wanted!
8
8
9
9
First of all, update your entity:
10
10
11
11
```php
12
12
13
13
use Bazinga\GeocoderBundle\Mapping\Attributes as Geocoder;
14
14
15
-
#[Geocoder\Geocodeable()]
15
+
#[Geocoder\Geocodeable(provider: 'acme')]
16
16
class User
17
17
{
18
18
#[Geocoder\Address()]
@@ -32,7 +32,7 @@ Instead of annotating a property, you can also annotate a getter:
32
32
33
33
use Bazinga\GeocoderBundle\Mapping\Attributes as Geocoder;
34
34
35
-
#[Geocoder\Geocodeable()]
35
+
#[Geocoder\Geocodeable(provider: 'acme')]
36
36
class User
37
37
{
38
38
#[Geocoder\Latitude()]
@@ -42,36 +42,28 @@ class User
42
42
private $longitude;
43
43
44
44
#[Geocoder\Address()]
45
-
public function getAddress(): string
45
+
public function getAddress(): \Stringable|string
46
46
{
47
47
// Your code...
48
48
}
49
49
}
50
50
```
51
51
52
-
Secondly, register the Doctrine event listener and its dependencies in your `config/services.yaml` or `config/services.php` file.
53
-
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.
52
+
Secondly, enable Doctrine ORM listener in the configuration:
0 commit comments