| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the sauls/components-bundle package. |
||
| 4 | * |
||
| 5 | * @author Saulius Vaičeliūnas <[email protected]> |
||
| 6 | * @link http://saulius.vaiceliunas.lt |
||
| 7 | * @copyright 2018 |
||
| 8 | * |
||
| 9 | * For the full copyright and license information, please view the LICENSE |
||
| 10 | * file that was distributed with this source code. |
||
| 11 | */ |
||
| 12 | |||
| 13 | namespace Sauls\Bundle\Components\DependencyInjection; |
||
| 14 | |||
| 15 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
| 16 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
| 17 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
| 18 | |||
| 19 | class Configuration implements ConfigurationInterface |
||
| 20 | { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Generates the configuration tree builder. |
||
| 24 | * |
||
| 25 | * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder |
||
| 26 | * @throws \RuntimeException |
||
| 27 | */ |
||
| 28 | 7 | public function getConfigTreeBuilder() |
|
| 29 | { |
||
| 30 | 7 | $treeBuilder = new TreeBuilder('sauls_components'); |
|
| 31 | 7 | $rootNode = $treeBuilder->getRootNode(); |
|
| 32 | |||
| 33 | $rootNode |
||
| 34 | 7 | ->fixXmlConfig('helper') |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 35 | 7 | ->fixXmlConfig('widget') |
|
| 36 | 7 | ->fixXmlConfig('component') |
|
| 37 | 7 | ->addDefaultsIfNotSet() |
|
| 38 | 7 | ->children() |
|
| 39 | 7 | ->booleanNode('helpers')->defaultTrue()->end() |
|
| 40 | 7 | ->booleanNode('widgets')->defaultTrue()->end() |
|
| 41 | 7 | ->arrayNode('components') |
|
| 42 | 7 | ->children() |
|
| 43 | 7 | ->arrayNode('access') |
|
| 44 | 7 | ->children() |
|
| 45 | 7 | ->arrayNode('allowed_ips') |
|
| 46 | 7 | ->beforeNormalization() |
|
| 47 | 7 | ->ifTrue(function ($v) { return !\is_array($v) && false !== $v; }) |
|
| 48 | 7 | ->then(function ($v) { return [$v]; }) |
|
| 49 | 7 | ->end() |
|
| 50 | 7 | ->prototype('scalar')->end() |
|
| 51 | 7 | ->end() |
|
| 52 | 7 | ->end() |
|
| 53 | 7 | ->children() |
|
| 54 | 7 | ->arrayNode('protected_routes') |
|
| 55 | 7 | ->beforeNormalization() |
|
| 56 | 7 | ->ifTrue(function ($v) { return !\is_array($v) && false !== $v; }) |
|
| 57 | 7 | ->then(function ($v) { return [$v]; }) |
|
| 58 | 7 | ->end() |
|
| 59 | 7 | ->prototype('scalar')->end() |
|
| 60 | 7 | ->end() |
|
| 61 | 7 | ->end() |
|
| 62 | 7 | ->end() |
|
| 63 | 7 | ->end() |
|
| 64 | 7 | ->end() |
|
| 65 | 7 | ->end() |
|
| 66 | ; |
||
| 67 | |||
| 68 | 7 | return $treeBuilder; |
|
| 69 | } |
||
| 70 | } |
||
| 71 |