Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know how this bundle works, but looking at the code:</p> <ul> <li>When a new provider is found (through the configuration), the <a href="https://github.com/willdurand/BazingaGeocoderBundle/blob/master/DependencyInjection/BazingaGeocoderExtension.php#L196" rel="nofollow">extension</a> will create a new <code>Definition</code> with id <code>bazinga_geocoder.provider.$name</code></li> <li>The definition is going to have a tag <code>bazinga_geocoder.provider</code> and a <strong>private</strong> visibility</li> <li>The <a href="https://github.com/willdurand/BazingaGeocoderBundle/blob/master/DependencyInjection/Compiler/AddProvidersPass.php#L47" rel="nofollow">compiler pass</a> will look for services tagged as <code>bazinga_geocoder.provider</code> and calls <code>registerProvider</code> on <code>bazinga_geocoder.geocoder</code> service, that is the <a href="https://github.com/willdurand/Geocoder/blob/master/src/Geocoder/Geocoder.php" rel="nofollow"><code>Geocoder</code></a>.</li> </ul> <p>Maybe this may work: inject the <code>bazinga_geocoder.provider.google_maps</code> service in your request listener, then call <code>$provider-&gt;setLocale($locale)</code>. I don't know hot to set the region, as there isn't a setter in the <a href="https://github.com/willdurand/Geocoder/blob/master/src/Geocoder/Provider/AbstractProvider.php" rel="nofollow"><code>AbstractProvider</code></a> class (neither in <a href="https://github.com/willdurand/Geocoder/blob/master/src/Geocoder/Provider/GoogleMapsProvider.php" rel="nofollow"><code>GoogleMapsProvider</code></a>).</p> <p>A "brutal" solution would be creating a new <code>GoogleMapsProvider</code> instance in the request listener, adding it to the geocoder. The listener should accept these services:</p> <ul> <li><code>bazinga_geocoder.geocoder.adapter</code></li> <li><code>bazinga_geocoder.geocoder</code></li> </ul> <p>That is:</p> <pre><code>use Geocoder\Geocoder; use Geocoder\Provider\GoogleMapsProvider; use Geocoder\HttpAdapter\HttpAdapterInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; class RequestListener { private $adapter; private $geo; public function __construct(HttpAdapterInterface $adapter, Geocoder $geo) { $this-&gt;adapter = $adapter; $this-&gt;geo = $geo; } public function onKernelRequest(GetResponseEvent $event) { // Get locale and region in some way // Create and register the provider, dynamically $provider = new GoogleMapsProvider($this-&gt;adapter, $locale, $region); $this-&gt;geo-&gt;registerProvider($provider); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload