-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathChainFactory.php
52 lines (42 loc) · 1.34 KB
/
ChainFactory.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
52
<?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\Chain\Chain;
use Geocoder\Provider\Provider;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Tobias Nyholm <[email protected]>
*/
final class ChainFactory extends AbstractFactory implements LoggerAwareInterface
{
use LoggerAwareTrait;
protected static $dependencies = [
['requiredClass' => Chain::class, 'packageName' => 'geocoder-php/chain-provider'],
];
/**
* @param array{services: Provider[]} $config
*/
protected function getProvider(array $config): Provider
{
$provider = new Chain($config['services']);
if (null !== $this->logger) {
$provider->setLogger($this->logger);
}
return $provider;
}
protected static function configureOptionResolver(OptionsResolver $resolver): void
{
parent::configureOptionResolver($resolver);
$resolver->setRequired('services');
$resolver->setAllowedTypes('services', ['array']);
}
}