1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 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\BootstrapBundle\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\DependencyInjection\ConfigurationHelper; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Bootstrap extension. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb/> |
25
|
|
|
* @package WBW\Bundle\BootstrapBundle\DependencyInjection |
26
|
|
|
*/ |
27
|
|
|
class WBWBootstrapExtension extends Extension { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Extension alias. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const EXTENSION_ALIAS = "wbw_bootstrap"; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritDoc} |
38
|
|
|
*/ |
39
|
|
|
public function load(array $configs, ContainerBuilder $container): void { |
40
|
|
|
|
41
|
|
|
$fileLocator = new FileLocator(__DIR__ . "/../Resources/config"); |
42
|
|
|
|
43
|
|
|
$serviceLoader = new YamlFileLoader($container, $fileLocator); |
44
|
|
|
$serviceLoader->load("services.yml"); |
45
|
|
|
|
46
|
|
|
/** @var ConfigurationInterface $configuration */ |
47
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
48
|
|
|
|
49
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
50
|
|
|
|
51
|
|
|
if (true === $config["twig"]) { |
52
|
|
|
$serviceLoader->load("twig.yml"); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config, $this->getAlias(), "twig"); |
56
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config, $this->getAlias(), "version"); |
57
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config, $this->getAlias(), "plugins"); |
58
|
|
|
ConfigurationHelper::registerContainerParameter($container, $config, $this->getAlias(), "locales"); |
59
|
|
|
|
60
|
|
|
$assets = ConfigurationHelper::loadYamlConfig(__DIR__, "assets"); |
61
|
|
|
ConfigurationHelper::registerContainerParameters($container, $assets["assets"]); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|