1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This is part of the webuni/commonmark-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Martin Hasoň <[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 Webuni\Bundle\CommonMarkBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
16
|
|
|
|
17
|
|
|
class Configuration implements ConfigurationInterface |
18
|
|
|
{ |
19
|
|
|
public function getConfigTreeBuilder() |
20
|
|
|
{ |
21
|
|
|
$builder = new TreeBuilder(); |
22
|
|
|
|
23
|
|
|
$builder->root('webuni_commonmark', 'array') |
24
|
|
|
->addDefaultsIfNotSet() |
25
|
|
|
->children() |
26
|
|
|
->scalarNode('default_converter')->defaultValue('default')->end() |
27
|
|
|
->arrayNode('extensions') |
28
|
|
|
->addDefaultsIfNotSet() |
29
|
|
|
->children() |
30
|
|
|
->booleanNode('attributes')->defaultTrue()->end() |
31
|
|
|
->booleanNode('table')->defaultTrue()->end() |
32
|
|
|
->end() |
33
|
|
|
->end() |
34
|
|
|
->arrayNode('converters') |
35
|
|
|
->defaultValue(['default' => [ |
36
|
|
|
'converter' => 'webuni_commonmark.converter', |
37
|
|
|
'environment' => 'webuni_commonmark.default_environment', |
38
|
|
|
'parser' => 'webuni_commonmark.docparser', |
39
|
|
|
'renderer' => 'webuni_commonmark.htmlrenderer', |
40
|
|
|
'config' => [], |
41
|
|
|
'extensions' => [], |
42
|
|
|
]]) |
43
|
|
|
->beforeNormalization() |
44
|
|
|
->always() |
45
|
|
|
->then(function ($v) { |
46
|
|
|
return array_merge(['default' => null], $v); |
47
|
|
|
}) |
48
|
|
|
->end() |
49
|
|
|
->prototype('array') |
50
|
|
|
->addDefaultsIfNotSet() |
51
|
|
|
->children() |
52
|
|
|
->scalarNode('converter')->defaultValue('webuni_commonmark.converter')->end() |
53
|
|
|
->scalarNode('environment')->defaultValue('webuni_commonmark.default_environment')->end() |
54
|
|
|
->scalarNode('parser')->defaultValue('webuni_commonmark.docparser')->end() |
55
|
|
|
->scalarNode('renderer')->defaultValue('webuni_commonmark.htmlrenderer')->end() |
56
|
|
|
->arrayNode('config') |
57
|
|
|
->prototype('variable') |
58
|
|
|
->defaultValue([]) |
59
|
|
|
->end() |
60
|
|
|
->end() |
61
|
|
|
->arrayNode('extensions') |
62
|
|
|
->defaultValue([]) |
63
|
|
|
->prototype('scalar')->end() |
64
|
|
|
->end() |
65
|
|
|
->end() |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->end() |
69
|
|
|
; |
70
|
|
|
|
71
|
|
|
return $builder; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|