-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathArcGISOnlineFactory.php
51 lines (41 loc) · 1.74 KB
/
ArcGISOnlineFactory.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
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
/*
* 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\ArcGISOnline\ArcGISOnline;
use Geocoder\Provider\Provider;
use Http\Discovery\HttpClientDiscovery;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class ArcGISOnlineFactory extends AbstractFactory
{
protected static $dependencies = [
['requiredClass' => ArcGISOnline::class, 'packageName' => 'geocoder-php/arcgis-online-provider'],
];
/**
* @param array{source_country: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
*/
protected function getProvider(array $config): Provider
{
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? HttpClientDiscovery::find();
return new ArcGISOnline($httpClient, $config['source_country']);
}
protected static function configureOptionResolver(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'httplug_client' => null,
'http_client' => null,
'source_country' => null,
]);
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
$resolver->setAllowedTypes('http_client', ['object', 'null']);
$resolver->setAllowedTypes('source_country', ['string', 'null']);
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
}
}