1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CLSlackBundle. |
5
|
|
|
* |
6
|
|
|
* (c) Cas Leentfaar <[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 CL\Bundle\SlackBundle\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
|
|
|
/** |
20
|
|
|
* @author Cas Leentfaar <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class CLSlackExtension extends Extension |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @param array[] $configs |
26
|
|
|
* @param ContainerBuilder $container |
27
|
|
|
*/ |
28
|
2 |
|
public function load(array $configs, ContainerBuilder $container) |
29
|
|
|
{ |
30
|
2 |
|
$configuration = new Configuration(); |
31
|
2 |
|
$config = $this->processConfiguration($configuration, $configs); |
32
|
|
|
|
33
|
2 |
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
34
|
2 |
|
$loader->load('services.yml'); |
35
|
|
|
|
36
|
2 |
|
$this->setParameters($container, $config); |
37
|
2 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param ContainerBuilder $container |
41
|
|
|
* @param string[] $config |
42
|
|
|
*/ |
43
|
2 |
|
protected function setParameters(ContainerBuilder $container, array $config) |
44
|
|
|
{ |
45
|
2 |
|
$container->setParameter('cl_slack.api_token', $config['api_token']); |
46
|
2 |
|
$container->setParameter('cl_slack.test', $config['test']); |
47
|
2 |
|
} |
48
|
|
|
} |
49
|
|
|
|