Conditions | 1 |
Paths | 1 |
Total Lines | 44 |
Code Lines | 40 |
Lines | 0 |
Ratio | 0 % |
Tests | 37 |
CRAP Score | 1 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | 5 | public function getConfigTreeBuilder() |
|
14 | { |
||
15 | 5 | $treeBuilder = new TreeBuilder(); |
|
16 | 5 | $rootNode = $treeBuilder->root('zenstruck_elastica'); |
|
17 | $rootNode |
||
18 | 5 | ->children() |
|
19 | 5 | ->booleanNode('logging')->defaultFalse()->end() |
|
20 | 5 | ->variableNode('client') |
|
21 | 5 | ->isRequired() |
|
22 | 5 | ->validate() |
|
23 | ->ifTrue(function ($value) { return !is_array($value); }) |
||
24 | 5 | ->thenInvalid('Client config must be an array.') |
|
25 | 5 | ->end() |
|
26 | 5 | ->end() |
|
27 | 5 | ->arrayNode('index') |
|
28 | 5 | ->children() |
|
29 | 5 | ->scalarNode('name')->isRequired()->end() |
|
30 | 5 | ->variableNode('settings') |
|
31 | 5 | ->defaultNull() |
|
32 | 5 | ->validate() |
|
33 | ->ifTrue(function ($value) { return !is_array($value); }) |
||
34 | 5 | ->thenInvalid('Index settings must be an array.') |
|
35 | 5 | ->end() |
|
36 | 5 | ->end() |
|
37 | 5 | ->end() |
|
38 | 5 | ->end() |
|
39 | 5 | ->arrayNode('types') |
|
40 | 5 | ->useAttributeAsKey('alias') |
|
41 | 5 | ->prototype('array') |
|
42 | 5 | ->children() |
|
43 | 5 | ->scalarNode('service')->isRequired()->end() |
|
44 | 5 | ->variableNode('mapping') |
|
45 | 5 | ->info('Can be an array of mappings or a service that implements Zenstruck\ElasticaBundle\Elastica\MappingProvider or Elastica\Type\Mapping') |
|
46 | 5 | ->isRequired() |
|
47 | 5 | ->end() |
|
48 | 5 | ->end() |
|
49 | 5 | ->end() |
|
50 | 5 | ->end() |
|
51 | 5 | ->end() |
|
52 | 5 | ->end() |
|
53 | ; |
||
54 | |||
55 | 5 | return $treeBuilder; |
|
56 | } |
||
57 | } |
||
58 |