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