Completed
Push — master ( 8ebb9e...d39589 )
by Karel
25:26 queued 19:39
created

Configuration::addClientsSection()   B

Complexity

Conditions 4
Paths 1

Size

Total Lines 90
Code Lines 78

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 70
CRAP Score 4.0011

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 90
ccs 70
cts 73
cp 0.9589
rs 8.3623
cc 4
eloc 78
nc 1
nop 1
crap 4.0011

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

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
362 27
            ->children()
363 27
                ->arrayNode('excludes')
364 27
                    ->useAttributeAsKey('name')
365 27
                    ->prototype('scalar')->end()
366 27
                ->end()
367 27
                ->arrayNode('includes')
368 27
                    ->useAttributeAsKey('name')
369 27
                    ->prototype('scalar')->end()
370 27
                ->end()
371 27
                ->scalarNode('compress')->end()
372 27
                ->scalarNode('compress_threshold')->end()
373 27
                ->scalarNode('enabled')->defaultTrue()->end()
374 27
            ->end()
375
        ;
376
377 27
        return $node;
378
    }
379
380
    /**
381
     * Returns the array node used for "_boost".
382
     */
383 27
    protected function getBoostNode()
384
    {
385 27
        $builder = new TreeBuilder();
386 27
        $node = $builder->root('_boost');
387
388
        $node
389 27
            ->children()
390 27
                ->scalarNode('name')->end()
391 27
                ->scalarNode('null_value')->end()
392 27
            ->end()
393
        ;
394
395 27
        return $node;
396
    }
397
398
    /**
399
     * Returns the array node used for "_routing".
400
     */
401 27 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...
402
    {
403 27
        $builder = new TreeBuilder();
404 27
        $node = $builder->root('_routing');
405
406
        $node
407 27
            ->children()
408 27
                ->scalarNode('required')->end()
409 27
                ->scalarNode('path')->end()
410 27
            ->end()
411
        ;
412
413 27
        return $node;
414
    }
415
416
    /**
417
     * Returns the array node used for "_parent".
418
     */
419 27
    protected function getParentNode()
420
    {
421 27
        $builder = new TreeBuilder();
422 27
        $node = $builder->root('_parent');
423
424
        $node
425 27
            ->children()
426 27
                ->scalarNode('type')->end()
427 27
                ->scalarNode('property')->defaultValue(null)->end()
428 27
                ->scalarNode('identifier')->defaultValue('id')->end()
429 27
            ->end()
430
        ;
431
432 27
        return $node;
433
    }
434
435
    /**
436
     * Returns the array node used for "_all".
437
     */
438 27
    protected function getAllNode()
439
    {
440 27
        $builder = new TreeBuilder();
441 27
        $node = $builder->root('_all');
442
443
        $node
444 27
            ->children()
445 27
            ->scalarNode('enabled')->defaultValue(true)->end()
446 27
            ->scalarNode('analyzer')->end()
447 27
            ->end()
448
        ;
449
450 27
        return $node;
451
    }
452
453
    /**
454
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
455
     */
456 27
    protected function getPersistenceNode()
