Completed
Pull Request — master (#993)
by David
16:22
created

Configuration::getPersistenceNode()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 82
Code Lines 78

Duplication

Lines 2
Ratio 2.44 %

Code Coverage

Tests 75
CRAP Score 5

Importance

Changes 3
Bugs 1 Features 0
Metric Value
dl 2
loc 82
c 3
b 1
f 0
ccs 75
cts 75
cp 1
rs 8.3769
cc 5
eloc 78
nc 1
nop 0
crap 5

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
                            );
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
                                    ->end()
133 22
                                ->end()
134 22
                            ->end()
135 22
                            ->scalarNode('timeout')->end()
136 22
                            ->scalarNode('headers')->end()
137 22
                            ->scalarNode('connectionStrategy')->defaultValue('Simple')->end()
138 22
                        ->end()
139 22
                    ->end()
140 22
                ->end()
141 22
            ->end()
142
        ;
143 22
    }
144
145
    /**
146
     * Adds the configuration for the "indexes" key.
147
     */
148 22
    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 22
            ->fixXmlConfig('index')
152 22
            ->children()
153 22
                ->arrayNode('indexes')
154 22
                    ->useAttributeAsKey('name')
155 22
                    ->prototype('array')
156 22
                        ->children()
157 22
                            ->scalarNode('index_name')
158 22
                                ->info('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch')
159 22
                            ->end()
160 22
                            ->booleanNode('use_alias')->defaultValue(false)->end()
161 22
                            ->scalarNode('client')->end()
162 22
                            ->scalarNode('finder')
163 22
                                ->treatNullLike(true)
164 22
                                ->defaultFalse()
165 22
                            ->end()
166 22
                            ->arrayNode('type_prototype')
167 22
                                ->children()
168 22
                                    ->scalarNode('index_analyzer')->end()
169 22
                                    ->scalarNode('search_analyzer')->end()
170 22
                                    ->append($this->getPersistenceNode())
171 22
                                    ->append($this->getSerializerNode())
172 22
                                ->end()
173 22
                            ->end()
174 22
                            ->variableNode('settings')->defaultValue(array())->end()
175 22
                        ->end()
176 22
                        ->append($this->getTypesNode())
177 22
                    ->end()
178 22
                ->end()
179 22
            ->end()
180
        ;
181 22
    }
182
183
    /**
184
     * Returns the array node used for "types".
185
     */
186 22
    protected function getTypesNode()
187
    {
188 22
        $builder = new TreeBuilder();
189 22
        $node = $builder->root('types');
190
191
        $node
192 22
            ->useAttributeAsKey('name')
193 22
            ->prototype('array')
194 22
                ->treatNullLike(array())
195 22
                ->beforeNormalization()
196 22
                ->ifNull()
197 22
                ->thenEmptyArray()
198 22
                ->end()
199
                // BC - Renaming 'mappings' node to 'properties'
200 22
                ->beforeNormalization()
201
                ->ifTrue(function ($v) { return array_key_exists('mappings', $v); })
202
                ->then(function ($v) {
203 13
                    $v['properties'] = $v['mappings'];
204 13
                    unset($v['mappings']);
205
206 13
                    return $v;
207 22
                })
208 22
                ->end()
209
                // BC - Support the old is_indexable_callback property
210 22
                ->beforeNormalization()
211
                ->ifTrue(function ($v) {
212 17
                    return isset($v['persistence']) &&
213 17
                        isset($v['persistence']['listener']) &&
214 17
                        isset($v['persistence']['listener']['is_indexable_callback']);
215 22
                })
216
                ->then(function ($v) {
217 5
                    $callback = $v['persistence']['listener']['is_indexable_callback'];
218
219 5
                    if (is_array($callback)) {
220 5
                        list($class) = $callback + array(null);
221
222 5
                        if ($class[0] !== '@' && is_string($class) && !class_exists($class)) {
223
                            $callback[0] = '@'.$class;
224
                        }
225
                    }
226
227 5
                    $v['indexable_callback'] = $callback;
228 5
                    unset($v['persistence']['listener']['is_indexable_callback']);
229
230 5
                    return $v;
231 22
                })
232 22
                ->end()
233
                // Support multiple dynamic_template formats to match the old bundle style
234
                // and the way ElasticSearch expects them
235 22
                ->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 22
                })
251 22
                ->end()
252 22
                ->children()
253 22
                    ->booleanNode('date_detection')->end()
254 22
                    ->arrayNode('dynamic_date_formats')->prototype('scalar')->end()->end()
255 22
                    ->scalarNode('index_analyzer')->end()
256 22
                    ->booleanNode('numeric_detection')->end()
257 22
                    ->scalarNode('search_analyzer')->end()
258 22
                    ->variableNode('indexable_callback')->end()
259 22
                    ->append($this->getPersistenceNode())
260 22
                    ->append($this->getSerializerNode())
261 22
                ->end()
262 22
                ->append($this->getIdNode())
263 22
                ->append($this->getPropertiesNode())
264 22
                ->append($this->getDynamicTemplateNode())
265 22
                ->append($this->getSourceNode())
