1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\NewsBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
17
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
21
|
|
|
* |
22
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
23
|
|
|
*/ |
24
|
|
|
class Configuration implements ConfigurationInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* NEXT_MAJOR: make constant protected/private. |
28
|
|
|
*/ |
29
|
|
|
public const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'no_driver']; |
30
|
|
|
|
31
|
|
|
public function getConfigTreeBuilder() |
32
|
|
|
{ |
33
|
|
|
$treeBuilder = new TreeBuilder('sonata_news'); |
34
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
35
|
|
|
|
36
|
|
|
$rootNode |
37
|
|
|
->children() |
38
|
|
|
->scalarNode('title')->isRequired()->end() |
39
|
|
|
->scalarNode('link')->isRequired()->end() |
40
|
|
|
->scalarNode('description')->isRequired()->end() |
41
|
|
|
->scalarNode('permalink_generator')->defaultValue('sonata.news.permalink.date')->end() |
42
|
|
|
->scalarNode('salt')->isRequired()->end() |
43
|
|
|
->arrayNode('permalink') |
44
|
|
|
->addDefaultsIfNotSet() |
45
|
|
|
->children() |
46
|
|
|
->scalarNode('date') |
47
|
|
|
->info('Default format: year/month/day/slug') |
48
|
|
|
->defaultValue('%%1$04d/%%2$d/%%3$d/%%4$s') |
49
|
|
|
->end() |
50
|
|
|
->end() |
51
|
|
|
->end() |
52
|
|
|
->scalarNode('db_driver') |
53
|
|
|
// NEXT_MAJOR: Change default value to: no_driver |
54
|
|
|
->defaultValue('doctrine_orm') |
55
|
|
|
->validate() |
56
|
|
|
->ifNotInArray(self::DB_DRIVERS) |
57
|
|
|
->thenInvalid('SonataNewsBundle - Invalid db driver %s.') |
58
|
|
|
->end() |
59
|
|
|
->end() |
60
|
|
|
->arrayNode('table') |
61
|
|
|
->addDefaultsIfNotSet() |
62
|
|
|
->children() |
63
|
|
|
->scalarNode('post_tag')->defaultValue('news__post_tag')->end() |
64
|
|
|
->end() |
65
|
|
|
->end() |
66
|
|
|
->arrayNode('class') |
67
|
|
|
->addDefaultsIfNotSet() |
68
|
|
|
->children() |
69
|
|
|
->scalarNode('tag') |
70
|
|
|
->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Tag') |
71
|
|
|
->end() |
72
|
|
|
->scalarNode('collection') |
73
|
|
|
->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Collection') |
74
|
|
|
->end() |
75
|
|
|
->scalarNode('post') |
76
|
|
|
->defaultValue('Application\\Sonata\\NewsBundle\\Entity\\Post') |
77
|
|
|
->end() |
78
|
|
|
->scalarNode('comment') |
79
|
|
|
->defaultValue('Application\\Sonata\\NewsBundle\\Entity\\Comment') |
80
|
|
|
->end() |
81
|
|
|
->scalarNode('media') |
82
|
|
|
->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Media') |
83
|
|
|
->end() |
84
|
|
|
->scalarNode('user') |
85
|
|
|
->defaultValue('Application\\Sonata\\UserBundle\\Entity\\User') |
86
|
|
|
->end() |
87
|
|
|
->end() |
88
|
|
|
->end() |
89
|
|
|
|
90
|
|
|
->arrayNode('admin') |
91
|
|
|
->addDefaultsIfNotSet() |
92
|
|
|
->children() |
93
|
|
|
->arrayNode('post') |
94
|
|
|
->addDefaultsIfNotSet() |
95
|
|
|
->children() |
96
|
|
|
->scalarNode('class') |
97
|
|
|
->cannotBeEmpty() |
98
|
|
|
->defaultValue('Sonata\\NewsBundle\\Admin\\PostAdmin') |
99
|
|
|
->end() |
100
|
|
|
->scalarNode('controller') |
101
|
|
|
->cannotBeEmpty() |
102
|
|
|
->defaultValue('SonataAdminBundle:CRUD') |
103
|
|
|
->end() |
104
|
|
|
->scalarNode('translation') |
105
|
|
|
->cannotBeEmpty() |
106
|
|
|
->defaultValue('SonataNewsBundle') |
107
|
|
|
->end() |
108
|
|
|
->end() |
109
|
|
|
->end() |
110
|
|
|
->arrayNode('comment') |
111
|
|
|
->addDefaultsIfNotSet() |
112
|
|
|
->children() |
113
|
|
|
->scalarNode('class') |
114
|
|
|
->cannotBeEmpty() |
115
|
|
|
->defaultValue('Sonata\\NewsBundle\\Admin\\CommentAdmin') |
116
|
|
|
->end() |
117
|
|
|
->scalarNode('controller') |
118
|
|
|
->cannotBeEmpty() |
119
|
|
|
->defaultValue('SonataNewsBundle:CommentAdmin') |
120
|
|
|
->end() |
121
|
|
|
->scalarNode('translation') |
122
|
|
|
->cannotBeEmpty() |
123
|
|
|
->defaultValue('SonataNewsBundle') |
124
|
|
|
->end() |
125
|
|
|
->end() |
126
|
|
|
->end() |
127
|
|
|
->end() |
128
|
|
|
->end() |
129
|
|
|
|
130
|
|
|
->arrayNode('comment') |
131
|
|
|
->children() |
132
|
|
|
->arrayNode('notification') |
133
|
|
|
->children() |
134
|
|
|
->arrayNode('emails') |
135
|
|
|
->prototype('scalar')->cannotBeEmpty()->end() |
136
|
|
|
->end() |
137
|
|
|
->scalarNode('from')->cannotBeEmpty()->end() |
138
|
|
|
->scalarNode('template')->cannotBeEmpty()->end() |
139
|
|
|
->end() |
140
|
|
|
->end() |
141
|
|
|
->end() |
142
|
|
|
->end() |
143
|
|
|
->end() |
144
|
|
|
; |
145
|
|
|
|
146
|
|
|
return $treeBuilder; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|