From 640efafa921911913bc742ccb34f0cd513e37399 Mon Sep 17 00:00:00 2001 From: AntoineLemaire Date: Thu, 12 Feb 2015 16:50:39 +0100 Subject: [PATCH] Allow locale change with chain Fix coding standards Prevent logical error https://github.com/geocoder-php/Geocoder/pull/408#discussion_r24653135 --- src/Geocoder/Provider/Chain.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Geocoder/Provider/Chain.php b/src/Geocoder/Provider/Chain.php index 1bb491f84..10c46caaa 100644 --- a/src/Geocoder/Provider/Chain.php +++ b/src/Geocoder/Provider/Chain.php @@ -16,8 +16,10 @@ /** * @author Markus Bachmann */ -class Chain implements Provider +class Chain implements LocaleAwareProvider { + use LocaleTrait; + /** * @var Provider[] */ @@ -38,6 +40,10 @@ public function geocode($address) { $exceptions = []; foreach ($this->providers as $provider) { + if ($provider instanceof LocaleAwareProvider && $this->getLocale() !== null){ + $provider = clone $provider; + $provider->setLocale($this->getLocale()); + } try { return $provider->geocode($address); } catch (InvalidCredentials $e) {