Completed
Push — 3.1.x ( b8b6d2...fd2df9 )
by Karel
14:12 queued 11:28
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 76
Code Lines 64

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 56
CRAP Score 4.0021

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 76
c 2
b 1
f 0
ccs 56
cts 59
cp 0.9492
rs 8.623
cc 4
eloc 64
nc 1
nop 1
crap 4.0021

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');
17
18
    /**
19
     * If the kernel is running in debug mode.
20
     *
21
     * @var bool
22
     */
23
    private $debug;
24
25 16
    public function __construct($debug)
26
    {
27 16
        $this->debug = $debug;
28 16
    }
29
30
    /**
31
     * Generates the configuration tree.
32
     *
33
     * @return TreeBuilder
34
     */
35 16
    public function getConfigTreeBuilder()
36
    {
37 16
        $treeBuilder = new TreeBuilder();
38 16
        $rootNode = $treeBuilder->root('fos_elastica', 'array');
39
40 16
        $this->addClientsSection($rootNode);
41 16
        $this->addIndexesSection($rootNode);
42
43
        $rootNode
44 16
            ->children()
45 16
                ->scalarNode('default_client')
46 16
                    ->info('Defaults to the first client defined')
47 16
                ->end()
48 16
                ->scalarNode('default_index')
49 16
                    ->info('Defaults to the first index defined')
50 16
                ->end()
51 16
                ->scalarNode('default_manager')->defaultValue('orm')->end()
52 16
                ->arrayNode('serializer')
53 16
                    ->treatNullLike(array())
54 16
                    ->children()
55 16
                        ->scalarNode('callback_class')->defaultValue('FOS\ElasticaBundle\Serializer\Callback')->end()
56 16
                        ->scalarNode('serializer')->defaultValue('serializer')->end()
57 16
                    ->end()
58 16
                ->end()
59 16
            ->end()
60
        ;
61
62 16
        return $treeBuilder;
63
    }
64
65
    /**
66
     * Adds the configuration for the "clients" key.
67
     */
68 16
    private function addClientsSection(ArrayNodeDefinition $rootNode)
69
    {
70
        $rootNode
71 16
            ->fixXmlConfig('client')
72 16
            ->children()
73 16
                ->arrayNode('clients')
74 16
                    ->useAttributeAsKey('id')
75 16
                    ->prototype('array')
76 16
                        ->performNoDeepMerging()
77
                        // BC - Renaming 'servers' node to 'connections'
78 16
                        ->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 16
                        })
86 16
                        ->end()
87
                        // Elastica names its properties with camel case, support both
88 16
                        ->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 16
                        })
96 16
                        ->end()
97
                        // If there is no connections array key defined, assume a single connection.
98 16
                        ->beforeNormalization()
99
                        ->ifTrue(function ($v) { return is_array($v) && !array_key_exists('connections', $v); })
100
                        ->then(function ($v) {
101
                            return array(
102 15
                                'connections' => array($v),
103 15
                            );
104 16
                        })
105 16
                        ->end()
106 16
                        ->children()
107 16
                            ->arrayNode('connections')
108 16
                                ->requiresAtLeastOneElement()
109 16
                                ->prototype('array')
110 16
                                    ->fixXmlConfig('header')
111 16
                                    ->children()
112 16
                                        ->scalarNode('url')
113 16
                                            ->validate()
114
                                                ->ifTrue(function ($url) { return $url && substr($url, -1) !== '/'; })
115
                                                ->then(function ($url) { return $url.'/'; })
116 16
                                            ->end()
117 16
                                        ->end()
118 16
                                        ->scalarNode('host')->end()
119 16
                                        ->scalarNode('port')->end()
120 16
                                        ->scalarNode('proxy')->end()
121 16
                                        ->scalarNode('logger')
122 16
                                            ->defaultValue($this->debug ? 'fos_elastica.logger' : false)
123 16
                                            ->treatNullLike('fos_elastica.logger')
124 16
                                            ->treatTrueLike('fos_elastica.logger')
125 16
                                        ->end()
126 16
                                        ->arrayNode('headers')
127 16
                                            ->useAttributeAsKey('name')
128 16
                                            ->prototype('scalar')->end()
129 16
                                        ->end()
130 16
                                        ->scalarNode('transport')->end()
131 16
                                        ->scalarNode('timeout')->end()
132 16
                                    ->end()
133 16
                                ->end()
134 16
                            ->end()
135 16
                            ->scalarNode('timeout')->end()
136 16
                            ->scalarNode('headers')->end()
137 16
                            ->scalarNode('connectionStrategy')->defaultValue('Simple')->end()
138 16
                        ->end()
139 16
                    ->end()
140 16
                ->end()
141 16
            ->end()
142
        ;
143 16
    }
144
145
    /**
146
     * Adds the configuration for the "indexes" key.
147
     */
148 16
    private function addIndexesSection(ArrayNodeDefinition $rootNode)
149
    {
150
        $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...
151 16
            ->fixXmlConfig('index')
152 16
            ->children()
153 16
                ->arrayNode('indexes')
154 16
                    ->useAttributeAsKey('name')
155 16
                    ->prototype('array')
156 16
                        ->children()
157 16
                            ->scalarNode('index_name')
158 16
                                ->info('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch')
159 16
                            ->end()
160 16
                            ->booleanNode('use_alias')->defaultValue(false)->end()
161 16
                            ->scalarNode('client')->end()
162 16
                            ->scalarNode('finder')
163 16
                                ->treatNullLike(true)
164 16
                                ->defaultFalse()
165 16
                            ->end()
166 16
                            ->arrayNode('type_prototype')
167 16
                                ->children()
168 16
                                    ->scalarNode('index_analyzer')->end()
169 16
                                    ->scalarNode('search_analyzer')->end()
170 16
                                    ->append($this->getPersistenceNode())
171 16
                                    ->append($this->getSerializerNode())
172 16
                                ->end()
173 16
                            ->end()
174 16
                            ->variableNode('settings')->defaultValue(array())->end()
175 16
                        ->end()
176 16
                        ->append($this->getTypesNode())
177 16
                    ->end()
178 16
                ->end()
179 16
            ->end()
180
        ;
181 16
    }
182
183
    /**
184
     * Returns the array node used for "types".
185
     */
186 16
    protected function getTypesNode()
187
    {
188 16
        $builder = new TreeBuilder();
189 16
        $node = $builder->root('types');
190
191
        $node
192 16
            ->useAttributeAsKey('name')
193 16
            ->prototype('array')
194 16
                ->treatNullLike(array())
195 16
                ->beforeNormalization()
196 16
                ->ifNull()
197 16
                ->thenEmptyArray()
198 16
                ->end()
199
                // BC - Renaming 'mappings' node to 'properties'
200 16
                ->beforeNormalization()
201
                ->ifTrue(function ($v) { return array_key_exists('mappings', $v); })
202
                ->then(function ($v) {
203 7
                    $v['properties'] = $v['mappings'];
204 7
                    unset($v['mappings']);
205
206 7
                    return $v;
207 16
                })
208 16
                ->end()
209
                // BC - Support the old is_indexable_callback property
210 16
                ->beforeNormalization()
211
                ->ifTrue(function ($v) {
212 11
                    return isset($v['persistence']) &&
213 11
                        isset($v['persistence']['listener']) &&
214 11
                        isset($v['persistence']['listener']['is_indexable_callback']);
215 16
                })
216
                ->then(function ($v) {
217
                    $callback = $v['persistence']['listener']['is_indexable_callback'];
218
219
                    if (is_array($callback)) {
220
                        list($class) = $callback + array(null);
221
222
                        if ($class[0] !== '@' && is_string($class) && !class_exists($class)) {
223
                            $callback[0] = '@'.$class;
224
                        }
225
                    }
226
227
                    $v['indexable_callback'] = $callback;
228
                    unset($v['persistence']['listener']['is_indexable_callback']);
229
230
                    return $v;
231 16
                })
232 16
                ->end()
233
                // Support multiple dynamic_template formats to match the old bundle style
234
                // and the way ElasticSearch expects them
235 16
                ->beforeNormalization()
236
                ->ifTrue(function ($v) { return isset($v['dynamic_templates']); })
237
                ->then(function ($v) {
238 4
                    $dt = array();
239 4
                    foreach ($v['dynamic_templates'] as $key => $type) {
240 4
                        if (is_int($key)) {
241 4
                            $dt[] = $type;
242 4
                        } else {
243 4
                            $dt[][$key] = $type;
244
                        }
245 4
                    }
246
247 4
                    $v['dynamic_templates'] = $dt;
248
249 4
                    return $v;
250 16
                })
251 16
                ->end()
252 16
                ->children()
253 16
                    ->booleanNode('date_detection')->end()
254 16
                    ->arrayNode('dynamic_date_formats')->prototype('scalar')->end()->end()
255 16
                    ->scalarNode('index_analyzer')->end()
256 16
                    ->booleanNode('numeric_detection')->end()
257 16
                    ->scalarNode('search_analyzer')->end()
258 16
                    ->variableNode('indexable_callback')->end()
259 16
                    ->append($this->getPersistenceNode())
260 16
                    ->append($this->getSerializerNode())
261 16
                ->end()
262 16
                ->append($this->getIdNode())
263 16
                ->append($this->getPropertiesNode())
264 16
                ->append($this->getDynamicTemplateNode())
265 16
                ->append($this->getSourceNode())
266 16
                ->append($this->getBoostNode())
267 16
                ->append($this->getRoutingNode())
268 16
                ->append($this->getParentNode())
269 16
                ->append($this->getAllNode())
270 16
                ->append($this->getTimestampNode())
271 16
                ->append($this->getTtlNode())
272 16
            ->end()
273
        ;
274
275 16
        return $node;
276
    }
277
278
    /**
279
     * Returns the array node used for "properties".
280
     */
281 16
    protected function getPropertiesNode()
282
    {
283 16
        $builder = new TreeBuilder();
284 16
        $node = $builder->root('properties');
285
286
        $node
287 16
            ->useAttributeAsKey('name')
288 16
            ->prototype('variable')
289 16
                ->treatNullLike(array());
290
291 16
        return $node;
292
    }
293
294
    /**
295
     * Returns the array node used for "dynamic_templates".
296
     */
297 16
    public function getDynamicTemplateNode()
298
    {
299 16
        $builder = new TreeBuilder();
300 16
        $node = $builder->root('dynamic_templates');
301
302
        $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...
303 16
            ->prototype('array')
304 16
                ->prototype('array')
305 16
                    ->children()
306 16
                        ->scalarNode('match')->end()
307 16
                        ->scalarNode('unmatch')->end()
308 16
                        ->scalarNode('match_mapping_type')->end()
309 16
                        ->scalarNode('path_match')->end()
310 16
                        ->scalarNode('path_unmatch')->end()
311 16
                        ->scalarNode('match_pattern')->end()
312 16
                        ->arrayNode('mapping')
313 16
                            ->prototype('variable')
314 16
                                ->treatNullLike(array())
315 16
                            ->end()
316 16
                        ->end()
317 16
                    ->end()
318 16
                ->end()
319 16
            ->end()
320
        ;
321
322 16
        return $node;
323
    }
324
325
    /**
326
     * Returns the array node used for "_id".
327
     */
328 16 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...
329
    {
330 16
        $builder = new TreeBuilder();
331 16
        $node = $builder->root('_id');
332
333
        $node
334 16
            ->children()
335 16
            ->scalarNode('path')->end()
336 16
            ->end()
337
        ;
338
339 16
        return $node;
340
    }
341
342
    /**
343
     * Returns the array node used for "_source".
344
     */
345 16
    protected function getSourceNode()
346
    {
347 16
        $builder = new TreeBuilder();
348 16
        $node = $builder->root('_source');
349
350
        $node
351 16
            ->children()
352 16
                ->arrayNode('excludes')
353 16
                    ->useAttributeAsKey('name')
354 16
                    ->prototype('scalar')->end()
355 16
                ->end()
356 16
                ->arrayNode('includes')
357 16
                    ->useAttributeAsKey('name')
358 16
                    ->prototype('scalar')->end()
359 16
                ->end()
360 16
                ->scalarNode('compress')->end()
361 16
                ->scalarNode('compress_threshold')->end()
362 16
                ->scalarNode('enabled')->defaultTrue()->end()
363 16
            ->end()
364
        ;
365
366 16
        return $node;
367
    }
368
369
    /**
370
     * Returns the array node used for "_boost".
371
     */
372 16
    protected function getBoostNode()
373
    {
374 16
        $builder = new TreeBuilder();
375 16
        $node = $builder->root('_boost');
376
377
        $node
378 16
            ->children()
379 16
                ->scalarNode('name')->end()
380 16
                ->scalarNode('null_value')->end()
381 16
            ->end()
382
        ;
383
384 16
        return $node;
385
    }
386
387
    /**
388
     * Returns the array node used for "_routing".
389
     */
390 16 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...
391
    {
392 16
        $builder = new TreeBuilder();
393 16
        $node = $builder->root('_routing');
394
395
        $node
396 16
            ->children()
397 16
                ->scalarNode('required')->end()
398 16
                ->scalarNode('path')->end()
399 16
            ->end()
400
        ;
401
402 16
        return $node;
403
    }
404
405
    /**
406
     * Returns the array node used for "_parent".
407
     */
408 16
    protected function getParentNode()
409
    {
410 16
        $builder = new TreeBuilder();
411 16
        $node = $builder->root('_parent');
412
413
        $node
414 16
            ->children()
415 16
                ->scalarNode('type')->end()
416 16
                ->scalarNode('property')->defaultValue(null)->end()
417 16
                ->scalarNode('identifier')->defaultValue('id')->end()
418 16
            ->end()
419
        ;
420
421 16
        return $node;
422
    }
423
424
    /**
425
     * Returns the array node used for "_all".
426
     */
427 16
    protected function getAllNode()
428
    {
429 16
        $builder = new TreeBuilder();
430 16
        $node = $builder->root('_all');
431
432
        $node
433 16
            ->children()
434 16
            ->scalarNode('enabled')->defaultValue(true)->end()
435 16
            ->scalarNode('index_analyzer')->end()
436 16
            ->scalarNode('search_analyzer')->end()
437 16
            ->end()
438
        ;
439
440 16
        return $node;
441
    }
442
443
    /**
444
     * Returns the array node used for "_timestamp".
445
     */
446 16 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...
447
    {
448 16
        $builder = new TreeBuilder();
449 16
        $node = $builder->root('_timestamp');
450
451
        $node
452 16
            ->children()
453 16
            ->scalarNode('enabled')->defaultValue(true)->end()
454 16
            ->scalarNode('path')->end()
455 16
            ->scalarNode('format')->end()
456 16
            ->scalarNode('store')->end()
457 16
            ->scalarNode('index')->end()
458 16
            ->end()
459
        ;
460
461 16
        return $node;
462
    }
463
464
    /**
465
     * Returns the array node used for "_ttl".
466
     */
467 16 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...
468
    {
469 16
        $builder = new TreeBuilder();
470 16
        $node = $builder->root('_ttl');
471
472
        $node
473 16
            ->children()
474 16
            ->scalarNode('enabled')->defaultValue(true)->end()
475 16
            ->scalarNode('default')->end()
476 16
            ->scalarNode('store')->end()
477 16
            ->scalarNode('index')->end()
478 16
            ->end()
479
        ;
480
481 16
        return $node;
482
    }
483
484
    /**
485
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
486
     */
487 16
    protected function getPersistenceNode()
488
    {
489 16
        $builder = new TreeBuilder();
490 16
        $node = $builder->root('persistence');
491
492
        $node
493 16
            ->validate()
494 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...
495 16
                    ->thenInvalid('Propel doesn\'t support listeners')
496 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...
497 16
                    ->thenInvalid('Propel doesn\'t support the "repository" parameter')
498 16
            ->end()
499 16
            ->children()
500 16
                ->scalarNode('driver')
501 16
                    ->validate()
502 16
                    ->ifNotInArray($this->supportedDrivers)
503 16
                        ->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($this->supportedDrivers))
504 16
                    ->end()
505 16
                ->end()
506 16
                ->scalarNode('model')->end()
507 16
                ->scalarNode('repository')->end()
508 16
                ->scalarNode('identifier')->defaultValue('id')->end()
509 16
                ->arrayNode('provider')
510 16
                    ->children()
511 16
                        ->scalarNode('batch_size')->defaultValue(100)->end()
512 16
                        ->scalarNode('clear_object_manager')->defaultTrue()->end()
513 16
                        ->scalarNode('debug_logging')
514 16
                            ->defaultValue($this->debug)
515 16
                            ->treatNullLike(true)
516 16
                        ->end()
517 16
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
518 16
                        ->scalarNode('service')->end()
519 16
                    ->end()
520 16
                ->end()
521 16
                ->arrayNode('listener')
522 16
                    ->children()
523 16
                        ->scalarNode('insert')->defaultTrue()->end()
524 16
                        ->scalarNode('update')->defaultTrue()->end()
525 16
                        ->scalarNode('delete')->defaultTrue()->end()
526 16
                        ->scalarNode('flush')->defaultTrue()->end()
527 16
                        ->booleanNode('immediate')->defaultFalse()->end()
528 16
                        ->scalarNode('logger')
529 16
                            ->defaultFalse()
530 16
                            ->treatNullLike('fos_elastica.logger')
531 16
                            ->treatTrueLike('fos_elastica.logger')
532 16
                        ->end()
533 16
                        ->scalarNode('service')->end()
534 16
                    ->end()
535 16
                ->end()
536 16
                ->arrayNode('finder')
537 16
                    ->children()
538 16
                        ->scalarNode('service')->end()
539 16
                    ->end()
540 16
                ->end()
541 16
                ->arrayNode('elastica_to_model_transformer')
542 16
                    ->addDefaultsIfNotSet()
543 16
                    ->children()
544 16
                        ->booleanNode('hydrate')->defaultTrue()->end()
545 16
                        ->booleanNode('ignore_missing')
546 16
                            ->defaultFalse()
547 16
                            ->info('Silently ignore results returned from Elasticsearch without corresponding persistent object.')
548 16
                        ->end()
549 16
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
550 16
                        ->scalarNode('service')->end()
551 16
                    ->end()
552 16
                ->end()
553 16
                ->arrayNode('model_to_elastica_transformer')
554 16
                    ->addDefaultsIfNotSet()
555 16
                    ->children()
556 16
                        ->scalarNode('service')->end()
557 16
                    ->end()
558 16
                ->end()
559 16
            ->end();
560
561 16
        return $node;
562
    }
563
564
    /**
565
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
566
     */
567 16
    protected function getSerializerNode()
568
    {
569 16
        $builder = new TreeBuilder();
570 16
        $node = $builder->root('serializer');
571
572
        $node
573 16
            ->addDefaultsIfNotSet()
574 16
            ->children()
575 16
                ->arrayNode('groups')
576 16
                    ->treatNullLike(array())
577 16
                    ->prototype('scalar')->end()
578 16
                ->end()
579 16
                ->scalarNode('version')->end()
580 16
            ->end();
581
582 16
        return $node;
583
    }
584
}
585