1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\DependencyInjection; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
14
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
15
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* RouteGuardBundle configuration structure. |
19
|
|
|
* |
20
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Configuration implements ConfigurationInterface |
23
|
|
|
{ |
24
|
|
|
private static $symfonyControllers = [ |
25
|
|
|
'twig.controller.preview_error', // 'Symfony\Bundle\TwigBundle\Controller\PreviewErrorController' |
26
|
|
|
'web_profiler.controller.profiler', // 'Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController' |
27
|
|
|
'web_profiler.controller.router', // 'Symfony\Bundle\WebProfilerBundle\Controller\RouterController', |
28
|
|
|
'web_profiler.controller.exception', // 'Symfony\Bundle\WebProfilerBundle\Controller\ExceptionController' |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
27 |
|
public function getConfigTreeBuilder() |
35
|
|
|
{ |
36
|
27 |
|
if (Kernel::VERSION_ID < 40200) { |
37
|
|
|
$treeBuilder = new TreeBuilder(); |
38
|
|
|
$rootNode = $treeBuilder->root('route_guard'); |
39
|
|
|
} else { |
40
|
27 |
|
$treeBuilder = new TreeBuilder('route_guard'); |
41
|
27 |
|
$rootNode = $treeBuilder->getRootNode(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$rootNode |
45
|
27 |
|
->validate() |
46
|
|
|
->always(function ($rootNode) { |
47
|
27 |
|
$dataCollectorNode = &$rootNode['data_collector']; |
48
|
|
|
|
49
|
27 |
|
$dataCollectorNode['ignore_controllers'] = array_merge($dataCollectorNode['ignore_controllers'], $dataCollectorNode['ignore_controllers_symfony']); |
50
|
27 |
|
unset($dataCollectorNode['ignore_controllers_symfony']); |
51
|
|
|
|
52
|
27 |
|
return $rootNode; |
53
|
27 |
|
}) |
54
|
27 |
|
->end() |
55
|
27 |
|
->children() |
56
|
27 |
|
->arrayNode('data_collector') |
57
|
27 |
|
->addDefaultsIfNotSet() |
58
|
27 |
|
->children() |
59
|
27 |
|
->arrayNode('ignore_controllers') |
60
|
27 |
|
->prototype('scalar')->end() |
61
|
27 |
|
->end() |
62
|
27 |
|
->arrayNode('ignore_controllers_symfony') |
63
|
27 |
|
->prototype('scalar')->end() |
64
|
27 |
|
->defaultValue(static::$symfonyControllers) |
|
|
|
|
65
|
27 |
|
->end() |
66
|
27 |
|
->booleanNode('ignore_exceptions')->defaultValue(false)->end() |
67
|
27 |
|
->end() |
68
|
27 |
|
->end() |
69
|
27 |
|
->arrayNode('twig') |
70
|
27 |
|
->addDefaultsIfNotSet() |
71
|
27 |
|
->children() |
72
|
27 |
|
->scalarNode('tag_name')->defaultValue('route')->end() |
73
|
27 |
|
->scalarNode('tag_variable_name')->defaultValue('_route')->end() |
74
|
27 |
|
->booleanNode('discover_routing_functions')->defaultValue(true)->end() |
75
|
27 |
|
->end() |
76
|
27 |
|
->end() |
77
|
27 |
|
->end(); |
78
|
|
|
|
79
|
27 |
|
return $treeBuilder; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|