1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the BenGorFile package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
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 BenGorFile\FileBundle\DependencyInjection; |
14
|
|
|
|
15
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
16
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* BenGor file bundle configuration class. |
20
|
|
|
* |
21
|
|
|
* @author Beñat Espiña <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Configuration implements ConfigurationInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
public function getConfigTreeBuilder() |
29
|
|
|
{ |
30
|
|
|
$treeBuilder = new TreeBuilder(); |
31
|
|
|
$treeBuilder->root('ben_gor_file') |
32
|
|
|
->children() |
33
|
|
|
->arrayNode('file_class')->requiresAtLeastOneElement() |
34
|
|
|
->prototype('array') |
35
|
|
|
->children() |
36
|
|
|
->scalarNode('class') |
37
|
|
|
->isRequired(true) |
38
|
|
|
->end() |
39
|
|
|
->scalarNode('persistence') |
40
|
|
|
->defaultValue('doctrine_orm') |
41
|
|
|
->validate() |
42
|
|
|
->ifNotInArray(['doctrine_orm', 'sql']) |
43
|
|
|
->thenInvalid('Invalid persistence layer "%s"') |
44
|
|
|
->end() |
45
|
|
|
->end() |
46
|
|
|
->scalarNode('storage') |
47
|
|
|
->defaultValue('symfony') |
48
|
|
|
->validate() |
49
|
|
|
->ifNotInArray(['gaufrette', 'symfony']) |
50
|
|
|
->thenInvalid('Invalid storage implementation "%s"') |
51
|
|
|
->end() |
52
|
|
|
->end() |
53
|
|
|
->scalarNode('upload_strategy') |
54
|
|
|
->defaultValue('default') |
55
|
|
|
->end() |
56
|
|
|
->scalarNode('upload_destination') |
57
|
|
|
->defaultValue('%kernel.root_dir%/../web') |
58
|
|
|
->end() |
59
|
|
|
->scalarNode('download_base_url') |
60
|
|
|
->defaultValue(null) |
61
|
|
|
->end() |
62
|
|
|
->scalarNode('data_transformer') |
63
|
|
|
->defaultValue('BenGorFile\\File\\Application\\DataTransformer\\FileDTODataTransformer') |
64
|
|
|
->end() |
65
|
|
|
->arrayNode('use_cases')->addDefaultsIfNotSet() |
66
|
|
|
->children() |
67
|
|
|
->arrayNode('upload')->addDefaultsIfNotSet() |
68
|
|
|
->children() |
69
|
|
|
->scalarNode('enabled') |
70
|
|
|
->defaultValue(false) |
71
|
|
|
->end() |
72
|
|
|
->scalarNode('api_enabled') |
73
|
|
|
->defaultValue(true) |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->arrayNode('get_files')->addDefaultsIfNotSet() |
78
|
|
|
->children() |
79
|
|
|
->scalarNode('enabled') |
80
|
|
|
->defaultValue(false) |
81
|
|
|
->end() |
82
|
|
|
->scalarNode('api_enabled') |
83
|
|
|
->defaultValue(true) |
84
|
|
|
->end() |
85
|
|
|
->end() |
86
|
|
|
->end() |
87
|
|
|
->arrayNode('get_file')->addDefaultsIfNotSet() |
88
|
|
|
->children() |
89
|
|
|
->scalarNode('enabled') |
90
|
|
|
->defaultValue(false) |
91
|
|
|
->end() |
92
|
|
|
->scalarNode('api_enabled') |
93
|
|
|
->defaultValue(true) |
94
|
|
|
->end() |
95
|
|
|
->end() |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
->end() |
99
|
|
|
->arrayNode('routes')->addDefaultsIfNotSet() |
100
|
|
|
->children() |
101
|
|
|
->arrayNode('upload')->addDefaultsIfNotSet() |
102
|
|
|
->children() |
103
|
|
|
->scalarNode('name') |
104
|
|
|
->defaultValue(null) |
105
|
|
|
->end() |
106
|
|
|
->scalarNode('path') |
107
|
|
|
->defaultValue(null) |
108
|
|
|
->end() |
109
|
|
|
->scalarNode('api_name') |
110
|
|
|
->defaultValue(null) |
111
|
|
|
->end() |
112
|
|
|
->scalarNode('api_path') |
113
|
|
|
->defaultValue(null) |
114
|
|
|
->end() |
115
|
|
|
->end() |
116
|
|
|
->end() |
117
|
|
|
->arrayNode('get_file')->addDefaultsIfNotSet() |
118
|
|
|
->children() |
119
|
|
|
->scalarNode('name') |
120
|
|
|
->defaultValue(null) |
121
|
|
|
->end() |
122
|
|
|
->scalarNode('path') |
123
|
|
|
->defaultValue(null) |
124
|
|
|
->end() |
125
|
|
|
->scalarNode('api_name') |
126
|
|
|
->defaultValue(null) |
127
|
|
|
->end() |
128
|
|
|
->scalarNode('api_path') |
129
|
|
|
->defaultValue(null) |
130
|
|
|
->end() |
131
|
|
|
->end() |
132
|
|
|
->end() |
133
|
|
|
->arrayNode('get_files')->addDefaultsIfNotSet() |
134
|
|
|
->children() |
135
|
|
|
->scalarNode('name') |
136
|
|
|
->defaultValue(null) |
137
|
|
|
->end() |
138
|
|
|
->scalarNode('path') |
139
|
|
|
->defaultValue(null) |
140
|
|
|
->end() |
141
|
|
|
->scalarNode('api_name') |
142
|
|
|
->defaultValue(null) |
143
|
|
|
->end() |
144
|
|
|
->scalarNode('api_path') |
145
|
|
|
->defaultValue(null) |
146
|
|
|
->end() |
147
|
|
|
->end() |
148
|
|
|
->end() |
149
|
|
|
->end() |
150
|
|
|
->end() |
151
|
|
|
->end() |
152
|
|
|
->end(); |
153
|
|
|
|
154
|
|
|
return $treeBuilder; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|