266 22
                ->append($this->getBoostNode())
267 22
                ->append($this->getRoutingNode())
268 22
                ->append($this->getParentNode())
269 22
                ->append($this->getAllNode())
270 22
                ->append($this->getTimestampNode())
271 22
                ->append($this->getTtlNode())
272 22
            ->end()
273
        ;
274
275 22
        return $node;
276
    }
277
278
    /**
279
     * Returns the array node used for "properties".
280
     */
281 22
    protected function getPropertiesNode()
282
    {
283 22
        $builder = new TreeBuilder();
284 22
        $node = $builder->root('properties');
285
286
        $node
287 22
            ->useAttributeAsKey('name')
288 22
            ->prototype('variable')
289 22
                ->treatNullLike(array());
290
291 22
        return $node;
292
    }
293
294
    /**
295
     * Returns the array node used for "dynamic_templates".
296
     */
297 22
    public function getDynamicTemplateNode()
298
    {
299 22
        $builder = new TreeBuilder();
300 22
        $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 22
            ->prototype('array')
304 22
                ->prototype('array')
305 22
                    ->children()
306 22
                        ->scalarNode('match')->end()
307 22
                        ->scalarNode('unmatch')->end()
308 22
                        ->scalarNode('match_mapping_type')->end()
309 22
                        ->scalarNode('path_match')->end()
310 22
                        ->scalarNode('path_unmatch')->end()
311 22
                        ->scalarNode('match_pattern')->end()
312 22
                        ->arrayNode('mapping')
313 22
                            ->prototype('variable')
314 22
                                ->treatNullLike(array())
315 22
                            ->end()
316 22
                        ->end()
317 22
                    ->end()
318 22
                ->end()
319 22
            ->end()
320
        ;
321
322 22
        return $node;
323
    }
324
325
    /**
326
     * Returns the array node used for "_id".
327
     */
328 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...
329
    {
330 22
        $builder = new TreeBuilder();
331 22
        $node = $builder->root('_id');
332
333
        $node
334 22
            ->children()
335 22
            ->scalarNode('path')->end()
336 22
            ->end()
337
        ;
338
339 22
        return $node;
340
    }
341
342
    /**
343
     * Returns the array node used for "_source".
344
     */
345 22
    protected function getSourceNode()
346
    {
347 22
        $builder = new TreeBuilder();
348 22
        $node = $builder->root('_source');
349
350
        $node
351 22
            ->children()
352 22
                ->arrayNode('excludes')
353 22
                    ->useAttributeAsKey('name')
354 22
                    ->prototype('scalar')->end()
355 22
                ->end()
356 22
                ->arrayNode('includes')
357 22
                    ->useAttributeAsKey('name')
358 22
                    ->prototype('scalar')->end()
359 22
                ->end()
360 22
                ->scalarNode('compress')->end()
361 22
                ->scalarNode('compress_threshold')->end()
362 22
                ->scalarNode('enabled')->defaultTrue()->end()
363 22
            ->end()
364
        ;
365
366 22
        return $node;
367
    }
368
369
    /**
370
     * Returns the array node used for "_boost".
371
     */
372 22
    protected function getBoostNode()
373
    {
374 22
        $builder = new TreeBuilder();
375 22
        $node = $builder->root('_boost');
376
377
        $node
378 22
            ->children()
379 22
                ->scalarNode('name')->end()
380 22
                ->scalarNode('null_value')->end()
381 22
            ->end()
382
        ;
383
384 22
        return $node;
385
    }
386
387
    /**
388
     * Returns the array node used for "_routing".
389
     */
390 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...
391
    {
392 22
        $builder = new TreeBuilder();
393 22
        $node = $builder->root('_routing');
394
395
        $node
396 22
            ->children()
397 22
                ->scalarNode('required')->end()
398 22
                ->scalarNode('path')->end()
399 22
            ->end()
400
        ;
401
402 22
        return $node;
403
    }
404
405
    /**
406
     * Returns the array node used for "_parent".
407
     */
408 22
    protected function getParentNode()
409
    {
410 22
        $builder = new TreeBuilder();
411 22
        $node = $builder->root('_parent');
412
413
        $node
414 22
            ->children()
415 22
                ->scalarNode('type')->end()
416 22
                ->scalarNode('property')->defaultValue(null)->end()
417 22
                ->scalarNode('identifier')->defaultValue('id')->end()
418 22
            ->end()
419
        ;
420
421 22
        return $node;
422
    }
423
424
    /**
425
     * Returns the array node used for "_all".
426
     */
427 22
    protected function getAllNode()
428
    {
429 22
        $builder = new TreeBuilder();
430 22
        $node = $builder->root('_all');
431
432
        $node
433 22
            ->children()
434 22
            ->scalarNode('enabled')->defaultValue(true)->end()
435 22
            ->scalarNode('index_analyzer')->end()
436 22
            ->scalarNode('search_analyzer')->end()
437 22
            ->end()
438
        ;
439
440 22
        return $node;
441
    }
442
443
    /**
444
     * Returns the array node used for "_timestamp".
445
     */
