-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathConfiguration.php
More file actions
72 lines (65 loc) · 2.58 KB
/
Configuration.php
File metadata and controls
72 lines (65 loc) · 2.58 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
<?php
namespace Happyr\TranslationBundle\DependencyInjection;
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.
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$root = $treeBuilder->root('happyr_translation');
$root->children()
->enumNode('translation_service')->values(array('blackhole', 'filesystem', 'loco'))->defaultValue('loco')->end()
->scalarNode('target_dir')->defaultValue('%kernel.root_dir%/Resources/translations')->end()
->scalarNode('httplug_client')->defaultValue('httplug.client')->cannotBeEmpty()->end()
->scalarNode('httplug_message_factory')->defaultValue('httplug.message_factory')->cannotBeEmpty()->end()
->booleanNode('sync_empty_translations')->defaultTrue()->end()
->booleanNode('auto_add_assets')->defaultFalse()->end()
->booleanNode('allow_edit')->defaultTrue()->end()
->enumNode('file_extension')->values(array('csv', 'ini', 'json', 'mo', 'php', 'po', 'qt', 'yml', 'xlf'))->defaultValue('xlf')->end()
->arrayNode('locales')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('domains')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->append($this->getProjectNode())
->end();
return $treeBuilder;
}
/**
* @return \Symfony\Component\Config\Definition\Builder\NodeDefinition
*/
private function getProjectNode()
{
$treeBuilder = new TreeBuilder();
$node = $treeBuilder->root('projects');
$node
->useAttributeAsKey('name')
->prototype('array')
->children()
->scalarNode('api_key')->isRequired()->end()
->arrayNode('locales')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('domains')
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('tags')
->prototype('scalar')->end()
->end()
->end()
->end();
return $node;
}
}