Completed
Pull Request — master (#1054)
by
unknown
14:26 queued 11:52
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 80
Code Lines 68

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 60
CRAP Score 4.0016

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 0
loc 80
ccs 60
cts 63
cp 0.9524
rs 8.5454
c 2
b 0
f 1
cc 4
eloc 68
nc 1
nop 1
crap 4.0016

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