Completed
Push — master ( 52b06e...08177a )
by
unknown
04:10 queued 10s
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 8.9818
c 0
b 0
f 0
cc 2
nc 2
nop 0

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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
18
use Symfony\Component\Config\Definition\ConfigurationInterface;
19
20
/**
21
 * This is the class that validates and merges configuration from your app/config files.
22
 *
23
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
24
 */
25
class Configuration implements ConfigurationInterface
26
{
27
    /**
28
     * NEXT_MAJOR: make constant protected/private.
29
     */
30
    public const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr', 'no_driver'];
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getConfigTreeBuilder()
36
    {
37
        $treeBuilder = new TreeBuilder('sonata_media');
38
39
        // Keep compatibility with symfony/config < 4.2
40
        if (!method_exists($treeBuilder, 'getRootNode')) {
41
            $node = $treeBuilder->root('sonata_media');
42
        } else {
43
            $node = $treeBuilder->getRootNode();
44
        }
45
46
        $node
47
            ->children()
48
                ->scalarNode('db_driver')
49
                    ->defaultValue('no_driver')
50
                    ->info('Choose persistence mechanism driver from the following list: "doctrine_orm", "doctrine_mongodb", "doctrine_phpcr"')
51
                    ->validate()
52
                        ->ifNotInArray(self::DB_DRIVERS)
53
                        ->thenInvalid('SonataMediaBundle - Invalid db driver %s.')
54
                    ->end()
55
                ->end()
56
                ->scalarNode('default_context')->isRequired()->end()
57
                ->scalarNode('category_manager')
58
                    ->defaultValue('sonata.media.manager.category.default')
59
                ->end()
60
                ->booleanNode('force_disable_category')
61
                    ->info('true IF you really want to disable the relation with category')
62
                    ->defaultFalse()
63
                ->end()
64
                ->arrayNode('admin_format')
65
                    ->info('Configures the thumbnail preview for the admin')
66
                    ->addDefaultsIfNotSet()
67
                    ->children()
68
                        ->scalarNode('width')->defaultValue(200)->end()
69
                        ->scalarNode('height')->defaultValue(false)->end()
70
                        ->scalarNode('quality')->defaultValue(90)->end()
71
                        ->scalarNode('format')->defaultValue('jpg')->end()
72
                        ->scalarNode('constraint')->defaultValue(true)->end()
73
                    ->end()
74
                ->end()
75
            ->end()
76
        ;
77
78
        $this->addContextsSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
79
        $this->addCdnSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
80
        $this->addFilesystemSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
81
        $this->addProvidersSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
82
        $this->addExtraSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
83
        $this->addModelSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
84
        $this->addBuzzSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
85
        $this->addResizerSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
86
        $this->addAdapterSection($node);
0 ignored issues
show
Compatibility introduced by
$node of type object<Symfony\Component...Builder\NodeDefinition> is not a sub-type of object<Symfony\Component...er\ArrayNodeDefinition>. It seems like you assume a child class of the class Symfony\Component\Config...\Builder\NodeDefinition to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
87
88
        return $treeBuilder;
89
    }
90
91
    /**
92
     * @param ArrayNodeDefinition $node
93
     */
94
    private function addContextsSection(ArrayNodeDefinition $node): void
95
    {
96
        $node
97
            ->children()
98
                ->arrayNode('contexts')
99
                    ->useAttributeAsKey('id')
100
                    ->prototype('array')
101
                        ->children()
102
                            ->arrayNode('download')
103
                                ->addDefaultsIfNotSet()
104
                                ->children()
105
                                    ->scalarNode('strategy')->defaultValue('sonata.media.security.superadmin_strategy')->end()
106
                                    ->scalarNode('mode')->defaultValue('http')->end()
107
                                ->end()
108
                            ->end()
109
                            ->arrayNode('providers')
110
                                ->prototype('scalar')
111
                                    ->defaultValue([])
112
                                ->end()
113
                            ->end()
114
                            ->arrayNode('formats')
115
                                ->useAttributeAsKey('id')
116
                                ->prototype('array')
117
                                    ->children()
118
                                        ->scalarNode('width')->defaultValue(false)->end()
119
                                        ->scalarNode('height')->defaultValue(false)->end()
120
                                        ->scalarNode('quality')->defaultValue(80)->end()
121
                                        ->scalarNode('format')->defaultValue('jpg')->end()
122
                                        ->scalarNode('constraint')->defaultValue(true)->end()
123
                                        ->scalarNode('resizer')->defaultNull()->end()
124
                                    ->end()
125
                                ->end()
126
                            ->end()
127
                        ->end()
128
                    ->end()
129
                ->end()
130
            ->end()
131
        ;
132
    }
133
134
    /**
135
     * @param ArrayNodeDefinition $node
136
     */
137
    private function addCdnSection(ArrayNodeDefinition $node): void
138
    {
139
        $node
140
            ->children()
141
                ->arrayNode('cdn')
142
                    ->children()
143
                        ->arrayNode('server')
144
                            ->addDefaultsIfNotSet()
145
                            ->children()
146
                                ->scalarNode('path')->defaultValue('/uploads/media')->end()
147
                            ->end()
148
                        ->end()
149
150
                        ->arrayNode('panther')
151
                            ->children()
152
                                ->scalarNode('path')
153
                                    ->info('e.g. http://domain.pantherportal.com/uploads/media')
154
                                    ->isRequired()
155
                                ->end()
156
                                ->scalarNode('site_id')->isRequired()->end()
157
                                ->scalarNode('password')->isRequired()->end()
158
                                ->scalarNode('username')->isRequired()->end()
159
                            ->end()
160
                        ->end()
161
162
                        ->arrayNode('cloudfront')
163
                            ->children()
164
                                ->scalarNode('path')
165
                                    ->info('e.g. http://xxxxxxxxxxxxxx.cloudfront.net/uploads/media')
166
                                    ->isRequired()
167
                                ->end()
168
                                ->scalarNode('distribution_id')->isRequired()->end()
169
                                ->scalarNode('key')->isRequired()->end()
170
                                ->scalarNode('secret')->isRequired()->end()
171
                            ->end()
172
                        ->end()
173
174
                        ->arrayNode('fallback')
175
                            ->children()
176
                                ->scalarNode('master')->isRequired()->end()
177
                                ->scalarNode('fallback')->isRequired()->end()
178
                            ->end()
179
                        ->end()
180
                    ->end()
181
                ->end()
182
            ->end()
183
        ;
184
    }
185
186
    /**
187
     * @param ArrayNodeDefinition $node
188
     */
189
    private function addFilesystemSection(ArrayNodeDefinition $node): void
190
    {
191
        $node
192
            ->children()
193
                ->arrayNode('filesystem')
194
                    ->children()
195
                        ->arrayNode('local')
196
                            ->addDefaultsIfNotSet()
197
                            ->children()
198
                                ->scalarNode('directory')->defaultValue('%kernel.root_dir%/../web/uploads/media')->end()
199
                                ->scalarNode('create')->defaultValue(false)->end()
200
                            ->end()
201
                        ->end()
202
203
                        ->arrayNode('ftp')
204
                            ->children()
205
                                ->scalarNode('directory')->isRequired()->end()
206
                                ->scalarNode('host')->isRequired()->end()
207
                                ->scalarNode('username')->isRequired()->end()
208
                                ->scalarNode('password')->isRequired()->end()
209
                                ->scalarNode('port')->defaultValue(21)->end()
210
                                ->scalarNode('passive')->defaultValue(false)->end()
211
                                ->scalarNode('create')->defaultValue(false)->end()
212
                                ->scalarNode('mode')->defaultValue(\defined('FTP_BINARY') ? FTP_BINARY : false)->end()
213
                            ->end()
214
                        ->end()
215
216
                        ->arrayNode('s3')
217
                            ->children()
218
                                ->scalarNode('directory')->defaultValue('')->end()
219
                                ->scalarNode('bucket')->isRequired()->end()
220
                                ->scalarNode('accessKey')->isRequired()->end()
221
                                ->scalarNode('secretKey')->isRequired()->end()
222
                                ->scalarNode('create')->defaultValue(false)->end()
223
                                ->scalarNode('storage')
224
                                    ->defaultValue('standard')
225
                                    ->validate()
226
                                    ->ifNotInArray(['standard', 'reduced'])
227
                                        ->thenInvalid('Invalid storage type - "%s"')
228
                                    ->end()
229
                                ->end()
230
                                ->scalarNode('cache_control')->defaultValue('')->end()
231
                                ->scalarNode('acl')
232
                                    ->defaultValue('public')
233
                                    ->validate()
234
                                    ->ifNotInArray(['private', 'public', 'open', 'auth_read', 'owner_read', 'owner_full_control'])
235
                                        ->thenInvalid('Invalid acl permission - "%s"')
236
                                    ->end()
237
                                ->end()
238
                                ->scalarNode('encryption')
239
                                    ->defaultValue('')
240
                                    ->validate()
241
                                    ->ifNotInArray(['aes256'])
242
                                        ->thenInvalid('Invalid encryption type - "%s"')
243
                                    ->end()
244
                                ->end()
245
                                ->scalarNode('region')->defaultValue('s3.amazonaws.com')->end()
246
                                ->scalarNode('version')->defaultValue('latest')->end()
247
                                ->enumNode('sdk_version')
248
                                    ->values([2, 3])
249
                                    ->defaultValue(2)
250
                                ->end()
251
                                ->arrayNode('meta')
252
                                    ->useAttributeAsKey('name')
253
                                    ->prototype('scalar')
254
                                    ->end()
255
                                ->end()
256
                            ->end()
257
                        ->end()
258
259
                        ->arrayNode('mogilefs')
260
                            ->children()
261
                                ->scalarNode('domain')->isRequired()->end()
262
                                ->arrayNode('hosts')
263
                                    ->prototype('scalar')->end()
264
                                    ->isRequired()
265
                                ->end()
266
                            ->end()
267
                        ->end()
268
269
                        ->arrayNode('replicate')
270
                            ->children()
271
                                ->scalarNode('master')->isRequired()->end()
272
                                ->scalarNode('slave')->isRequired()->end()
273
                            ->end()
274
                        ->end()
275
                        ->arrayNode('openstack')
276
                            ->children()
277
                                ->scalarNode('url')->isRequired()->end()
278
                                ->arrayNode('secret')
279
                                    ->children()
280
                                        ->scalarNode('username')->isRequired()->end()
281
                                        ->scalarNode('password')->isRequired()->end()
282
                                    ->end()
283
                                ->end()
284
                                ->scalarNode('region')->end()
285
                                ->scalarNode('containerName')->defaultValue('media')->end()
286
                                ->scalarNode('create_container')->defaultValue(false)->end()
287
                            ->end()
288
                        ->end()
289
                        ->arrayNode('rackspace')
290
                            ->children()
291
                                ->scalarNode('url')->isRequired()->end()
292
                                    ->arrayNode('secret')
293
                                        ->children()
294
                                            ->scalarNode('username')->isRequired()->end()
295
                                            ->scalarNode('apiKey')->isRequired()->end()
296
                                        ->end()
297
                                    ->end()
298
                                    ->scalarNode('region')->isRequired()->end()
299
                                    ->scalarNode('containerName')->defaultValue('media')->end()
300
                                    ->scalarNode('create_container')->defaultValue(false)->end()
301
                                ->end()
302
                            ->end()
303
                        ->end()
304
                    ->end()
305
                ->end()
306
            ->end()
307
        ;
308
    }
309
310
    /**
311
     * @param ArrayNodeDefinition $node
312
     */
313
    private function addProvidersSection(ArrayNodeDefinition $node): void
314
    {
315
        $node
316
            ->children()
317
                ->arrayNode('providers')
318
                    ->addDefaultsIfNotSet()
319
                    ->children()
320
                        ->arrayNode('file')
321
                            ->addDefaultsIfNotSet()
322
                            ->children()
323
                                ->scalarNode('service')->defaultValue('sonata.media.provider.file')->end()
324
                                ->scalarNode('resizer')->defaultValue(false)->end()
325
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
326
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
327
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
328
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
329
                                ->arrayNode('allowed_extensions')
330
                                    ->prototype('scalar')->end()
331
                                    ->defaultValue([
332
                                        'pdf', 'txt', 'rtf',
333
                                        'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',
334
                                        'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb',
335
                                        'csv',
336
                                        'xml',
337
                                    ])
338
                                ->end()
339
                                ->arrayNode('allowed_mime_types')
340
                                    ->prototype('scalar')->end()
341
                                    ->defaultValue([
342
                                        'application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain',
343
                                        'application/excel', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint',
344
                                        'application/vnd.ms-powerpoint', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.chart', 'application/vnd.oasis.opendocument.formula', 'application/vnd.oasis.opendocument.database', 'application/vnd.oasis.opendocument.image',
345
                                        'text/comma-separated-values',
346
                                        'text/xml', 'application/xml',
347
                                        'application/zip', // seems to be used for xlsx document ...
348
                                    ])
349
                                ->end()
350
                            ->end()
351
                        ->end()
352
353
                        ->arrayNode('image')
354
                            ->addDefaultsIfNotSet()
355
                            ->children()
356
                                ->scalarNode('service')->defaultValue('sonata.media.provider.image')->end()
357
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
358
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
359
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
360
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
361
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
362
                                ->scalarNode('adapter')->defaultValue('sonata.media.adapter.image.default')->end()
363
                                ->arrayNode('allowed_extensions')
364
                                    ->prototype('scalar')->end()
365
                                    ->defaultValue(['jpg', 'png', 'jpeg'])
366
                                ->end()
367
                                ->arrayNode('allowed_mime_types')
368
                                    ->prototype('scalar')->end()
369
                                    ->defaultValue([
370
                                        'image/pjpeg',
371
                                        'image/jpeg',
372
                                        'image/png',
373
                                        'image/x-png',
374
                                    ])
375
                                ->end()
376
                            ->end()
377
                        ->end()
378
379
                        ->arrayNode('youtube')
380
                            ->addDefaultsIfNotSet()
381
                            ->children()
382
                                ->scalarNode('service')->defaultValue('sonata.media.provider.youtube')->end()
383
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
384
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
385
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
386
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
387
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
388
                                ->scalarNode('html5')->defaultValue(false)->end()
389
                            ->end()
390
                        ->end()
391
392
                        ->arrayNode('dailymotion')
393
                            ->addDefaultsIfNotSet()
394
                            ->children()
395
                                ->scalarNode('service')->defaultValue('sonata.media.provider.dailymotion')->end()
396
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
397
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
398
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
399
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
400
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
401
                            ->end()
402
                        ->end()
403
404
                        ->arrayNode('vimeo')
405
                            ->addDefaultsIfNotSet()
406
                            ->children()
407
                                ->scalarNode('service')->defaultValue('sonata.media.provider.vimeo')->end()
408
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
409
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
410
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
411
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
412
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
413
                            ->end()
414
                        ->end()
415
                    ->end()
416
                ->end()
417
            ->end()
418
        ;
419
    }
420
421
    /**
422
     * @param ArrayNodeDefinition $node
423
     */
424
    private function addExtraSection(ArrayNodeDefinition $node): void
425
    {
426
        $node
427
            ->children()
428
                ->arrayNode('pixlr')
429
                    ->info('More info at https://pixlr.com/')
430
                    ->addDefaultsIfNotSet()
431
                    ->children()
432
                        ->scalarNode('enabled')->defaultValue(false)->end()
433
                        ->scalarNode('secret')->defaultValue(sha1(uniqid((string) random_int(1, 9999), true)))->end()
434
                        ->scalarNode('referrer')->defaultValue('Sonata Media')->end()
435
                    ->end()
436
                ->end()
437
            ->end()
438
        ;
439
    }
440
441
    /**
442
     * @param ArrayNodeDefinition $node
443
     */
444
    private function addModelSection(ArrayNodeDefinition $node): void
445
    {
446
        $node
447
            ->children()
448
                ->arrayNode('class')
449
                    ->addDefaultsIfNotSet()
450
                    ->children()
451
                        ->scalarNode('media')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Media')->end()
452
                        ->scalarNode('gallery')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Gallery')->end()
453
                        ->scalarNode('gallery_item')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\GalleryItem')->end()
454
                        ->scalarNode('category')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Category')->end()
455
                        ->end()
456
                    ->end()
457
                ->end()
458
            ->end()
459
        ;
460
    }
461
462
    /**
463
     * @param ArrayNodeDefinition $node
464
     */
465
    private function addBuzzSection(ArrayNodeDefinition $node): void
466
    {
467
        $node
468
            ->children()
469
                ->arrayNode('buzz')
470
                    ->addDefaultsIfNotSet()
471
                    ->children()
472
                        ->scalarNode('connector')->defaultValue('sonata.media.buzz.connector.curl')->end()
473
                        ->arrayNode('client')
474
                        ->addDefaultsIfNotSet()
475
                        ->children()
476
                            ->booleanNode('ignore_errors')->defaultValue(true)->end()
477
                            ->scalarNode('max_redirects')->defaultValue(5)->end()
478
                            ->scalarNode('timeout')->defaultValue(5)->end()
479
                            ->booleanNode('verify_peer')->defaultValue(true)->end()
480
                            ->scalarNode('proxy')->defaultNull()->end()
481
                        ->end()
482
                    ->end()
483
                ->end()
484
            ->end()
485
        ;
486
    }
487
488
    /**
489
     * @param ArrayNodeDefinition $node
490
     */
491
    private function addResizerSection(ArrayNodeDefinition $node): void
492
    {
493
        $node
494
            ->children()
495
                ->arrayNode('resizer')
496
                    ->addDefaultsIfNotSet()
497
                    ->children()
498
                        ->arrayNode('simple')
499
                            ->addDefaultsIfNotSet()
500
                            ->children()
501
                                ->scalarNode('mode')->defaultValue('inset')->end()
502
                            ->end()
503
                        ->end()
504
                        ->arrayNode('square')
505
                            ->addDefaultsIfNotSet()
506
                            ->children()
507
                                ->scalarNode('mode')->defaultValue('inset')->end()
508
                            ->end()
509
                        ->end()
510
                    ->end()
511
                ->end()
512
                ->arrayNode('resizers')
513
                    ->addDefaultsIfNotSet()
514
                    ->children()
515
                        ->scalarNode('default')->defaultValue('sonata.media.resizer.simple')->end()
516
                    ->end()
517
                ->end()
518
            ->end()
519
        ;
520
    }
521
522
    /**
523
     * @param ArrayNodeDefinition $node
524
     */
525
    private function addAdapterSection(ArrayNodeDefinition $node): void
526
    {
527
        $node
528
            ->children()
529
                ->arrayNode('adapters')
530
                    ->addDefaultsIfNotSet()
531
                    ->children()
532
                        ->scalarNode('default')->defaultValue('sonata.media.adapter.image.gd')->end()
533
                    ->end()
534
                ->end()
535
            ->end()
536
        ;
537
    }
538
}
539