-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathConfiguration.php
More file actions
145 lines (128 loc) · 5.29 KB
/
Configuration.php
File metadata and controls
145 lines (128 loc) · 5.29 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
namespace Lexik\Bundle\TranslationBundle\DependencyInjection;
use Lexik\Bundle\TranslationBundle\Storage\StorageInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*
* @author Cédric Girard <c.girard@lexik.fr>
*/
class Configuration implements ConfigurationInterface
{
/**
* (non-PHPdoc)
* @see Symfony\Component\Config\Definition.ConfigurationInterface::getConfigTreeBuilder()
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('lexik_translation');
$rootNode = $treeBuilder->getRootNode();
$storages = array(
StorageInterface::STORAGE_ORM,
StorageInterface::STORAGE_MONGODB,
StorageInterface::STORAGE_PROPEL,
);
$registrationTypes = array('all', 'files', 'database');
$inputTypes = array('text', 'textarea');
$rootNode
->addDefaultsIfNotSet()
->children()
->scalarNode('base_layout')
->cannotBeEmpty()
->defaultValue('@LexikTranslationBundle/layout.html.twig')
->end()
->arrayNode('fallback_locale')
->isRequired()
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->beforeNormalization()
->ifString()
->then(function ($value) { return array($value); })
->end()
->end()
->arrayNode('managed_locales')
->isRequired()
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->scalarNode('grid_input_type')
->cannotBeEmpty()
->defaultValue('text')
->validate()
->ifNotInArray($inputTypes)
->thenInvalid('The input type "%s" is not supported. Please use one of the following types: '.implode(', ', $inputTypes))
->end()
->end()
->booleanNode('grid_toggle_similar')
->defaultValue(false)
->end()
->booleanNode('auto_cache_clean')
->defaultValue(false)
->end()
->integerNode('auto_cache_clean_interval')
->defaultValue(null)
->end()
->arrayNode('storage')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')
->cannotBeEmpty()
->defaultValue(StorageInterface::STORAGE_ORM)
->validate()
->ifNotInArray($storages)
->thenInvalid('The storage "%s" is not supported. Please use one of the following storage: '.implode(', ', $storages))
->end()
->end()
->scalarNode('object_manager')
->end()
->end()
->end()
->arrayNode('resources_registration')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')
->cannotBeEmpty()
->defaultValue('all')
->validate()
->ifNotInArray($registrationTypes)
->thenInvalid('Invalid registration type "%s". Please use one of the following types: '.implode(', ', $registrationTypes))
->end()
->end()
->booleanNode('managed_locales_only')
->defaultTrue()
->end()
->end()
->end()
->arrayNode('exporter')
->addDefaultsIfNotSet()
->children()
->booleanNode('json_hierarchical_format')
->defaultFalse()
->end()
->booleanNode('use_yml_tree')
->defaultFalse()
->end()
->end()
->end()
->arrayNode('dev_tools')
->addDefaultsIfNotSet()
->children()
->booleanNode('enable')
->defaultFalse()
->end()
->booleanNode('create_missing')
->defaultFalse()
->end()
->scalarNode('file_format')
->defaultValue('yml')
->end()
->end()
->end()
->end()
;
return $treeBuilder;
}
}