Completed
Pull Request — master (#1134)
by Istvan
14:27
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 82
Code Lines 70

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 62
CRAP Score 4.0015

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 82
ccs 62
cts 65
cp 0.9538
rs 8.5076
cc 4
eloc 70
nc 1
nop 1
crap 4.0015

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 26
    public function __construct($debug)
26
    {
27 26
        $this->debug = $debug;
28 26
    }
29
30
    /**
31
     * Generates the configuration tree.
32
     *
33
     * @return TreeBuilder
34
     */
35 26
    public function getConfigTreeBuilder()
36
    {
37 26
        $treeBuilder = new TreeBuilder();
38 26
        $rootNode = $treeBuilder->root('fos_elastica', 'array');
39
40 26
        $this->addClientsSection($rootNode);
41 26
        $this->addIndexesSection($rootNode);
42
43
        $rootNode
44 26
            ->children()
45 26
                ->scalarNode('default_client')
46 26
                    ->info('Defaults to the first client defined')
47 26
                ->end()
48 26
                ->scalarNode('default_index')
49 26
                    ->info('Defaults to the first index defined')
50 26
                ->end()
51 26
                ->scalarNode('default_manager')->defaultValue('orm')->end()
52 26
                ->arrayNode('serializer')
53 26
                    ->treatNullLike(array())
54 26
                    ->children()
55 26
                        ->scalarNode('callback_class')->defaultValue('FOS\ElasticaBundle\Serializer\Callback')->end()
56 26
                        ->scalarNode('serializer')->defaultValue('serializer')->end()
57 26
                    ->end()
58 26
                ->end()
59 26
            ->end()
60
        ;
61
62 26
        return $treeBuilder;
63
    }
64
65
    /**
66
     * Adds the configuration for the "clients" key.
67
     */
68 26
    private function addClientsSection(ArrayNodeDefinition $rootNode)
69
    {
70
        $rootNode
71 26
            ->fixXmlConfig('client')
72 26
            ->children()
73 26
                ->arrayNode('clients')
74 26
                    ->useAttributeAsKey('id')
75 26
                    ->prototype('array')
76 26
                        ->performNoDeepMerging()
77
                        // BC - Renaming 'servers' node to 'connections'
78 26
                        ->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 26
                        })
86 26
                        ->end()
87
                        // Elastica names its properties with camel case, support both
88 26
                        ->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 26
                        })
96 26
                        ->end()
97
                        // If there is no connections array key defined, assume a single connection.
98 26
                        ->beforeNormalization()
99
                        ->ifTrue(function ($v) { return is_array($v) && !array_key_exists('connections', $v); })
100
                        ->then(function ($v) {
101
                            return array(
102 25
                                'connections' => array($v),
103 25
                            );
104 26
                        })
105 26
                        ->end()
106 26
                        ->children()
107 26
                            ->arrayNode('connections')
108 26
                                ->requiresAtLeastOneElement()
109 26
                                ->prototype('array')
110 26
                                    ->fixXmlConfig('header')
111 26
                                    ->children()
112 26
                                        ->scalarNode('url')
113 26
                                            ->validate()
114
                                                ->ifTrue(function ($url) { return $url && substr($url, -1) !== '/'; })
115
                                                ->then(function ($url) { return $url.'/'; })
116 26
                                            ->end()
117 26
                                        ->end()
118 26
                                        ->scalarNode('host')->end()
119 26
                                        ->scalarNode('port')->end()
120 26
                                        ->scalarNode('proxy')->end()
121 26
                                        ->scalarNode('logger')
122 26
                                            ->defaultValue($this->debug ? 'fos_elastica.logger' : false)
123 26
                                            ->treatNullLike('fos_elastica.logger')
124 26
                                            ->treatTrueLike('fos_elastica.logger')
125 26
                                        ->end()
126 26
                                        ->booleanNode('compression')->defaultValue(false)->end()
127 26
                                        ->arrayNode('headers')
128 26
                                            ->useAttributeAsKey('name')
129 26
                                            ->prototype('scalar')->end()
130 26
                                        ->end()
131 26
                                        ->scalarNode('transport')->end()
132 26
                                        ->scalarNode('timeout')->end()
133 26
                                        ->scalarNode('connectTimeout')->end()
134 26
                                        ->scalarNode('retryOnConflict')
135 26
                                            ->defaultValue(0)
136 26
                                        ->end()
137 26
                                    ->end()
138 26
                                ->end()
139 26
                            ->end()
140 26
                            ->scalarNode('timeout')->end()
141 26
                            ->scalarNode('connectTimeout')->end()
142 26
                            ->scalarNode('headers')->end()
143 26
                            ->scalarNode('connectionStrategy')->defaultValue('Simple')->end()
144 26
                        ->end()
145 26
                    ->end()
146 26
                ->end()
147 26
            ->end()
148
        ;
149 26
    }
150
151
    /**
152
     * Adds the configuration for the "indexes" key.
153
     */
