Completed
Push — master ( f28679...41e14f )
by Grégoire
11:52 queued 12s
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 9.0909
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
/**
26
 * @final since sonata-project/media-bundle 3.21.0
27
 */
28
class Configuration implements ConfigurationInterface
29
{
30
    /**
31
     * NEXT_MAJOR: make constant protected/private.
32
     */
33
    public const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr', 'no_driver'];
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getConfigTreeBuilder()
39
    {
40
        $treeBuilder = new TreeBuilder('sonata_media');
41
42
        $node = $treeBuilder->getRootNode();
43
44
        $node
45
            ->children()
46
                ->scalarNode('db_driver')
47
                    ->defaultValue('no_driver')
48
                    ->info('Choose persistence mechanism driver from the following list: "doctrine_orm", "doctrine_mongodb", "doctrine_phpcr"')
49
                    ->validate()
50
                        ->ifNotInArray(self::DB_DRIVERS)
51
                        ->thenInvalid('SonataMediaBundle - Invalid db driver %s.')
52
                    ->end()
53
                ->end()
54
                ->scalarNode('default_context')->isRequired()->end()
55
                ->scalarNode('category_manager')
56
                    ->defaultValue('sonata.media.manager.category.default')
57
                ->end()
58
                ->booleanNode('force_disable_category')
59
                    ->info('true IF you really want to disable the relation with category')
60
                    ->defaultFalse()
61
                ->end()
62
                ->arrayNode('admin_format')
63
                    ->info('Configures the thumbnail preview for the admin')
64
                    ->addDefaultsIfNotSet()
65
                    ->children()
66
                        ->scalarNode('width')->defaultValue(200)->end()
67
                        ->scalarNode('height')->defaultValue(null)->end()
68
                        ->scalarNode('quality')->defaultValue(90)->end()
69
                        ->scalarNode('format')->defaultValue('jpg')->end()
70
                        ->scalarNode('constraint')->defaultValue(true)->end()
71
                    ->end()
72
                ->end()
73
            ->end()
74
        ;
75
76
        $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...
77
        $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...
78
        $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...
79
        $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...
80
        $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...
81
        $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...
82
        $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...
83
        $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...
84
        $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...
85
86
        return $treeBuilder;
87
    }
88
89
    private function addContextsSection(ArrayNodeDefinition $node): void
90
    {
91
        $node
92
            ->children()
93
                ->arrayNode('contexts')
94
                    ->useAttributeAsKey('id')
95
                    ->prototype('array')
96
                        ->children()
97
                            ->arrayNode('download')
98
                                ->addDefaultsIfNotSet()
99
                                ->children()
100
                                    ->scalarNode('strategy')->defaultValue('sonata.media.security.superadmin_strategy')->end()
101
                                    ->scalarNode('mode')->defaultValue('http')->end()
102
                                ->end()
103
                            ->end()
104
                            ->arrayNode('providers')
105
                                ->prototype('scalar')
106
                                    ->defaultValue([])
107
                                ->end()
108
                            ->end()
109
                            ->arrayNode('formats')
110
                                ->useAttributeAsKey('id')
111
                                ->prototype('array')
112
                                    ->children()
113
                                        ->scalarNode('width')->defaultValue(null)->end()
114
                                        ->scalarNode('height')->defaultValue(null)->end()
115
                                        ->scalarNode('quality')->defaultValue(80)->end()
116
                                        ->scalarNode('format')->defaultValue('jpg')->end()
117
                                        ->scalarNode('constraint')->defaultValue(true)->end()
118
                                        ->scalarNode('resizer')->defaultNull()->end()
119
                                        ->arrayNode('resizer_options')
120
                                            ->info('options directly passed to selected resizer. e.g. {use_crop: true, crop_gravity: center}')
121
                                            ->defaultValue([])
122
                                            ->useAttributeAsKey('name')
123
                                            ->prototype('scalar')
124
                                        ->end()
125
                                    ->end()
126
                                ->end()
127
                            ->end()
128
                        ->end()
129
                    ->end()
130
                ->end()
131
            ->end()
132
        ;
133
    }
134
135
    private function addCdnSection(ArrayNodeDefinition $node): void
136
    {
137
        $node
138
            ->children()
139
                ->arrayNode('cdn')
140
                    ->children()
141
                        ->arrayNode('server')
142
                            ->addDefaultsIfNotSet()
143
                            ->children()
144
                                ->scalarNode('path')->defaultValue('/uploads/media')->end()
145
                            ->end()
146
                        ->end()
147
148
                        ->arrayNode('panther')
149
                            ->children()
150
                                ->scalarNode('path')
151
                                    ->info('e.g. http://domain.pantherportal.com/uploads/media')
152
                                    ->isRequired()
153
                                ->end()
154
                                ->scalarNode('site_id')->isRequired()->end()
155
                                ->scalarNode('password')->isRequired()->end()
156
                                ->scalarNode('username')->isRequired()->end()
157
                            ->end()
158
                        ->end()
159
160
                        ->arrayNode('cloudfront')
161
                            ->children()
162
                                ->scalarNode('path')
163
                                    ->info('e.g. http://xxxxxxxxxxxxxx.cloudfront.net/uploads/media')
164
                                    ->isRequired()
165
                                ->end()
166
                                ->scalarNode('distribution_id')->isRequired()->end()
167
                                ->scalarNode('key')->isRequired()->end()
168
                                ->scalarNode('secret')->isRequired()->end()
169
                            ->end()
170
                        ->end()
171
172
                        ->arrayNode('fallback')
173
                            ->children()
174
                                ->scalarNode('master')->isRequired()->end()
175
                                ->scalarNode('fallback')->isRequired()->end()
176
                            ->end()
177
                        ->end()
178
                    ->end()
179
                ->end()
180
            ->end()
181
        ;
182
    }
183
184
    private function addFilesystemSection(ArrayNodeDefinition $node): void
185
    {
186
        $node
187
            ->children()
188
                ->arrayNode('filesystem')
189
                    ->children()
190
                        ->arrayNode('local')
191
                            ->addDefaultsIfNotSet()
192
                            ->children()
193
                                ->scalarNode('directory')->defaultValue('%kernel.root_dir%/../web/uploads/media')->end()
194
                                ->scalarNode('create')->defaultValue(false)->end()
195
                            ->end()
196
                        ->end()
197
198
                        ->arrayNode('ftp')
199
                            ->children()
200
                                ->scalarNode('directory')->isRequired()->end()
201
                                ->scalarNode('host')->isRequired()->end()
202
                                ->scalarNode('username')->isRequired()->end()
203
                                ->scalarNode('password')->isRequired()->end()
204
                                ->scalarNode('port')->defaultValue(21)->end()
205
                                ->scalarNode('passive')->defaultValue(false)->end()
206
                                ->scalarNode('create')->defaultValue(false)->end()
207
                                ->scalarNode('mode')->defaultValue(\defined('FTP_BINARY') ? FTP_BINARY : false)->end()
208
                            ->end()
209
                        ->end()
210
211
                        ->arrayNode('s3')
212
                            ->children()
213
                                ->scalarNode('directory')->defaultValue('')->end()
214
                                ->scalarNode('bucket')->isRequired()->end()
215
                                ->scalarNode('accessKey')->isRequired()->end()
216
                                ->scalarNode('secretKey')->isRequired()->end()
217
                                ->scalarNode('create')->defaultValue(false)->end()
218
                                ->scalarNode('storage')
219
                                    ->defaultValue('standard')
220
                                    ->validate()
221
                                    ->ifNotInArray(['standard', 'reduced'])
222
                                        ->thenInvalid('Invalid storage type - "%s"')
223
                                    ->end()
224
                                ->end()
225
                                ->scalarNode('cache_control')->defaultValue('')->end()
226
                                ->scalarNode('acl')
227
                                    ->defaultValue('public')
228
                                    ->validate()
229
                                    ->ifNotInArray(['private', 'public', 'open', 'auth_read', 'owner_read', 'owner_full_control'])
230
                                        ->thenInvalid('Invalid acl permission - "%s"')
231
                                    ->end()
232
                                ->end()
233
                                ->scalarNode('encryption')
234
                                    ->defaultValue('')
235
                                    ->validate()
236
                                    ->ifNotInArray(['aes256'])
237
                                        ->thenInvalid('Invalid encryption type - "%s"')
238
                                    ->end()
239
                                ->end()
240
                                ->scalarNode('region')->defaultValue('s3.amazonaws.com')->end()
241
                                ->scalarNode('version')->defaultValue('latest')->end()
242
                                ->enumNode('sdk_version')
243
                                    ->values([2, 3])
244
                                    ->defaultValue(2)
245
                                ->end()
246
                                ->arrayNode('meta')
247
                                    ->useAttributeAsKey('name')
248
                                    ->prototype('scalar')
249
                                    ->end()
250
                                ->end()
251
                            ->end()
252
                        ->end()
253
254
                        ->arrayNode('mogilefs')
255
                            ->children()
256
                                ->scalarNode('domain')->isRequired()->end()
257
                                ->arrayNode('hosts')
258
                                    ->prototype('scalar')->end()
259
                                    ->isRequired()
260
                                ->end()
261
                            ->end()
262
                        ->end()
263
264
                        ->arrayNode('replicate')
265
                            ->children()
266
                                ->scalarNode('master')->isRequired()->end()
267
                                ->scalarNode('slave')->isRequired()->end()
268
                            ->end()
269
                        ->end()
270
                        ->arrayNode('openstack')
271
                            ->children()
272
                                ->scalarNode('url')->isRequired()->end()
273
                                ->arrayNode('secret')
274
                                    ->children()
275
                                        ->scalarNode('username')->isRequired()->end()
276
                                        ->scalarNode('password')->isRequired()->end()
277
                                    ->end()
278
                                ->end()
279
                                ->scalarNode('region')->end()
280
                                ->scalarNode('containerName')->defaultValue('media')->end()
281
                                ->scalarNode('create_container')->defaultValue(false)->end()
282
                            ->end()
283
                        ->end()
284
                        ->arrayNode('rackspace')
285
                            ->children()
286
                                ->scalarNode('url')->isRequired()->end()
287
                                    ->arrayNode('secret')
288
                                        ->children()
289
                                            ->scalarNode('username')->isRequired()->end()
290
                                            ->scalarNode('apiKey')->isRequired()->end()
291
                                        ->end()
292
                                    ->end()
293
                                    ->scalarNode('region')->isRequired()->end()
294
                                    ->scalarNode('containerName')->defaultValue('media')->end()
295
                                    ->scalarNode('create_container')->defaultValue(false)->end()
296
                                ->end()
297
                            ->end()
298
                        ->end()
299
                    ->end()
300
                ->end()
301
            ->end()
302
        ;
303
    }
304
305
    private function addProvidersSection(ArrayNodeDefinition $node): void
306
    {
307
        $node
308
            ->children()
309
                ->arrayNode('providers')
310
                    ->addDefaultsIfNotSet()
311
                    ->children()
312
                        ->arrayNode('file')
313
                            ->addDefaultsIfNotSet()
314
                            ->children()
315
                                ->scalarNode('service')->defaultValue('sonata.media.provider.file')->end()
316
                                ->scalarNode('resizer')->defaultValue(false)->end()
317
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
318
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
319
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
320
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
321
                                ->arrayNode('allowed_extensions')
322
                                    ->prototype('scalar')->end()
323
                                    ->defaultValue([
324
                                        'pdf', 'txt', 'rtf',
325
                                        'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',
326
                                        'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb',
327
                                        'csv',
328
                                        'xml',
329
                                    ])
330
                                ->end()
331
                                ->arrayNode('allowed_mime_types')
332
                                    ->prototype('scalar')->end()
333
                                    ->defaultValue([
334
                                        'application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain',
335
                                        'application/excel', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint',
336
                                        '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',
337
                                        'text/comma-separated-values',
338
                                        'text/xml', 'application/xml',
339
                                        'application/zip', // seems to be used for xlsx document ...
340
                                    ])
341
                                ->end()
342
                            ->end()
343
                        ->end()
344
345
                        ->arrayNode('image')
346
                            ->addDefaultsIfNotSet()
347
                            ->children()
348
                                ->scalarNode('service')->defaultValue('sonata.media.provider.image')->end()
349
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
350
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
351
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
352
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
353
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
354
                                ->scalarNode('adapter')->defaultValue('sonata.media.adapter.image.default')->end()
355
                                ->arrayNode('allowed_extensions')
356
                                    ->prototype('scalar')->end()
357
                                    ->defaultValue(['jpg', 'png', 'jpeg'])
358
                                ->end()
359
                                ->arrayNode('allowed_mime_types')
360
                                    ->prototype('scalar')->end()
361
                                    ->defaultValue([
362
                                        'image/pjpeg',
363
                                        'image/jpeg',
364
                                        'image/png',
365
                                        'image/x-png',
366
                                    ])
367
                                ->end()
368
                            ->end()
369
                        ->end()
370
371
                        ->arrayNode('youtube')
372
                            ->addDefaultsIfNotSet()
373
                            ->children()
374
                                ->scalarNode('service')->defaultValue('sonata.media.provider.youtube')->end()
375
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
376
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
377
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
378
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
379
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
380
                                ->scalarNode('html5')->defaultValue(false)->end()
381
                            ->end()
382
                        ->end()
383
384
                        ->arrayNode('dailymotion')
385
                            ->addDefaultsIfNotSet()
386
                            ->children()
387
                                ->scalarNode('service')->defaultValue('sonata.media.provider.dailymotion')->end()
388
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
389
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
390
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
391
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
392
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
393
                            ->end()
394
                        ->end()
395
396
                        ->arrayNode('vimeo')
397
                            ->addDefaultsIfNotSet()
398
                            ->children()
399
                                ->scalarNode('service')->defaultValue('sonata.media.provider.vimeo')->end()
400
                                ->scalarNode('resizer')->defaultValue('sonata.media.resizer.default')->end()
401
                                ->scalarNode('filesystem')->defaultValue('sonata.media.filesystem.local')->end()
402
                                ->scalarNode('cdn')->defaultValue('sonata.media.cdn.server')->end()
403
                                ->scalarNode('generator')->defaultValue('sonata.media.generator.default')->end()
404
                                ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end()
405
                            ->end()
406
                        ->end()
407
                    ->end()
408
                ->end()
409
            ->end()
410
        ;
411
    }
412
413
    private function addExtraSection(ArrayNodeDefinition $node): void
414
    {
415
        $node
416
            ->children()
417
                ->arrayNode('pixlr')
418
                    ->info('More info at https://pixlr.com/')
419
                    ->addDefaultsIfNotSet()
420
                    ->children()
421
                        ->scalarNode('enabled')->defaultValue(false)->end()
422
                        ->scalarNode('secret')->defaultValue(sha1(uniqid((string) random_int(1, 9999), true)))->end()
423
                        ->scalarNode('referrer')->defaultValue('Sonata Media')->end()
424
                    ->end()
425
                ->end()
426
            ->end()
427
        ;
428
    }
429
430
    private function addModelSection(ArrayNodeDefinition $node): void
431
    {
432
        $node
433
            ->children()
434
                ->arrayNode('class')
435
                    ->addDefaultsIfNotSet()
436
                    ->children()
437
                        ->scalarNode('media')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Media')->end()
438
                        ->scalarNode('gallery')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Gallery')->end()
439
                        ->scalarNode('gallery_item')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\GalleryItem')->end()
440
                        ->scalarNode('category')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Category')->end()
441
                        ->end()
442
                    ->end()
443
                ->end()
444
            ->end()
445
        ;
446
    }
447
448
    private function addBuzzSection(ArrayNodeDefinition $node): void
449
    {
450
        $node
451
            ->children()
452
                ->arrayNode('buzz')
453
                    ->addDefaultsIfNotSet()
454
                    ->children()
455
                        ->scalarNode('connector')->defaultValue('sonata.media.buzz.connector.curl')->end()
456
                        ->arrayNode('client')
457
                        ->addDefaultsIfNotSet()
458
                        ->children()
459
                            ->booleanNode('ignore_errors')->defaultValue(true)->end()
460
                            ->scalarNode('max_redirects')->defaultValue(5)->end()
461
                            ->scalarNode('timeout')->defaultValue(5)->end()
462
                            ->booleanNode('verify_peer')->defaultValue(true)->end()
463
                            ->scalarNode('proxy')->defaultNull()->end()
464
                        ->end()
465
                    ->end()
466
                ->end()
467
            ->end()
468
        ;
469
    }
470
471
    private function addResizerSection(ArrayNodeDefinition $node): void
472
    {
473
        $node
474
            ->children()
475
                ->arrayNode('resizer')
476
                    ->addDefaultsIfNotSet()
477
                    ->children()
478
                        ->arrayNode('simple')
479
                            ->addDefaultsIfNotSet()
480
                            ->children()
481
                                ->scalarNode('mode')->defaultValue('inset')->end()
482
                            ->end()
483
                        ->end()
484
                        ->arrayNode('square')
485
                            ->addDefaultsIfNotSet()
486
                            ->children()
487
                                ->scalarNode('mode')->defaultValue('inset')->end()
488
                            ->end()
489
                        ->end()
490
                    ->end()
491
                ->end()
492
                ->arrayNode('resizers')
493
                    ->addDefaultsIfNotSet()
494
                    ->children()
495
                        ->scalarNode('default')->defaultValue('sonata.media.resizer.simple')->end()
496
                    ->end()
497
                ->end()
498
            ->end()
499
        ;
500
    }
501
502
    private function addAdapterSection(ArrayNodeDefinition $node): void
503
    {
504
        $node
505
            ->children()
506
                ->arrayNode('adapters')
507
                    ->addDefaultsIfNotSet()
508
                    ->children()
509
                        ->scalarNode('default')->defaultValue('sonata.media.adapter.image.gd')->end()
510
                    ->end()
511
                ->end()
512
            ->end()
513
        ;
514
    }
515
}
516