Skip to content

Commit f1509e0

Browse files
committed
Fix loading of GeoIP2 provider within Chain provider
1 parent 6934692 commit f1509e0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/ProviderAndDumperAggregator.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,33 @@ protected function getArguments(array $arguments, string $provider) : array
226226
}
227227

228228
$adapter = $this->getAdapterClass($provider);
229+
$reader = null;
229230

230231
if ($adapter) {
231-
array_unshift($arguments, (new $adapter));
232+
if ($this->requiresReader($provider)) {
233+
$reader = config('geocoder.reader');
234+
}
235+
236+
array_unshift($arguments, new $adapter($reader));
232237
}
233238

234239
return $arguments;
235240
}
236241

242+
protected function requiresReader(string $class) : bool
243+
{
244+
$specificAdapters = collect([
245+
'Geocoder\Provider\GeoIP2\GeoIP2',
246+
]);
247+
248+
return $specificAdapters->contains($class);
249+
}
250+
237251
protected function getAdapterClass(string $provider) : string
238252
{
239253
$specificAdapters = collect([
240-
'Geocoder\Provider\GeoIP2' => 'Geocoder\Adapter\GeoIP2Adapter',
241-
'Geocoder\Provider\MaxMindBinary' => null,
254+
'Geocoder\Provider\GeoIP2\GeoIP2' => 'Geocoder\Provider\GeoIP2\GeoIP2Adapter',
255+
'Geocoder\Provider\MaxMindBinary\MaxMindBinary' => '',
242256
]);
243257

244258
if ($specificAdapters->has($provider)) {

0 commit comments

Comments
 (0)