1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Superdesk Web Publisher Bridge for the Content API. |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Sourcefabric z.u. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú. |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
namespace SWP\Bundle\BridgeBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* This is the class that loads and manages your bundle configuration. |
21
|
|
|
* |
22
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
23
|
|
|
*/ |
24
|
|
|
class SWPBridgeExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function load(array $configs, ContainerBuilder $container) |
30
|
|
|
{ |
31
|
|
|
$defaultOptions = array(); |
32
|
|
|
$configuration = new Configuration(); |
33
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
34
|
|
|
|
35
|
|
|
$mainKeys = array('api', 'auth'); |
36
|
|
|
foreach ($mainKeys as $mainKey) { |
37
|
|
|
if (isset($config[$mainKey])) { |
38
|
|
|
foreach ($config[$mainKey] as $key => $value) { |
39
|
|
|
if (!empty($value)) { |
40
|
|
|
$container->setParameter(sprintf('%s.%s.%s', $this->getAlias(), $mainKey, $key), $value); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (isset($config['options']) && is_array($config['options'])) { |
47
|
|
|
$defaultOptions = $config['options']; |
48
|
|
|
} |
49
|
|
|
$container->setParameter($this->getAlias().'.options', $defaultOptions); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|