Completed
Push — master ( 4892d1...36f372 )
by
unknown
22:19
created

Configuration::addHttpCacheSection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 49

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 49
rs 9.1127
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Configuration class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection;
10
11
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface;
12
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration;
13
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollectorInterface;
14
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
17
18
class Configuration extends SiteAccessConfiguration
19
{
20
    const CUSTOM_TAG_ATTRIBUTE_TYPES = ['number', 'string', 'boolean', 'choice'];
21
22
    /**
23
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
24
     */
25
    private $mainConfigParser;
26
27
    /**
28
     * @var Configuration\Suggestion\Collector\SuggestionCollectorInterface
29
     */
30
    private $suggestionCollector;
31
32
    /**
33
     * @var \eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter[]
34
     */
35
    private $siteAccessConfigurationFilters;
36
37
    public function __construct(ParserInterface $mainConfigParser, SuggestionCollectorInterface $suggestionCollector)
38
    {
39
        $this->suggestionCollector = $suggestionCollector;
40
        $this->mainConfigParser = $mainConfigParser;
41
    }
42
43
    public function setSiteAccessConfigurationFilters(array $filters)
44
    {
45
        $this->siteAccessConfigurationFilters = $filters;
46
    }
47
48
    /**
49
     * Generates the configuration tree builder.
50
     *
51
     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
52
     */
53
    public function getConfigTreeBuilder()
54
    {
55
        $treeBuilder = new TreeBuilder();
56
        $rootNode = $treeBuilder->root('ezpublish');
57
58
        $this->addRepositoriesSection($rootNode);
59
        $this->addSiteaccessSection($rootNode);
60
        $this->addImageMagickSection($rootNode);
61
        $this->addHttpCacheSection($rootNode);
62
        $this->addPageSection($rootNode);
63
        $this->addRouterSection($rootNode);
64
        $this->addRichTextSection($rootNode);
65
        $this->addUrlAliasSection($rootNode);
66
        $this->addImagePlaceholderSection($rootNode);
67
68
        // Delegate SiteAccess config to configuration parsers
69
        $this->mainConfigParser->addSemanticConfig($this->generateScopeBaseNode($rootNode));
70
71
        return $treeBuilder;
72
    }
73
74
    public function addRepositoriesSection(ArrayNodeDefinition $rootNode)
75
    {
76
        $rootNode
77
            ->children()
78
                ->arrayNode('repositories')
79
                    ->info('Content repositories configuration')
80
                    ->example(
81
                        array(
82
                            'main' => array(
83
                                'storage' => array(
84
                                    'engine' => 'legacy',
85
                                    'connection' => 'my_doctrine_connection_name',
86
                                ),
87
                            ),
88
                        )
89
                    )
90
                    ->useAttributeAsKey('alias')
91
                    ->prototype('array')
92
                        ->beforeNormalization()
93
                            ->always(
94
                                // Handling deprecated structure by mapping it to new one
95
                                function ($v) {
96
                                    if (isset($v['storage'])) {
97
                                        return $v;
98
                                    }
99
100
                                    if (isset($v['engine'])) {
101
                                        $v['storage']['engine'] = $v['engine'];
102
                                        unset($v['engine']);
103
                                    }
104
105
                                    if (isset($v['connection'])) {
106
                                        $v['storage']['connection'] = $v['connection'];
107
                                        unset($v['connection']);
108
                                    }
109
110
                                    if (isset($v['config'])) {
111
                                        $v['storage']['config'] = $v['config'];
112
                                        unset($v['config']);
113
                                    }
114
115
                                    return $v;
116
                                }
117
                            )
118
                        ->end()
119
                        ->beforeNormalization()
120
                            ->always(
121
                                // Setting default values
122
                                function ($v) {
123
                                    if ($v === null) {
124
                                        $v = array();
125
                                    }
126
127
                                    if (!isset($v['storage'])) {
128
                                        $v['storage'] = array();
129
                                    }
130
131
                                    if (!isset($v['search'])) {
132
                                        $v['search'] = array();
133
                                    }
134
135
                                    if (!isset($v['fields_groups']['list'])) {
136
                                        $v['fields_groups']['list'] = [];
137
                                    }
138
139
                                    if (!isset($v['options'])) {
140
                                        $v['options'] = [];
141
                                    }
142
143
                                    return $v;
144
                                }
145
                            )
146
                        ->end()
147
                        ->children()
148
                            ->arrayNode('storage')
149
                                ->children()
150
                                    ->scalarNode('engine')
151
                                        ->defaultValue('%ezpublish.api.storage_engine.default%')
152
                                        ->info('The storage engine to use')
153
                                    ->end()
154
                                    ->scalarNode('connection')
155
                                        ->defaultNull()
156
                                        ->info('The connection name, if applicable (e.g. Doctrine connection name). If not set, the default connection will be used.')
157
                                    ->end()
158
                                    ->arrayNode('config')
159
                                        ->info('Arbitrary configuration options, supported by your storage engine')
160
                                        ->useAttributeAsKey('key')
161
                                        ->prototype('variable')->end()
162
                                    ->end()
163
                                ->end()
164
                            ->end()
165
                            ->arrayNode('search')
166
                                ->children()
167
                                    ->scalarNode('engine')
168
                                        ->defaultValue('%ezpublish.api.search_engine.default%')
169
                                        ->info('The search engine to use')
170
                                    ->end()
171
                                    ->scalarNode('connection')
172
                                        ->defaultNull()
173
                                        ->info('The connection name, if applicable (e.g. Doctrine connection name). If not set, the default connection will be used.')
174
                                    ->end()
175
                                    ->arrayNode('config')
176
                                        ->info('Arbitrary configuration options, supported by your search engine')
177
                                        ->useAttributeAsKey('key')
178
                                        ->prototype('variable')->end()
179
                                    ->end()
180
                                ->end()
181
                            ->end()
182
                            ->arrayNode('fields_groups')
183
                                ->info('Definitions of fields groups.')
184
                                ->children()
185
                                    ->arrayNode('list')->prototype('scalar')->end()->end()
186
                                    ->scalarNode('default')->defaultValue('%ezsettings.default.content.field_groups.default%')->end()
187
                                ->end()
188
                            ->end()
189
                            ->arrayNode('options')
190
                                ->info('Options for repository.')
191
                                ->children()
192
                                    ->scalarNode('default_version_archive_limit')
193
                                        ->defaultValue(5)
194
                                        ->info('Default version archive limit (0-50), only enforced on publish, not on un-publish.')
195
                                    ->end()
196
                                ->end()
197
                            ->end()
198
                        ->end()
199
                    ->end()
200
                ->end()
201
            ->end();
202
    }
203
204
    public function addSiteaccessSection(ArrayNodeDefinition $rootNode)
205
    {
206
        $rootNode
207
            ->children()
208
                ->arrayNode('siteaccess')
209
                    ->info('SiteAccess configuration')
210
                    ->children()
211
                        ->arrayNode('list')
212
                            ->info('Available SiteAccess list')
213
                            ->example(array('ezdemo_site', 'ezdemo_site_admin'))
214
                            ->isRequired()
215
                            ->requiresAtLeastOneElement()
216
                            ->prototype('scalar')->end()
217
                        ->end()
218
                        ->arrayNode('groups')
219
                            ->useAttributeAsKey('key')
220
                            ->info('SiteAccess groups. Useful to share settings between Siteaccess')
221
                            ->example(array('ezdemo_group' => array('ezdemo_site', 'ezdemo_site_admin')))
222
                            ->prototype('array')
223
                                ->requiresAtLeastOneElement()
224
                                ->prototype('scalar')->end()
225
                            ->end()
226
                        ->end()
227
                        ->scalarNode('default_siteaccess')->isRequired()->info('Name of the default siteaccess')->end()
228
                        ->arrayNode('match')
229
                            ->info('Siteaccess match configuration. First key is the matcher class, value is passed to the matcher. Key can be a service identifier (prepended by "@"), or a FQ class name (prepended by "\\")')
230
                            ->example(
231
                                array(
232
                                    'Map\\URI' => array(
233
                                        'foo' => 'ezdemo_site',
234
                                        'ezdemo_site' => 'ezdemo_site',
235
                                        'ezdemo_site_admin' => 'ezdemo_site_admin',
236
                                    ),
237
                                    'Map\\Host' => array(
238
                                        'ezpublish.dev' => 'ezdemo_site',
239
                                        'admin.ezpublish.dev' => 'ezdemo_site_admin',
240
                                    ),
241
                                    '\\My\\Custom\\Matcher' => array(
242
                                        'some' => 'configuration',
243
                                    ),
244
                                    '@my.custom.matcher' => array(
245
                                        'some' => 'other_configuration',
246
                                    ),
247
                                )
248
                            )
249
                            ->isRequired()
250
                            ->useAttributeAsKey('key')
251
                            ->normalizeKeys(false)
252
                            ->prototype('array')
253
                                ->useAttributeAsKey('key')
254
                                ->beforeNormalization()
255
                                    ->always(
256
                                        function ($v) {
257
                                            // Value passed to the matcher should always be an array.
258
                                            // If value is not an array, we transform it to a hash, with 'value' as key.
259
                                            if (!is_array($v)) {
260
                                                return array('value' => $v);
261
                                            }
262
263
                                            // If passed value is a numerically indexed array, we must convert it into a hash.
264
                                            // See https://jira.ez.no/browse/EZP-21876
265
                                            if (array_keys($v) === range(0, count($v) - 1)) {
266
                                                $final = array();
267
                                                foreach ($v as $i => $val) {
268
                                                    $final["i$i"] = $val;
269
                                                }
270
271
                                                return $final;
272
                                            }
273
274
                                            return $v;
275
                                        }
276
                                    )
277
                                ->end()
278
                                ->normalizeKeys(false)
279
                                ->prototype('variable')->end()
280
                            ->end()
281
                        ->end()
282
                    ->end()
283
                    ->beforeNormalization()
284
                        ->always()->then(function ($v) {
285
                            if (isset($this->siteAccessConfigurationFilters)) {
286
                                foreach ($this->siteAccessConfigurationFilters as $filter) {
287
                                    $v = $filter->filter($v);
288
                                }
289
                            }
290
291
                            return $v;
292
                        })
293
                    ->end()
294
                ->end()
295
                ->arrayNode('locale_conversion')
296
                    ->info('Locale conversion map between eZ Publish format (i.e. fre-FR) to POSIX (i.e. fr_FR). The key is the eZ Publish locale. Check locale.yml in EzPublishCoreBundle to see natively supported locales.')
297
                    ->example(array('fre-FR' => 'fr_FR'))
298
                    ->useAttributeAsKey('key')
299
                    ->normalizeKeys(false)
300
                    ->prototype('scalar')->end()
301
                ->end()
302
            ->end();
303
    }
304
305
    private function addImageMagickSection(ArrayNodeDefinition $rootNode)
306
    {
307
        $filtersInfo =
308
<<<EOT
309
DEPRECATED.
310
This is only used for legacy injection.
311
You may use imagick/gmagick liip_imagine bundle drivers.
312
313
Hash of filters to be used for your image variations config.
314
#   Key is the filter name, value is an argument passed to "convert" binary.
315
#   You can use numbered placeholders (aka input variables) that will be replaced by defined parameters in your image variations config
316
EOT;
317
318
        $rootNode
319
            ->children()
320
                ->arrayNode('imagemagick')
321
                    ->info('ImageMagick configuration')
322
                    ->children()
323
                        ->booleanNode('enabled')->defaultTrue()->end()
324
                        ->scalarNode('path')
325
                            ->info('Absolute path of ImageMagick / GraphicsMagick "convert" binary.')
326
                            ->beforeNormalization()
327
                                ->ifTrue(
328
                                    function ($v) {
329
                                        $basename = basename($v);
330
                                        // If there is a space in the basename, just drop it and everything after it.
331
                                        if (($wsPos = strpos($basename, ' ')) !== false) {
332
                                            $basename = substr($basename, 0, $wsPos);
333
                                        }
334
335
                                        return !is_executable(dirname($v) . DIRECTORY_SEPARATOR . $basename);
336
                                    }
337
                                )
338
                                ->thenInvalid('Please provide full path to ImageMagick / GraphicsMagick  "convert" binary. Please also check that it is executable.')
339
                            ->end()
340
                        ->end()
341
                        ->arrayNode('filters')
342
                            ->info($filtersInfo)
343
                            ->example(array('geometry/scaledownonly' => '"-geometry {1}x{2}>"'))
344
                            ->prototype('scalar')->end()
345
                        ->end()
346
                    ->end()
347
                ->end()
348
            ->end();
349
    }
350
351
    private function addHttpCacheSection(ArrayNodeDefinition $rootNode)
352
    {
353
        $purgeTypeInfo = <<<EOT
354
Http cache purge type.
355
356
Cache purge for content/locations is triggered when needed (e.g. on publish) and will result in one or several Http PURGE requests.
357
Can be "local", "http" or a valid symfony service id:
358
- If "local" is used, an Http PURGE request will be emulated when needed (e.g. when using Symfony internal reverse proxy).
359
- If "http" is used, a full HTTP PURGE/BAN is done to a real reverse proxy (Varnish, ..) depending on your config
360
- If custom symfony service id is used, then check documentation on that service for how it behaves and how you need to configure your system for it.
361
362
If ezplatform-http-cache package is enabled (default as of 1.12 and up), then go to documentation on this package for further
363
info on how it supports multiple response tagging, purges and allow plugins for custom purge types.
364
365
If that is not enabled, then the (deprecated as of 1.8) default BAN based system will be used instead.
366
Where ressponses can be tagged by a single  X-Location-Id header, and for purges a single Http BAN request will be sent,
367
where X-Location-Id header consists of a Regexp containing locationIds to ban.
368
  BAN Examples:
369
   - (123|456|789) => Purge locations #123, #456, #789.
370
   - .* => Purge all locations.
371
EOT;
372
373
        $rootNode
374
            ->children()
375
                ->arrayNode('http_cache')
376
                    ->children()
377
                        ->scalarNode('purge_type')
378
                            ->info($purgeTypeInfo)
379
                            ->defaultValue('local')
380
                            ->beforeNormalization()
381
                                ->ifTrue(
382
                                    function ($v) {
383
                                        $http = array('multiple_http' => true, 'single_http' => true);
384
385
                                        return isset($http[$v]);
386
                                    }
387
                                )
388
                                ->then(
389
                                    function () {
390
                                        return 'http';
391
                                    }
392
                                )
393
                            ->end()
394
                        ->end()
395
                        ->scalarNode('timeout')->info('DEPRECATED')->end()
396
                    ->end()
397
                ->end()
398
            ->end();
399
    }
400
401
    private function addPageSection(ArrayNodeDefinition $rootNode)
402
    {
403
        $pageInfo = <<<EOT
404
List of globally registered layouts and blocks used by the Page fieldtype
405
EOT;
406
407
        $rootNode
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Config...\Builder\NodeDefinition as the method children() does only exist in the following sub-classes of Symfony\Component\Config...\Builder\NodeDefinition: Symfony\Component\Config...der\ArrayNodeDefinition. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
408
            ->children()
409
                ->arrayNode('ezpage')
410
                    ->info($pageInfo)
411
                    ->children()
412
                        ->arrayNode('layouts')
413
                            ->info('List of registered layouts, the key is the identifier of the layout')
414
                            ->useAttributeAsKey('key')
415
                            ->normalizeKeys(false)
416
                            ->prototype('array')
417
                                ->children()
418
                                    ->scalarNode('name')->isRequired()->info('Name of the layout')->end()
419
                                    ->scalarNode('template')->isRequired()->info('Template to use to render this layout')->end()
420
                                ->end()
421
                            ->end()
422
                        ->end()
423
                        ->arrayNode('blocks')
424
                            ->info('List of registered blocks, the key is the identifier of the block')
425
                            ->useAttributeAsKey('key')
426
                            ->normalizeKeys(false)
427
                            ->prototype('array')
428
                                ->children()
429
                                    ->scalarNode('name')->isRequired()->info('Name of the block')->end()
430
                                ->end()
431
                            ->end()
432
                        ->end()
433
                        ->arrayNode('enabledBlocks')
434
                            ->prototype('scalar')
435
                            ->end()
436
                            ->info('List of enabled blocks by default')
437
                        ->end()
438
                        ->arrayNode('enabledLayouts')
439
                            ->prototype('scalar')
440
                            ->end()
441
                            ->info('List of enabled layouts by default')
442
                        ->end()
443
                    ->end()
444
                ->end()
445
            ->end();
446
    }
447
448
    private function addRouterSection(ArrayNodeDefinition $rootNode)
449
    {
450
        $nonSAAwareInfo = <<<EOT
451
Route names that are not supposed to be SiteAccess aware, i.e. Routes pointing to asset generation (like assetic).
452
Note that you can just specify a prefix to match a selection of routes.
453
e.g. "_assetic_" will match "_assetic_*"
454
Defaults to ['_assetic_', '_wdt', '_profiler', '_configurator_']
455
EOT;
456
        $rootNode
457
            ->children()
458
                ->arrayNode('router')
459
                    ->children()
460
                        ->arrayNode('default_router')
461
                            ->children()
462
                                ->arrayNode('non_siteaccess_aware_routes')
463
                                    ->prototype('scalar')->end()
464
                                    ->info($nonSAAwareInfo)
465
                                    ->example(array('my_route_name', 'some_prefix_'))
466
                                ->end()
467
                            ->end()
468
                        ->end()
469
                    ->end()
470
                    ->info('Router related settings')
471
                ->end()
472
            ->end();
473
    }
474
475
    /**
476
     * Define global Semantic Configuration for RichText.
477
     *
478
     * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode
479
     */
480
    private function addRichTextSection(ArrayNodeDefinition $rootNode)
481
    {
482
        $ezRichTextNode = $rootNode->children()->arrayNode('ezrichtext')->children();
483
        $this->addCustomTagsSection($ezRichTextNode);
484
        $this->addCustomStylesSection($ezRichTextNode);
485
        $ezRichTextNode->end()->end()->end();
486
    }
487
488
    /**
489
     * Define RichText Custom Tags Semantic Configuration.
490
     *
491
     * The configuration is available at:
492
     * <code>
493
     * ezpublish:
494
     *     ezrichtext:
495
     *         custom_tags:
496
     * </code>
497
     *
498
     * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $ezRichTextNode
499
     *
500
     * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
501
     */
502
    private function addCustomTagsSection(NodeBuilder $ezRichTextNode)
503
    {
504
        return $ezRichTextNode
505
                ->arrayNode('custom_tags')
506
                // workaround: take into account Custom Tag names when merging configs
507
                ->useAttributeAsKey('tag')
508
                ->arrayPrototype()
509
                    ->children()
510
                        ->scalarNode('template')
511
                            ->isRequired()
512
                        ->end()
513
                        ->scalarNode('icon')
514
                            ->defaultNull()
515
                        ->end()
516
                        ->arrayNode('attributes')
517
                            ->useAttributeAsKey('attribute')
518
                            ->isRequired()
519
                            ->arrayPrototype()
520
                                ->beforeNormalization()
521
                                    ->always(
522
                                        function ($v) {
523
                                            // Workaround: set empty value to be able to unset it later on (see validation for "choices")
524
                                            if (!isset($v['choices'])) {
525
                                                $v['choices'] = [];
526
                                            }
527
528
                                            return $v;
529
                                        }
530
                                    )
531
                                ->end()
532
                                ->validate()
533
                                    ->ifTrue(
534
                                        function ($v) {
535
                                            return $v['type'] === 'choice' && !empty($v['required']) && empty($v['choices']);
536
                                        }
537
                                    )
538
                                    ->thenInvalid('List of choices for required choice type attribute has to be non-empty')
539
                                ->end()
540
                                ->validate()
541
                                    ->ifTrue(
542
                                        function ($v) {
543
                                            return !empty($v['choices']) && $v['type'] !== 'choice';
544
                                        }
545
                                    )
546
                                    ->thenInvalid('List of choices is supported by choices type only.')
547
                                ->end()
548
                                ->children()
549
                                    ->enumNode('type')
550
                                        ->isRequired()
551
                                        ->values(static::CUSTOM_TAG_ATTRIBUTE_TYPES)
552
                                    ->end()
553
                                    ->booleanNode('required')
554
                                        ->defaultFalse()
555
                                    ->end()
556
                                    ->scalarNode('default_value')
557
                                        ->defaultNull()
558
                                    ->end()
559
                                    ->arrayNode('choices')
560
                                        ->scalarPrototype()->end()
561
                                        ->performNoDeepMerging()
562
                                        ->validate()
563
                                            ->ifEmpty()->thenUnset()
564
                                        ->end()
565
                                    ->end()
566
                                ->end()
567
                            ->end()
568
                        ->end()
569
                    ->end()
570
                ->end()
571
            ->end()
572
        ;
573
    }
574
575
    /**
576
     * Define RichText Custom Styles Semantic Configuration.
577
     *
578
     * The configuration is available at:
579
     * <code>
580
     * ezpublish:
581
     *     ezrichtext:
582
     *         custom_styles:
583
     * </code>
584
     *
585
     * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $ezRichTextNode
586
     *
587
     * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
588
     */
589
    private function addCustomStylesSection(NodeBuilder $ezRichTextNode)
590
    {
591
        return $ezRichTextNode
592
                ->arrayNode('custom_styles')
593
                // workaround: take into account Custom Styles names when merging configs
594
                ->useAttributeAsKey('style')
595
                ->arrayPrototype()
596
                    ->children()
597
                        ->scalarNode('template')
598
                            ->defaultNull()
599
                        ->end()
600
                        ->scalarNode('inline')
601
                            ->defaultFalse()
602
                        ->end()
603
                    ->end()
604
                ->end()
605
            ->end()
606
        ;
607
    }
608
609
    /**
610
     * Defines configuration the images placeholder generation.
611
     *
612
     * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode
613
     */
614
    private function addImagePlaceholderSection(ArrayNodeDefinition $rootNode)
615
    {
616
        $rootNode
617
            ->children()
618
                ->arrayNode('image_placeholder')
619
                    ->info('Configuration for strategy of replacing missing images')
620
                    ->useAttributeAsKey('name')
621
                    ->arrayPrototype()
622
                        ->children()
623
                            ->scalarNode('provider')
624
                            ->end()
625
                            ->variableNode('options')
626
                                ->defaultValue([])
627
                            ->end()
628
                        ->end()
629
                    ->end()
630
                ->end()
631
            ->end();
632
    }
633
634
    /**
635
     * Define Url Alias Slug converter Semantic Configuration.
636
     *
637
     * The configuration is available at:
638
     * <code>
639
     * ezpublish:
640
     *     url_alias:
641
     *         slug_converter:
642
     *             transformation: name_of_transformation_group_to_use
643
     *             separator:  name_of_separator_to_use
644
     *             transformation_groups:
645
     *                 transformation_group_name: name of existing or new transformation group
646
     *                     commands : [] array of commands which will be added to group
647
     *                     cleanup_method: name_of_cleanup_method
648
     * </code>
649
     *
650
     * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode
651
     *
652
     * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
653
     */
654
    private function addUrlAliasSection(ArrayNodeDefinition $rootNode)
655
    {
656
        return $rootNode
657
            ->children()
658
                ->arrayNode('url_alias')
659
                    ->children()
660
                        ->arrayNode('slug_converter')
661
                            ->children()
662
                                ->scalarNode('transformation')->end()
663
                                ->scalarNode('separator')->end()
664
                                ->arrayNode('transformation_groups')
665
                                    ->arrayPrototype()
666
                                        ->children()
667
                                            ->arrayNode('commands')
668
                                                ->scalarPrototype()->end()
669
                                            ->end()
670
                                            ->scalarNode('cleanup_method')->end()
671
                                        ->end()
672
                                    ->end()
673
                                ->end()
674
                            ->end()
675
                        ->end()
676
                    ->end()
677
                ->end()
678
            ->end();
679
    }
680
}
681