Skip to content

Commit

Permalink
Inject logger into chain provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Oct 2, 2019
1 parent c48a0ba commit d9cccd3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ProviderAndDumperAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
use Geocoder\ProviderAggregator;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Illuminate\Log\Logger;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Psr\Log\LoggerAwareTrait;
use ReflectionClass;

/**
Expand Down Expand Up @@ -246,11 +248,13 @@ protected function getProvidersFromConfiguration(Collection $providers) : array
$arguments = $this->getArguments($arguments, $provider);
$reflection = new ReflectionClass($provider);

if ($provider === 'Geocoder\Provider\Chain\Chain') {
if ($provider === "Geocoder\Provider\Chain\Chain") {
$chainProvider = $reflection->newInstance($arguments);

if (in_array(\Psr\Log\LoggerAwareTrait::class, class_uses($chainProvider)) && app(\Illuminate\Log\Logger::class) !== null) {
$chainProvider->setLogger(app(\Illuminate\Log\Logger::class));
if (in_array(LoggerAwareTrait::class, class_uses($chainProvider))
&& app(Logger::class) !== null
) {
$chainProvider->setLogger(app(Logger::class));
}

return $chainProvider;
Expand Down

0 comments on commit d9cccd3

Please sign in to comment.