1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* (c) Christian Gripp <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Core23\SetlistFmBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
|
19
|
|
|
final class Core23SetlistFmExtension extends Extension |
20
|
|
|
{ |
21
|
|
|
public function getAlias() |
22
|
|
|
{ |
23
|
|
|
return 'core23_setlistfm'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
27
|
|
|
{ |
28
|
|
|
$configuration = new Configuration(); |
29
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
30
|
|
|
|
31
|
|
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
32
|
|
|
$loader->load('services.xml'); |
33
|
|
|
|
34
|
|
|
$this->configureApi($container, $config); |
35
|
|
|
$this->configureHttpClient($container, $config); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
private function configureApi(ContainerBuilder $container, array $config): void |
39
|
|
|
{ |
40
|
|
|
$container->setParameter('core23_setlistfm.api.key', $config['api']['key']); |
41
|
|
|
$container->setParameter('core23_setlistfm.api.endpoint', $config['api']['endpoint']); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
private function configureHttpClient(ContainerBuilder $container, array $config): void |
45
|
|
|
{ |
46
|
|
|
$container->setAlias('core23_setlistfm.http.client', $config['http']['client']); |
47
|
|
|
$container->setAlias('core23_setlistfm.http.message_factory', $config['http']['message_factory']); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|