457
    {
458 27
        $builder = new TreeBuilder();
459 27
        $node = $builder->root('persistence');
460
461
        $node
462 27
            ->beforeNormalization()
463
                ->ifTrue(function($v) { return isset($v['immediate']); })
464
                    ->then(function($v) {
465
                        @trigger_error('The immediate configuration key is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
466
467
                        return $v;
468 27
                    })
469 27
            ->end()
470 27
            ->validate()
471 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...
472 27
                    ->thenInvalid('Propel doesn\'t support listeners')
473 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...
474 27
                    ->thenInvalid('Propel doesn\'t support the "repository" parameter')
475
                ->ifTrue(function($v) { return isset($v['driver']) && 'orm' !== $v['driver'] && !empty($v['elastica_to_model_transformer']['hints']); })
476 27
                    ->thenInvalid('Hints are only supported by the "orm" driver')
477 27
            ->end()
478 27
            ->children()
479 27
                ->scalarNode('driver')
480 27
                    ->defaultValue('orm')
481 27
                    ->validate()
482 27
                    ->ifNotInArray($this->supportedDrivers)
483 27
                        ->thenInvalid('The driver %s is not supported. Please choose one of '.json_encode($this->supportedDrivers))
484 27
                    ->end()
485 27
                ->end()
486 27
                ->scalarNode('model')->defaultValue(null)->end()
487 27
                ->scalarNode('repository')->end()
488 27
                ->scalarNode('identifier')->defaultValue('id')->end()
489 27
                ->arrayNode('provider')
490 27
                    ->addDefaultsIfNotSet()
491 27
                    ->children()
492 27
                        ->scalarNode('batch_size')->defaultValue(100)->end()
493 27
                        ->scalarNode('clear_object_manager')->defaultTrue()->end()
494 27
                        ->scalarNode('debug_logging')
495 27
                            ->defaultValue($this->debug)
496 27
                            ->treatNullLike(true)
497 27
                        ->end()
498 27
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
499 27
                        ->scalarNode('service')->end()
500 27
                    ->end()
501 27
                ->end()
502 27
                ->arrayNode('listener')
503 27
                    ->addDefaultsIfNotSet()
504 27
                    ->children()
505 27
                        ->scalarNode('insert')->defaultTrue()->end()
506 27
                        ->scalarNode('update')->defaultTrue()->end()
507 27
                        ->scalarNode('delete')->defaultTrue()->end()
508 27
                        ->scalarNode('flush')->defaultTrue()->end()
509 27
                        ->booleanNode('immediate')->defaultFalse()->end()
510 27
                        ->scalarNode('logger')
511 27
                            ->defaultFalse()
512 27
                            ->treatNullLike('fos_elastica.logger')
513 27
                            ->treatTrueLike('fos_elastica.logger')
514 27
                        ->end()
515 27
                        ->scalarNode('service')->end()
516 27
                    ->end()
517 27
                ->end()
518 27
                ->arrayNode('finder')
519 27
                    ->addDefaultsIfNotSet()
520 27
                    ->children()
521 27
                        ->scalarNode('service')->end()
522 27
                    ->end()
523 27
                ->end()
524 27
                ->arrayNode('elastica_to_model_transformer')
525 27
                    ->addDefaultsIfNotSet()
526 27
                    ->children()
527 27
                        ->arrayNode('hints')
528 27
                            ->prototype('array')
529 27
                                ->children()
530 27
                                    ->scalarNode('name')->end()
531 27
                                    ->scalarNode('value')->end()
532 27
                                ->end()
533 27
                            ->end()
534 27
                        ->end()
535 27
                        ->booleanNode('hydrate')->defaultTrue()->end()
536 27
                        ->booleanNode('ignore_missing')
537 27
                            ->defaultFalse()
538 27
                            ->info('Silently ignore results returned from Elasticsearch without corresponding persistent object.')
539 27
                        ->end()
540 27
                        ->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()
541 27
                        ->scalarNode('service')->end()
542 27
                    ->end()
543 27
                ->end()
544 27
                ->arrayNode('model_to_elastica_transformer')
545 27
                    ->addDefaultsIfNotSet()
546 27
                    ->children()
547 27
                        ->scalarNode('service')->end()
548 27
                    ->end()
549 27
                ->end()
550 27
                ->arrayNode('persister')
551 27
                    ->addDefaultsIfNotSet()
552 27
                    ->children()
553 27
                        ->scalarNode('service')->end()
554 27
                    ->end()
555 27
                ->end()
556 27
            ->end();
557
558 27
        return $node;
559
    }
560
561
    /**
562
     * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
563
     */
564 27
    protected function getSerializerNode()
565
    {
566 27
        $builder = new TreeBuilder();
567 27
        $node = $builder->root('serializer');
568
569
        $node
0 ignored issues
show
Bug introduced by
The method scalarNode() does not seem to exist on object<Symfony\Component...odeDefinitionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
570 27
            ->addDefaultsIfNotSet()
571 27
            ->children()
572 27
                ->arrayNode('groups')
573 27
                    ->treatNullLike(array())
574 27
                    ->prototype('scalar')->end()
575 27
                ->end()
576 27
                ->scalarNode('version')->end()
577 27
                ->booleanNode('serialize_null')
578 27
                    ->defaultFalse()
579 27
                ->end()
580 27
            ->end();
581
582 27
        return $node;
583
    }
584
}
585