446 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...
447
    {
448 22
        $builder = new TreeBuilder();
449 22
        $node = $builder->root('_timestamp');
450
451
        $node
452 22
            ->children()
453 22
            ->scalarNode('enabled')->defaultValue(true)->end()
454 22
            ->scalarNode('path')->end()
455 22
            ->scalarNode('format')->end()
456 22
            ->scalarNode('store')->end()
457 22
            ->scalarNode('index')->end()
458 22
            ->end()
459
        ;
460
461 22
        return $node;
462
    }
463
464
    /**
465
     * Returns the array node used for "_ttl".
466
     */
467 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...
468
    {
469 22
        $builder = new TreeBuilder();
470 22
        $node = $builder->root('_ttl');
471
472
        $node
473 22
            ->children()
474 22
            ->scalarNode('enabled')->defaultValue(true)->end()
475 22
            ->scalarNode('default')->end()
476 22
            ->scalarNode('store')->end()
477 22
            ->scalarNode('index')->end()
478 22
            ->end()
479
        ;
480
481 22
        return $node;
482
    }
483
484
    /**
485
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
486
     */
487 22
    protected function getPersistenceNode()
488
    {
489 22
        $builder = new TreeBuilder();
490 22
        $node = $builder->root('persistence');
491
492
        $node
493 22
            ->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 22
                    ->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 22
                    ->thenInvalid('Propel doesn\'t support the "repository" parameter')
498 22
            ->end()
499 22
            ->children()
500 22
                ->scalarNode('driver')
501 22
                    ->validate()
502 22
                    ->ifNotInArray($this->supportedDrivers)
503 22
                        ->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($this->supportedDrivers))
504 22
                    ->end()
505 22
                ->end()
506 22
                ->scalarNode('model')->end()
507 22
                ->scalarNode('repository')->end()
508 22
                ->scalarNode('identifier')->defaultValue('id')->end()
509 22
                ->arrayNode('provider')
510 22
                    ->children()
511 22
                        ->scalarNode('batch_size')->defaultValue(100)->end()
512 22
                        ->scalarNode('clear_object_manager')->defaultTrue()->end()
513 22
                        ->scalarNode('debug_logging')
514 22
                            ->defaultValue($this->debug)
515 22
                            ->treatNullLike(true)
516 22
                        ->end()
517 22
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
518 22
                        ->scalarNode('service')->end()
519 22
                    ->end()
520 22
                ->end()
521 22
                ->arrayNode('listener')
522 22
                    ->children()
523 22
                        ->scalarNode('insert')->defaultTrue()->end()
524 22
                        ->scalarNode('update')->defaultTrue()->end()
525 22
                        ->scalarNode('delete')->defaultTrue()->end()
526 22
                        ->scalarNode('flush')->defaultTrue()->end()
527 22
                        ->booleanNode('immediate')->defaultFalse()->end()
528 22
                        ->scalarNode('logger')
529 22
                            ->defaultFalse()
530 22
                            ->treatNullLike('fos_elastica.logger')
531 22
                            ->treatTrueLike('fos_elastica.logger')
532 22
                        ->end()
533 22
                        ->scalarNode('service')->end()
534 22
                    ->end()
535 22
                ->end()
536 22
                ->arrayNode('finder')
537 22
                    ->children()
538 22
                        ->scalarNode('service')->end()
539 22
                    ->end()
540 22
                ->end()
541 22
                ->arrayNode('elastica_to_model_transformer')
542 22
                    ->addDefaultsIfNotSet()
543 22
                    ->children()
544 22
                        ->booleanNode('hydrate')->defaultTrue()->end()
545 22
                        ->booleanNode('ignore_missing')
546 22
                            ->defaultFalse()
547 22
                            ->info('Silently ignore results returned from Elasticsearch without corresponding persistent object.')
548 22
                        ->end()
549 22
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
550 22
                        ->scalarNode('service')->end()
551 22
                    ->end()
552 22
                ->end()
553 22
                ->arrayNode('model_to_elastica_transformer')
554 22
                    ->addDefaultsIfNotSet()
555 22
                    ->children()
556 22
                        ->scalarNode('service')->end()
557 22
                    ->end()
558 22
                ->end()
559 22
                ->arrayNode('persister')
560 22
                    ->addDefaultsIfNotSet()
561 22
                    ->children()
562 22
                        ->scalarNode('service')->end()
563 22
                    ->end()
564 22
                ->end()
565 22
            ->end();
566
567 22
        return $node;
568
    }
569
570
    /**
571
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
572
     */
573 22
    protected function getSerializerNode()
574
    {
575 22
        $builder = new TreeBuilder();
576 22
        $node = $builder->root('serializer');
577
578
        $node
579 22
            ->addDefaultsIfNotSet()
580 22
            ->children()
581 22
                ->arrayNode('groups')
582 22
                    ->treatNullLike(array())
583 22
                    ->prototype('scalar')->end()
584 22
                ->end()
585 22
                ->scalarNode('version')->end()
586 22
            ->end();
587
588 22
        return $node;
589
    }
590
}
591