Skip to content

Commit b620b4b

Browse files
norkunasNyholm
authored andcommitted
Add docs about autowiring (#236)
1 parent 0962e7d commit b620b4b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Resources/doc/index.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,41 @@ bazinga_geocoder:
129129

130130
The `services` key could also be as follows `services: ['@my_geocoder', '@my_geocoder_ii']`. Notice these are the values from the `aliases` key.
131131

132+
### Autowiring Providers
133+
134+
If you're using Symfony 4.3 and autowiring you can use bindings provided
135+
the bundle.
136+
137+
```yaml
138+
bazinga_geocoder:
139+
providers:
140+
googleMaps:
141+
factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
142+
```
143+
144+
```php
145+
<?php
146+
147+
namespace App\Service;
148+
149+
use Geocoder\Provider\Provider;
150+
151+
class MyService
152+
{
153+
private $googleMapsGeocoder;
154+
155+
public function __construct(Provider $googleMapsGeocoder)
156+
{
157+
$this->googleMapsGeocoder = $googleMapsGeocoder;
158+
}
159+
}
160+
```
161+
162+
Each configured provider has a binding in the following format:
163+
`providerName + Geocoder`.
164+
165+
In the example we configured provider name as `googleMaps` so the argument is `$googleMapsGeocoder`.
166+
132167
### Fake local ip
133168

134169
You can fake your local IP through this bundle in order to get location

0 commit comments

Comments
 (0)