Completed
Pull Request — master (#992)
by David
05:34
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 76
Code Lines 64

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 55
CRAP Score 4

Importance

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

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