Issues (234)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/DependencyInjection/Configuration.php (9 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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