1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the smsmode-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
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 WBW\Bundle\SmsModeBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
15
|
|
|
use Symfony\Component\Config\FileLocator; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
18
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
19
|
|
|
use WBW\Bundle\CoreBundle\Config\ConfigurationHelper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* sMsmode extension. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
25
|
|
|
* @package WBW\Bundle\SmsModeBundle\DependencyInjection |
26
|
|
|
*/ |
27
|
|
|
class WBWSmsModeExtension extends Extension { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Extension alias. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const EXTENSION_ALIAS = "wbw_smsmode"; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritDoc} |
38
|
|
|
*/ |
39
|
|
|
public function getAlias(): string { |
40
|
|
|
return self::EXTENSION_ALIAS; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritDoc} |
45
|
|
|
*/ |
46
|
|
|
public function load(array $configs, ContainerBuilder $container): void { |
47
|
|
|
|
48
|
|
|
$fileLocator = new FileLocator(__DIR__ . "/../Resources/config"); |
49
|
|
|
|
50
|
|
|
$serviceLoader = new YamlFileLoader($container, $fileLocator); |
51
|
|
|
$serviceLoader->load("controllers.yml"); |
52
|
|
|
$serviceLoader->load("services.yml"); |
53
|
|
|
|
54
|
|
|
/** @var ConfigurationInterface $configuration */ |
55
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
56
|
|
|
|
57
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
58
|
|
|
|
59
|
|
|
if (true === $config["event_listeners"]) { |
60
|
|
|
$serviceLoader->load("event_listeners.yml"); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (true === array_key_exists("authentication", $config)) { |
64
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config["authentication"], $this->getAlias(), "access_token"); |
65
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config["authentication"], $this->getAlias(), "pseudo"); |
66
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config["authentication"], $this->getAlias(), "pass"); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config, $this->getAlias(), "event_listeners"); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|