154 26
    private function addIndexesSection(ArrayNodeDefinition $rootNode)
155
    {
156
        $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...
157 26
            ->fixXmlConfig('index')
158 26
            ->children()
159 26
                ->arrayNode('indexes')
160 26
                    ->useAttributeAsKey('name')
161 26
                    ->prototype('array')
162 26
                        ->children()
163 26
                            ->scalarNode('index_name')
164 26
                                ->info('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch')
165 26
                            ->end()
166 26
                            ->booleanNode('use_alias')->defaultValue(false)->end()
167 26
                            ->scalarNode('client')->end()
168 26
                            ->scalarNode('finder')
169 26
                                ->treatNullLike(true)
170 26
                                ->defaultFalse()
171 26
                            ->end()
172 26
                            ->arrayNode('type_prototype')
173 26
                                ->children()
174 26
                                    ->scalarNode('analyzer')->end()
175 26
                                    ->append($this->getPersistenceNode())
176 26
                                    ->append($this->getSerializerNode())
177 26
                                ->end()
178 26
                            ->end()
179 26
                            ->variableNode('settings')->defaultValue(array())->end()
180 26
                        ->end()
181 26
                        ->append($this->getTypesNode())
182 26
                    ->end()
183 26
                ->end()
184 26
            ->end()
185
        ;
186 26
    }
187
188
    /**
189
     * Returns the array node used for "types".
190
     */
191 26
    protected function getTypesNode()
192
    {
193 26
        $builder = new TreeBuilder();
194 26
        $node = $builder->root('types');
195
196
        $node
197 26
            ->useAttributeAsKey('name')
198 26
            ->prototype('array')
199 26
                ->treatNullLike(array())
200 26
                ->beforeNormalization()
201 26
                ->ifNull()
202 26
                ->thenEmptyArray()
203 26
                ->end()
204
                // BC - Renaming 'mappings' node to 'properties'
205 26
                ->beforeNormalization()
206
                ->ifTrue(function ($v) { return array_key_exists('mappings', $v); })
207
                ->then(function ($v) {
208 13
                    $v['properties'] = $v['mappings'];
209 13
                    unset($v['mappings']);
210
211 13
                    return $v;
212 26
                })
213 26
                ->end()
214
                // BC - Support the old is_indexable_callback property
215 26
                ->beforeNormalization()
216
                ->ifTrue(function ($v) {
217 18
                    return isset($v['persistence']) &&
218 18
                        isset($v['persistence']['listener']) &&
219 18
                        isset($v['persistence']['listener']['is_indexable_callback']);
220 26
                })
221
                ->then(function ($v) {
222 5
                    $callback = $v['persistence']['listener']['is_indexable_callback'];
223
224 5
                    if (is_array($callback)) {
225 5
                        list($class) = $callback + array(null);
226
227 5
                        if ($class[0] !== '@' && is_string($class) && !class_exists($class)) {
228
                            $callback[0] = '@'.$class;
229
                        }
230 5
                    }
231
232 5
                    $v['indexable_callback'] = $callback;
233 5
                    unset($v['persistence']['listener']['is_indexable_callback']);
234
235 5
                    return $v;
236 26
                })
237 26
                ->end()
238
                // Support multiple dynamic_template formats to match the old bundle style
239
                // and the way ElasticSearch expects them
240 26
                ->beforeNormalization()
241
                ->ifTrue(function ($v) { return isset($v['dynamic_templates']); })
242
                ->then(function ($v) {
243 4
                    $dt = array();
244 4
                    foreach ($v['dynamic_templates'] as $key => $type) {
245 4
                        if (is_int($key)) {
246 4
                            $dt[] = $type;
247 4
                        } else {
248 4
                            $dt[][$key] = $type;
249
                        }
250 4
                    }
251
252 4
                    $v['dynamic_templates'] = $dt;
253
254 4
                    return $v;
255 26
                })
256 26
                ->end()
257 26
                ->children()
258 26
                    ->booleanNode('date_detection')->end()
259 26
                    ->arrayNode('dynamic_date_formats')->prototype('scalar')->end()->end()
260 26
                    ->scalarNode('analyzer')->end()
261 26
                    ->booleanNode('numeric_detection')->end()
262 26
                    ->scalarNode('dynamic')->end()
263 26
                    ->variableNode('indexable_callback')->end()
264 26
                    ->append($this->getPersistenceNode())
265 26
                    ->append($this->getSerializerNode())
266 26
                ->end()
267 26
                ->append($this->getIdNode())
268 26
                ->append($this->getPropertiesNode())
269 26
                ->append($this->getDynamicTemplateNode())
270 26
                ->append($this->getSourceNode())
271 26
                ->append($this->getBoostNode())
272 26
                ->append($this->getRoutingNode())
273 26
                ->append($this->getParentNode())
274 26
                ->append($this->getAllNode())
275 26
                ->append($this->getTimestampNode())
276 26
                ->append($this->getTtlNode())
277 26
            ->end()
278
        ;
279
280 26
        return $node;
281
    }
