Completed
Pull Request — master (#1193)
by
unknown
16:25 queued 07:13
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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