Completed
Pull Request — master (#1015)
by Kévin
09:16 queued 06:42
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 79
Code Lines 67

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 4.0018

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 79
ccs 59
cts 62
cp 0.9516
rs 8.5646
cc 4
eloc 67
nc 1
nop 1
crap 4.0018

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace FOS\ElasticaBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
class Configuration implements ConfigurationInterface
10
{
11
    /**
12
     * Stores supported database drivers.
13
     *
14
     * @var array
15
     */
16
    private $supportedDrivers = array('orm', 'mongodb', 'propel', 'phpcr');
17
18
    /**
19
     * If the kernel is running in debug mode.
20
     *
21
     * @var bool
22
     */
23
    private $debug;
24
25 22
    public function __construct($debug)
26
    {
27 22
        $this->debug = $debug;
28 22
    }
29
30
    /**
31
     * Generates the configuration tree.
32
     *
33
     * @return TreeBuilder
34
     */
35 22
    public function getConfigTreeBuilder()
36
    {
37 22
        $treeBuilder = new TreeBuilder();
38 22
        $rootNode = $treeBuilder->root('fos_elastica', 'array');
39
40 22
        $this->addClientsSection($rootNode);
41 22
        $this->addIndexesSection($rootNode);
42
43
        $rootNode
44 22
            ->children()
45 22
                ->scalarNode('default_client')
46 22
                    ->info('Defaults to the first client defined')
47 22
                ->end()
48 22
                ->scalarNode('default_index')
49 22
                    ->info('Defaults to the first index defined')
50 22
                ->end()
51 22
                ->scalarNode('default_manager')->defaultValue('orm')->end()
52 22
                ->arrayNode('serializer')
53 22
                    ->treatNullLike(array())
54 22
                    ->children()
55 22
                        ->scalarNode('callback_class')->defaultValue('FOS\ElasticaBundle\Serializer\Callback')->end()
56 22
                        ->scalarNode('serializer')->defaultValue('serializer')->end()
57 22
                    ->end()
58 22
                ->end()
59 22
            ->end()
60
        ;
61
62 22
        return $treeBuilder;
63
    }
64
65
    /**
66
     * Adds the configuration for the "clients" key.
67
     */
68 22
    private function addClientsSection(ArrayNodeDefinition $rootNode)
69
    {
70
        $rootNode
71 22
            ->fixXmlConfig('client')
72 22
            ->children()
73 22
                ->arrayNode('clients')
74 22
                    ->useAttributeAsKey('id')
75 22
                    ->prototype('array')
76 22
                        ->performNoDeepMerging()
77
                        // BC - Renaming 'servers' node to 'connections'
78 22
                        ->beforeNormalization()
79
                        ->ifTrue(function ($v) { return isset($v['servers']); })
80
                        ->then(function ($v) {
81
                            $v['connections'] = $v['servers'];
82
                            unset($v['servers']);
83
84
                            return $v;
85 22
                        })
86 22
                        ->end()
87
                        // Elastica names its properties with camel case, support both
88 22
                        ->beforeNormalization()
89
                        ->ifTrue(function ($v) { return isset($v['connection_strategy']); })
90
                        ->then(function ($v) {
91 4
                            $v['connectionStrategy'] = $v['connection_strategy'];
92 4
                            unset($v['connection_strategy']);
93
94 4
                            return $v;
95 22
                        })
96 22
                        ->end()
97
                        // If there is no connections array key defined, assume a single connection.
98 22
                        ->beforeNormalization()
99
                        ->ifTrue(function ($v) { return is_array($v) && !array_key_exists('connections', $v); })
100
                        ->then(function ($v) {
101
                            return array(
102 21
                                'connections' => array($v),
103 21
                            );
104 22
                        })
105 22
                        ->end()
106 22
                        ->children()
107 22
                            ->arrayNode('connections')
108 22
                                ->requiresAtLeastOneElement()
109 22
                                ->prototype('array')
110 22
                                    ->fixXmlConfig('header')
111 22
                                    ->children()
112 22
                                        ->scalarNode('url')
113 22
                                            ->validate()
114
                                                ->ifTrue(function ($url) { return $url && substr($url, -1) !== '/'; })
115
                                                ->then(function ($url) { return $url.'/'; })
116 22
                                            ->end()
117 22
                                        ->end()
118 22
                                        ->scalarNode('host')->end()
119 22
                                        ->scalarNode('port')->end()
120 22
                                        ->scalarNode('proxy')->end()
121 22
                                        ->scalarNode('logger')
122 22
                                            ->defaultValue($this->debug ? 'fos_elastica.logger' : false)
123 22
                                            ->treatNullLike('fos_elastica.logger')
124 22
                                            ->treatTrueLike('fos_elastica.logger')
125 22
                                        ->end()
126 22
                                        ->arrayNode('headers')
127 22
                                            ->useAttributeAsKey('name')
128 22
                                            ->prototype('scalar')->end()
129 22
                                        ->end()
130 22
                                        ->scalarNode('transport')->end()
131 22
                                        ->scalarNode('timeout')->end()
132 22
                                        ->scalarNode('retryOnConflict')
133 22
                                            ->defaultValue(0)
134 22
                                        ->end()
135 22
                                    ->end()
136 22
                                ->end()
137 22
                            ->end()
138 22
                            ->scalarNode('timeout')->end()
139 22
                            ->scalarNode('headers')->end()
140 22
                            ->scalarNode('connectionStrategy')->defaultValue('Simple')->end()
141 22
                        ->end()
142 22
                    ->end()
143 22
                ->end()
144 22
            ->end()
145
        ;
146 22
    }
147
148
    /**
149
     * Adds the configuration for the "indexes" key.
150
     */
151 22
    private function addIndexesSection(ArrayNodeDefinition $rootNode)
152
    {
153
        $rootNode
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Config...\Builder\NodeDefinition as the method children() does only exist in the following sub-classes of Symfony\Component\Config...\Builder\NodeDefinition: Symfony\Component\Config...der\ArrayNodeDefinition. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
154 22
            ->fixXmlConfig('index')
155 22
            ->children()
156 22
                ->arrayNode('indexes')
157 22
                    ->useAttributeAsKey('name')
158 22
                    ->prototype('array')
159 22
                        ->children()
160 22
                            ->scalarNode('index_name')
161 22
                                ->info('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch')
162 22
                            ->end()
163 22
                            ->booleanNode('use_alias')->defaultValue(false)->end()
164 22
                            ->scalarNode('client')->end()
165 22
                            ->scalarNode('finder')
166 22
                                ->treatNullLike(true)
167 22
                                ->defaultFalse()
168 22
                            ->end()
169 22
                            ->arrayNode('type_prototype')
170 22
                                ->children()
171 22
                                    ->scalarNode('index_analyzer')->end()
172 22
                                    ->scalarNode('search_analyzer')->end()
173 22
                                    ->append($this->getPersistenceNode())
174 22
                                    ->append($this->getSerializerNode())
175 22
                                ->end()
176 22
                            ->end()
177 22
                            ->variableNode('settings')->defaultValue(array())->end()
178 22
                        ->end()
179 22
                        ->append($this->getTypesNode())
180 22
                    ->end()
181 22
                ->end()
182 22
            ->end()
183
        ;
184 22
    }
185
186
    /**
187
     * Returns the array node used for "types".
188
     */
189 22
    protected function getTypesNode()
190
    {
191 22
        $builder = new TreeBuilder();
192 22
        $node = $builder->root('types');
193
194
        $node
195 22
            ->useAttributeAsKey('name')
196 22
            ->prototype('array')
197 22
                ->treatNullLike(array())
198 22
                ->beforeNormalization()
199 22
                ->ifNull()
200 22
                ->thenEmptyArray()
201 22
                ->end()
202
                // BC - Renaming 'mappings' node to 'properties'
203 22
                ->beforeNormalization()
204
                ->ifTrue(function ($v) { return array_key_exists('mappings', $v); })
205
                ->then(function ($v) {
206 13
                    $v['properties'] = $v['mappings'];
207 13
                    unset($v['mappings']);
208
209 13
                    return $v;
210 22
                })
211 22
                ->end()
212
                // BC - Support the old is_indexable_callback property
213 22
                ->beforeNormalization()
214
                ->ifTrue(function ($v) {
215 17
                    return isset($v['persistence']) &&
216 17
                        isset($v['persistence']['listener']) &&
217 17
                        isset($v['persistence']['listener']['is_indexable_callback']);
218 22
                })
219
                ->then(function ($v) {
220 5
                    $callback = $v['persistence']['listener']['is_indexable_callback'];
221
222 5
                    if (is_array($callback)) {
223 5
                        list($class) = $callback + array(null);
224
225 5
                        if ($class[0] !== '@' && is_string($class) && !class_exists($class)) {
226
                            $callback[0] = '@'.$class;
227
                        }
228 5
                    }
229
230 5
                    $v['indexable_callback'] = $callback;
231 5
                    unset($v['persistence']['listener']['is_indexable_callback']);
232
233 5
                    return $v;
234 22
                })
235 22
                ->end()
236
                // Support multiple dynamic_template formats to match the old bundle style
237
                // and the way ElasticSearch expects them
238 22
                ->beforeNormalization()
239
                ->ifTrue(function ($v) { return isset($v['dynamic_templates']); })
240
                ->then(function ($v) {
241 4
                    $dt = array();
242 4
                    foreach ($v['dynamic_templates'] as $key => $type) {
243 4
                        if (is_int($key)) {
244 4
                            $dt[] = $type;
245 4
                        } else {
246 4
                            $dt[][$key] = $type;
247
                        }
248 4
                    }
249
250 4
                    $v['dynamic_templates'] = $dt;
251
252 4
                    return $v;
253 22
                })
254 22
                ->end()
255 22
                ->children()
256 22
                    ->booleanNode('date_detection')->end()
257 22
                    ->arrayNode('dynamic_date_formats')->prototype('scalar')->end()->end()
258 22
                    ->scalarNode('index_analyzer')->end()
259 22
                    ->booleanNode('numeric_detection')->end()
260 22
                    ->scalarNode('search_analyzer')->end()
261 22
                    ->scalarNode('dynamic')->end()
262 22
                    ->variableNode('indexable_callback')->end()
263 22
                    ->append($this->getPersistenceNode())
264 22
                    ->append($this->getSerializerNode())
265 22
                ->end()
266 22
                ->append($this->getIdNode())
267 22
                ->append($this->getPropertiesNode())
268 22
                ->append($this->getDynamicTemplateNode())
269 22
                ->append($this->getSourceNode())
270 22
                ->append($this->getBoostNode())
271 22
                ->append($this->getRoutingNode())
272 22
                ->append($this->getParentNode())
273 22
                ->append($this->getAllNode())
274 22
                ->append($this->getTimestampNode())
275 22
                ->append($this->getTtlNode())
276 22
            ->end()
277
        ;
278
279 22
        return $node;
280
    }
281
282
    /**
283
     * Returns the array node used for "properties".
284
     */
285 22
    protected function getPropertiesNode()
286
    {
287 22
        $builder = new TreeBuilder();
288 22
        $node = $builder->root('properties');
289
290
        $node
291 22
            ->useAttributeAsKey('name')
292 22
            ->prototype('variable')
293 22
                ->treatNullLike(array());
294
295 22
        return $node;
296
    }
297
298
    /**
299
     * Returns the array node used for "dynamic_templates".
300
     */
301 22
    public function getDynamicTemplateNode()
302
    {
303 22
        $builder = new TreeBuilder();
304 22
        $node = $builder->root('dynamic_templates');
305
306
        $node
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Config...\Builder\NodeDefinition as the method prototype() does only exist in the following sub-classes of Symfony\Component\Config...\Builder\NodeDefinition: Symfony\Component\Config...der\ArrayNodeDefinition. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
307 22
            ->prototype('array')
308 22
                ->prototype('array')
309 22
                    ->children()
310 22
                        ->scalarNode('match')->end()
311 22
                        ->scalarNode('unmatch')->end()
312 22
                        ->scalarNode('match_mapping_type')->end()
313 22
                        ->scalarNode('path_match')->end()
314 22
                        ->scalarNode('path_unmatch')->end()
315 22
                        ->scalarNode('match_pattern')->end()
316 22
                        ->arrayNode('mapping')
317 22
                            ->prototype('variable')
318 22
                                ->treatNullLike(array())
319 22
                            ->end()
320 22
                        ->end()
321 22
                    ->end()
322 22
                ->end()
323 22
            ->end()
324
        ;
325
326 22
        return $node;
327
    }
328
329
    /**
330
     * Returns the array node used for "_id".
331
     */
332 22 View Code Duplication
    protected function getIdNode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
333
    {
334 22
        $builder = new TreeBuilder();
335 22
        $node = $builder->root('_id');
336
337
        $node
338 22
            ->children()
339 22
            ->scalarNode('path')->end()
340 22
            ->end()
341
        ;
342
343 22
        return $node;
344
    }
345
346
    /**
347
     * Returns the array node used for "_source".
348
     */
349 22
    protected function getSourceNode()
350
    {
351 22
        $builder = new TreeBuilder();
352 22
        $node = $builder->root('_source');
353
354
        $node
355 22
            ->children()
356 22
                ->arrayNode('excludes')
357 22
                    ->useAttributeAsKey('name')
358 22
                    ->prototype('scalar')->end()
359 22
                ->end()
360 22
                ->arrayNode('includes')
361 22
                    ->useAttributeAsKey('name')
362 22
                    ->prototype('scalar')->end()
363 22
                ->end()
364 22
                ->scalarNode('compress')->end()
365 22
                ->scalarNode('compress_threshold')->end()
366 22
                ->scalarNode('enabled')->defaultTrue()->end()
367 22
            ->end()
368
        ;
369
370 22
        return $node;
371
    }
372
373
    /**
374
     * Returns the array node used for "_boost".
375
     */
376 22
    protected function getBoostNode()
377
    {
378 22
        $builder = new TreeBuilder();
379 22
        $node = $builder->root('_boost');
380
381
        $node
382 22
            ->children()
383 22
                ->scalarNode('name')->end()
384 22
                ->scalarNode('null_value')->end()
385 22
            ->end()
386
        ;
387
388 22
        return $node;
389
    }
390
391
    /**
392
     * Returns the array node used for "_routing".
393
     */
394 22 View Code Duplication
    protected function getRoutingNode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
395
    {
396 22
        $builder = new TreeBuilder();
397 22
        $node = $builder->root('_routing');
398
399
        $node
400 22
            ->children()
401 22
                ->scalarNode('required')->end()
402 22
                ->scalarNode('path')->end()
403 22
            ->end()
404
        ;
405
406 22
        return $node;
407
    }
408
409
    /**
410
     * Returns the array node used for "_parent".
411
     */
412 22
    protected function getParentNode()
413
    {
414 22
        $builder = new TreeBuilder();
415 22
        $node = $builder->root('_parent');
416
417
        $node
418 22
            ->children()
419 22
                ->scalarNode('type')->end()
420 22
                ->scalarNode('property')->defaultValue(null)->end()
421 22
                ->scalarNode('identifier')->defaultValue('id')->end()
422 22
            ->end()
423
        ;
424
425 22
        return $node;
426
    }
427
428
    /**
429
     * Returns the array node used for "_all".
430
     */
431 22
    protected function getAllNode()
432
    {
433 22
        $builder = new TreeBuilder();
434 22
        $node = $builder->root('_all');
435
436
        $node
437 22
            ->children()
438 22
            ->scalarNode('enabled')->defaultValue(true)->end()
439 22
            ->scalarNode('index_analyzer')->end()
440 22
            ->scalarNode('search_analyzer')->end()
441 22
            ->end()
442
        ;
443
444 22
        return $node;
445
    }
446
447
    /**
448
     * Returns the array node used for "_timestamp".
449
     */
450 22 View Code Duplication
    protected function getTimestampNode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
451
    {
452 22
        $builder = new TreeBuilder();
453 22
        $node = $builder->root('_timestamp');
454
455
        $node
456 22
            ->children()
457 22
            ->scalarNode('enabled')->defaultValue(true)->end()
458 22
            ->scalarNode('path')->end()
459 22
            ->scalarNode('format')->end()
460 22
            ->scalarNode('store')->end()
461 22
            ->scalarNode('index')->end()
462 22
            ->end()
463
        ;
464
465 22
        return $node;
466
    }
467
468
    /**
469
     * Returns the array node used for "_ttl".
470
     */
471 22 View Code Duplication
    protected function getTtlNode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
472
    {
473 22
        $builder = new TreeBuilder();
474 22
        $node = $builder->root('_ttl');
475
476
        $node
477 22
            ->children()
478 22
            ->scalarNode('enabled')->defaultValue(true)->end()
479 22
            ->scalarNode('default')->end()
480 22
            ->scalarNode('store')->end()
481 22
            ->scalarNode('index')->end()
482 22
            ->end()
483
        ;
484
485 22
        return $node;
486
    }
487
488
    /**
489
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
490
     */
491 22
    protected function getPersistenceNode()
492
    {
493 22
        $builder = new TreeBuilder();
494 22
        $node = $builder->root('persistence');
495
496
        $node
497 22
            ->validate()
498 View Code Duplication
                ->ifTrue(function ($v) { return isset($v['driver']) && 'propel' === $v['driver'] && isset($v['listener']); })
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
499 22
                    ->thenInvalid('Propel doesn\'t support listeners')
500 View Code Duplication
                ->ifTrue(function ($v) { return isset($v['driver']) && 'propel' === $v['driver'] && isset($v['repository']); })
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
501 22
                    ->thenInvalid('Propel doesn\'t support the "repository" parameter')
502 22
            ->end()
503 22
            ->children()
504 22
                ->scalarNode('driver')
505 22
                    ->validate()
506 22
                    ->ifNotInArray($this->supportedDrivers)
507 22
                        ->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($this->supportedDrivers))
508 22
                    ->end()
509 22
                ->end()
510 22
                ->scalarNode('model')->end()
511 22
                ->scalarNode('repository')->end()
512 22
                ->scalarNode('identifier')->defaultValue('id')->end()
513 22
                ->arrayNode('provider')
514 22
                    ->children()
515 22
                        ->scalarNode('batch_size')->defaultValue(100)->end()
516 22
                        ->scalarNode('clear_object_manager')->defaultTrue()->end()
517 22
                        ->scalarNode('debug_logging')
518 22
                            ->defaultValue($this->debug)
519 22
                            ->treatNullLike(true)
520 22
                        ->end()
521 22
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
522 22
                        ->scalarNode('service')->end()
523 22
                    ->end()
524 22
                ->end()
525 22
                ->arrayNode('listener')
526 22
                    ->children()
527 22
                        ->scalarNode('insert')->defaultTrue()->end()
528 22
                        ->scalarNode('update')->defaultTrue()->end()
529 22
                        ->scalarNode('delete')->defaultTrue()->end()
530 22
                        ->scalarNode('flush')->defaultTrue()->end()
531 22
                        ->booleanNode('immediate')->defaultFalse()->end()
532 22
                        ->scalarNode('logger')
533 22
                            ->defaultFalse()
534 22
                            ->treatNullLike('fos_elastica.logger')
535 22
                            ->treatTrueLike('fos_elastica.logger')
536 22
                        ->end()
537 22
                        ->scalarNode('service')->end()
538 22
                    ->end()
539 22
                ->end()
540 22
                ->arrayNode('finder')
541 22
                    ->children()
542 22
                        ->scalarNode('service')->end()
543 22
                    ->end()
544 22
                ->end()
545 22
                ->arrayNode('elastica_to_model_transformer')
546 22
                    ->addDefaultsIfNotSet()
547 22
                    ->children()
548 22
                        ->booleanNode('hydrate')->defaultTrue()->end()
549 22
                        ->booleanNode('ignore_missing')
550 22
                            ->defaultFalse()
551 22
                            ->info('Silently ignore results returned from Elasticsearch without corresponding persistent object.')
552 22
                        ->end()
553 22
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
554 22
                        ->scalarNode('service')->end()
555 22
                    ->end()
556 22
                ->end()
557 22
                ->arrayNode('model_to_elastica_transformer')
558 22
                    ->addDefaultsIfNotSet()
559 22
                    ->children()
560 22
                        ->scalarNode('service')->end()
561 22
                    ->end()
562 22
                ->end()
563 22
                ->arrayNode('persister')
564 22
                    ->addDefaultsIfNotSet()
565 22
                    ->children()
566 22
                        ->scalarNode('service')->end()
567 22
                    ->end()
568 22
                ->end()
569 22
            ->end();
570
571 22
        return $node;
572
    }
573
574
    /**
575
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
576
     */
577 22
    protected function getSerializerNode()
578
    {
579 22
        $builder = new TreeBuilder();
580 22
        $node = $builder->root('serializer');
581
582
        $node
583 22
            ->addDefaultsIfNotSet()
584 22
            ->children()
585 22
                ->arrayNode('groups')
586 22
                    ->treatNullLike(array())
587 22
                    ->prototype('scalar')->end()
588 22
                ->end()
589 22
                ->scalarNode('version')->end()
590 22
            ->end();
591
592 22
        return $node;
593
    }
594
}
595