282
283
    /**
284
     * Returns the array node used for "properties".
285
     */
286 26
    protected function getPropertiesNode()
287
    {
288 26
        $builder = new TreeBuilder();
289 26
        $node = $builder->root('properties');
290
291
        $node
292 26
            ->useAttributeAsKey('name')
293 26
            ->prototype('variable')
294 26
                ->treatNullLike(array());
295
296 26
        return $node;
297
    }
298
299
    /**
300
     * Returns the array node used for "dynamic_templates".
301
     */
302 26
    public function getDynamicTemplateNode()
303
    {
304 26
        $builder = new TreeBuilder();
305 26
        $node = $builder->root('dynamic_templates');
306
307
        $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...
308 26
            ->prototype('array')
309 26
                ->prototype('array')
310 26
                    ->children()
311 26
                        ->scalarNode('match')->end()
312 26
                        ->scalarNode('unmatch')->end()
313 26
                        ->scalarNode('match_mapping_type')->end()
314 26
                        ->scalarNode('path_match')->end()
315 26
                        ->scalarNode('path_unmatch')->end()
316 26
                        ->scalarNode('match_pattern')->end()
317 26
                        ->arrayNode('mapping')
318 26
                            ->prototype('variable')
319 26
                                ->treatNullLike(array())
320 26
                            ->end()
321 26
                        ->end()
322 26
                    ->end()
323 26
                ->end()
324 26
            ->end()
325
        ;
326
327 26
        return $node;
328
    }
329
330
    /**
331
     * Returns the array node used for "_id".
332
     */
333 26 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...
334
    {
335 26
        $builder = new TreeBuilder();
336 26
        $node = $builder->root('_id');
337
338
        $node
339 26
            ->children()
340 26
            ->scalarNode('path')->end()
341 26
            ->end()
342
        ;
343
344 26
        return $node;
345
    }
346
347
    /**
348
     * Returns the array node used for "_source".
349
     */
350 26
    protected function getSourceNode()
351
    {
352 26
        $builder = new TreeBuilder();
353 26
        $node = $builder->root('_source');
354
355
        $node
356 26
            ->children()
357 26
                ->arrayNode('excludes')
358 26
                    ->useAttributeAsKey('name')
359 26
                    ->prototype('scalar')->end()
360 26
                ->end()
361 26
                ->arrayNode('includes')
362 26
                    ->useAttributeAsKey('name')
363 26
                    ->prototype('scalar')->end()
364 26
                ->end()
365 26
                ->scalarNode('compress')->end()
366 26
                ->scalarNode('compress_threshold')->end()
367 26
                ->scalarNode('enabled')->defaultTrue()->end()
368 26
            ->end()
369
        ;
370
371 26
        return $node;
372
    }
373
374
    /**
375
     * Returns the array node used for "_boost".
376
     */
377 26
    protected function getBoostNode()
378
    {
379 26
        $builder = new TreeBuilder();
380 26
        $node = $builder->root('_boost');
381
382
        $node
383 26
            ->children()
384 26
                ->scalarNode('name')->end()
385 26
                ->scalarNode('null_value')->end()
386 26
            ->end()
387
        ;
388
389 26
        return $node;
390
    }
391
392
    /**
393
     * Returns the array node used for "_routing".
394
     */
395 26 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...
396
    {
397 26
        $builder = new TreeBuilder();
398 26
        $node = $builder->root('_routing');
399
400
        $node
401 26
            ->children()
402 26
                ->scalarNode('required')->end()
403 26
                ->scalarNode('path')->end()
404 26
            ->end()
405
        ;
406
407 26
        return $node;
408
    }
409
410
    /**
411
     * Returns the array node used for "_parent".
412
     */
413 26
    protected function getParentNode()
414
    {
415 26
        $builder = new TreeBuilder();
416 26
        $node = $builder->root('_parent');
417
418
        $node
419 26
            ->children()
420 26
                ->scalarNode('type')->end()
421 26
                ->scalarNode('property')->defaultValue(null)->end()
422 26
                ->scalarNode('identifier')->defaultValue('id')->end()
423 26
            ->end()
424
        ;
425
426 26
        return $node;
427
    }
428
429
    /**
430
     * Returns the array node used for "_all".
431
     */
432 26
    protected function getAllNode()
433
    {
434 26
        $builder = new TreeBuilder();
435 26
        $node = $builder->root('_all');
436
437
        $node
438 26
            ->children()
439 26
            ->scalarNode('enabled')->defaultValue(true)->end()
440 26
            ->scalarNode('analyzer')->end()
441 26
            ->end()
442
        ;
443
444 26
        return $node;
445
    }
446
447
    /**
448
     * Returns the array node used for "_timestamp".
449
     */
450 26 View Code Duplication
    protected function getTimestampNode()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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

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

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

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

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

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

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

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

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

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

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

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