Skip to content

Commit 4186cd1

Browse files
DamienHarpernorkunas
authored andcommitted
Exposes Here provider to the bundle (#222)
* Exposes Here provider to the bundle * Add support to Here CIT (Customer Integration Testing) environment * app_id and app_code must not be null * app_id and app_code are required * Add dev requirement regarding geocoder-php/here-provider * Add relevant functional test config regarding geocoder-php/here-provider
1 parent 66cac05 commit 4186cd1

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

ProviderFactory/HereFactory.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the BazingaGeocoderBundle package.
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*
10+
* @license MIT License
11+
*/
12+
13+
namespace Bazinga\GeocoderBundle\ProviderFactory;
14+
15+
use Geocoder\Provider\Here\Here;
16+
use Geocoder\Provider\Provider;
17+
use Http\Discovery\HttpClientDiscovery;
18+
use Symfony\Component\OptionsResolver\OptionsResolver;
19+
20+
final class HereFactory extends AbstractFactory
21+
{
22+
protected static $dependencies = [
23+
['requiredClass' => Here::class, 'packageName' => 'geocoder-php/here-provider'],
24+
];
25+
26+
protected function getProvider(array $config): Provider
27+
{
28+
$httplug = $config['httplug_client'] ?: HttpClientDiscovery::find();
29+
30+
return new Here($httplug, $config['app_id'], $config['app_code'], $config['use_cit']);
31+
}
32+
33+
protected static function configureOptionResolver(OptionsResolver $resolver)
34+
{
35+
$resolver->setDefaults([
36+
'httplug_client' => null,
37+
'use_cit' => false,
38+
]);
39+
40+
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
41+
$resolver->setAllowedTypes('use_cit', ['bool', 'false']);
42+
$resolver->setRequired(['app_id', 'app_code']);
43+
}
44+
}

Resources/doc/services.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Here is a list of all provider factories and their options.
2020
| `Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory` | httplug_client, username
2121
| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | httplug_client
2222
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | httplug_client, api_key, region
23+
| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | httplug_client, app_id, app_code, use_cit
2324
| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | httplug_client
2425
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | httplug_client
2526
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | httplug_client, api_key, precision

Tests/Functional/ProviderFactoryTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Geocoder\Provider\Geonames\Geonames;
2424
use Geocoder\Provider\GeoPlugin\GeoPlugin;
2525
use Geocoder\Provider\GoogleMaps\GoogleMaps;
26+
use Geocoder\Provider\Here\Here;
2627
use Geocoder\Provider\HostIp\HostIp;
2728
use Geocoder\Provider\IpInfo\IpInfo;
2829
use Geocoder\Provider\IpInfoDb\IpInfoDb;
@@ -66,6 +67,7 @@ public function getProviders()
6667
[Geonames::class, ['acme']],
6768
[GeoPlugin::class, ['empty']],
6869
[GoogleMaps::class, ['empty']],
70+
[Here::class, ['acme']],
6971
[HostIp::class, ['empty']],
7072
[IpInfo::class, ['acme']],
7173
[IpInfoDb::class, ['empty', 'acme']],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bazinga_geocoder:
2+
profiling:
3+
enabled: false
4+
providers:
5+
acme:
6+
factory: Bazinga\GeocoderBundle\ProviderFactory\HereFactory
7+
options:
8+
app_id: 'foo'
9+
app_code: 'bar'

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"geocoder-php/geonames-provider": "^4.0",
4040
"geocoder-php/geoips-provider": "^4.0",
4141
"geocoder-php/geoip2-provider": "^4.0",
42+
"geocoder-php/here-provider": "^0.2",
4243
"geocoder-php/ip-info-provider": "^0.1",
4344
"geocoder-php/ip-info-db-provider": "^4.0",
4445
"geocoder-php/ipstack-provider": "^0.1",

0 commit comments

Comments
 (0)