-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from nassuf/feat/add_locationiq_provider
Add locationIQ provider
- Loading branch information
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BazingaGeocoderBundle package. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license MIT License | ||
*/ | ||
|
||
namespace Bazinga\GeocoderBundle\ProviderFactory; | ||
|
||
use Geocoder\Provider\LocationIQ\LocationIQ; | ||
use Geocoder\Provider\Provider; | ||
use Http\Discovery\HttpClientDiscovery; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
final class LocationIQFactory extends AbstractFactory | ||
{ | ||
protected static $dependencies = [ | ||
['requiredClass' => LocationIQ::class, 'packageName' => 'geocoder-php/locationiq-provider'], | ||
]; | ||
|
||
protected function getProvider(array $config): Provider | ||
{ | ||
$httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); | ||
|
||
return new LocationIQ($httplug, $config['api_key']); | ||
} | ||
|
||
protected static function configureOptionResolver(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults([ | ||
'httplug_client' => null, | ||
]); | ||
|
||
$resolver->setAllowedTypes('httplug_client', ['object', 'null']); | ||
$resolver->setRequired(['api_key']); | ||
$resolver->setAllowedTypes('api_key', ['string']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
bazinga_geocoder: | ||
profiling: | ||
enabled: false | ||
providers: | ||
acme: | ||
factory: Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory | ||
options: | ||
api_key: 'foo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters