/
Configuration.php
77 lines (71 loc) · 2.77 KB
/
Configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
* This file is part of the Eko\FeedBundle Symfony bundle.
*
* (c) Vincent Composieux <vincent.composieux@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eko\FeedBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* Configuration.
*
* This class generates configuration settings tree
*
* @author Vincent Composieux <vincent.composieux@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
/**
* Builds configuration tree.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder A tree builder instance
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('eko_feed');
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
$rootNode = $treeBuilder->root('eko_feed');
}
$rootNode
->children()
->scalarNode('hydrator')->defaultValue('eko_feed.hydrator.default')->end()
->scalarNode('translation_domain')->defaultNull()->end()
->arrayNode('feeds')
->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->prototype('array')
->children()
->scalarNode('title')->isRequired()->end()
->scalarNode('description')->isRequired()->end()
->arrayNode('link')
->isRequired()
->beforeNormalization()
->ifString()
->then(function ($value) {
return ['uri' => $value];
})
->end()
->children()
->scalarNode('route_name')->end()
->arrayNode('route_params')
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->scalarNode('uri')->end()
->end()
->end()
->scalarNode('encoding')->isRequired()->end()
->scalarNode('author')->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}
}