-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathGoogleMapsFactory.php
43 lines (35 loc) · 1.31 KB
/
GoogleMapsFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?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\Bundle\GeocoderBundle\ProviderFactory;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Http\Client\HttpClient;
use Http\Discovery\HttpClientDiscovery;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class GoogleMapsFactory extends AbstractFactory
{
protected static $dependencies = [
['requiredClass' => GoogleMaps::class, 'packageName' => 'geocoder-php/google-maps-provider'],
];
protected function getProvider(array $config)
{
$httplug = $config['httplug_client'] ?: HttpClientDiscovery::find();
return new GoogleMaps($httplug, $config['region'], $config['api_key']);
}
protected static function configureOptionResolver(OptionsResolver $resolver)
{
$resolver->setDefaults([
'httplug_client' => null,
'region' => null,
'api_key' => null,
]);
$resolver->setAllowedTypes('httplug_client', [HttpClient::class, 'null']);
$resolver->setAllowedTypes('region', ['string', 'null']);
$resolver->setAllowedTypes('api_key', ['string', 'null']);
}
}