Completed
Push — master ( f0cf2e...0fffc8 )
by Karel
11:40 queued 04:22
created

Configuration::addIndexesSection()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

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