Completed
Push — ezp27152-rest_exception_symfon... ( d7d9ca...5c9060 )
by André
26:51 queued 13:22
created

EzPublishCoreExtension   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 518
Duplicated Lines 3.28 %

Coupling/Cohesion

Components 1
Dependencies 14

Importance

Changes 0
Metric Value
dl 17
loc 518
rs 6.8
c 0
b 0
f 0
wmc 55
lcom 1
cbo 14

24 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getAlias() 0 4 1
A load() 0 55 3
A getConfiguration() 0 4 1
A getMainConfigParser() 0 14 4
A handleDefaultSettingsLoading() 0 11 3
A registerRepositoriesConfiguration() 0 14 4
B registerSiteAccessConfiguration() 9 30 5
A registerImageMagickConfiguration() 0 14 4
B registerPageConfiguration() 0 27 5
A handleRouting() 0 15 2
B handleApiLoading() 0 29 1
A handleTemplating() 0 4 1
A handleSessionLoading() 0 4 1
B handleCache() 0 23 5
A handleLocale() 0 8 1
A handleHelpers() 0 4 1
B handleSiteAccessesRelation() 0 32 5
A handleImage() 0 4 1
A buildPolicyMap() 0 7 2
A prepend() 8 8 1
A addPolicyProvider() 0 4 1
A addConfigParser() 0 4 1
A addDefaultSettings() 0 4 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EzPublishCoreExtension often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EzPublishCoreExtension, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * File containing the EzPublishCoreExtension 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\ConfigParser;
12
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
13
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollector;
14
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollectorAwareInterface;
15
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Formatter\YamlSuggestionFormatter;
16
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PoliciesConfigBuilder;
17
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface;
18
use Symfony\Component\Config\Resource\FileResource;
19
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
20
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Loader;
23
use Symfony\Component\DependencyInjection\Loader\FileLoader;
24
use Symfony\Component\Config\FileLocator;
25
use InvalidArgumentException;
26
use Symfony\Component\Yaml\Yaml;
27
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface;
28
29
class EzPublishCoreExtension extends Extension implements PrependExtensionInterface
30
{
31
    /**
32
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollector
33
     */
34
    private $suggestionCollector;
35
36
    /**
37
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
38
     */
39
    private $mainConfigParser;
40
41
    /**
42
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface[]
43
     */
44
    private $configParsers;
45
46
    /**
47
     * @var PolicyProviderInterface[]
48
     */
49
    private $policyProviders = [];
50
51
    /**
52
     * Holds a collection of YAML files, as an array with directory path as a
53
     * key to the array of contained file names.
54
     *
55
     * @var array
56
     */
57
    private $defaultSettingsCollection = [];
58
59
    public function __construct(array $configParsers = array())
60
    {
61
        $this->configParsers = $configParsers;
62
        $this->suggestionCollector = new SuggestionCollector();
63
    }
64
65
    public function getAlias()
66
    {
67
        return 'ezpublish';
68
    }
69
70
    /**
71
     * Loads a specific configuration.
72
     *
73
     * @param mixed[] $configs An array of configuration values
74
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
75
     *
76
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
77
     *
78
     * @api
79
     */
80
    public function load(array $configs, ContainerBuilder $container)
81
    {
82
        $loader = new Loader\YamlFileLoader(
83
            $container,
84
            new FileLocator(__DIR__ . '/../Resources/config')
85
        );
86
87
        $configuration = $this->getConfiguration($configs, $container);
88
89
        // Note: this is where the transformation occurs
90
        $config = $this->processConfiguration($configuration, $configs);
91
92
        // Base services and services overrides
93
        $loader->load('services.yml');
94
        // Security services
95
        $loader->load('security.yml');
96
        // Slots
97
        $loader->load('slot.yml');
98
99
        // Default settings
100
        $this->handleDefaultSettingsLoading($container, $loader);
101
102
        $this->registerRepositoriesConfiguration($config, $container);
103
        $this->registerSiteAccessConfiguration($config, $container);
104
        $this->registerImageMagickConfiguration($config, $container);
105
        $this->registerPageConfiguration($config, $container);
106
107
        // Routing
108
        $this->handleRouting($config, $container, $loader);
109
        // Public API loading
110
        $this->handleApiLoading($container, $loader);
111
        $this->handleTemplating($container, $loader);
112
        $this->handleSessionLoading($container, $loader);
113
        $this->handleCache($config, $container, $loader);
114
        $this->handleLocale($config, $container, $loader);
115
        $this->handleHelpers($config, $container, $loader);
116
        $this->handleImage($config, $container, $loader);
117
118
        // Map settings
119
        $processor = new ConfigurationProcessor($container, 'ezsettings');
120
        $processor->mapConfig($config, $this->getMainConfigParser());
121
122
        if ($this->suggestionCollector->hasSuggestions()) {
123
            $message = '';
124
            $suggestionFormatter = new YamlSuggestionFormatter();
125
            foreach ($this->suggestionCollector->getSuggestions() as $suggestion) {
126
                $message .= $suggestionFormatter->format($suggestion) . "\n\n";
127
            }
128
129
            throw new InvalidArgumentException($message);
130
        }
131
132
        $this->handleSiteAccessesRelation($container);
133
        $this->buildPolicyMap($container);
134
    }
135
136
    /**
137
     * @param array $config
138
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
139
     *
140
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration
141
     */
142
    public function getConfiguration(array $config, ContainerBuilder $container)
143
    {
144
        return new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
145
    }
146
147
    /**
148
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
149
     */
150
    private function getMainConfigParser()
151
    {
152
        if ($this->mainConfigParser === null) {
153
            foreach ($this->configParsers as $parser) {
154
                if ($parser instanceof SuggestionCollectorAwareInterface) {
155
                    $parser->setSuggestionCollector($this->suggestionCollector);
156
                }
157
            }
158
159
            $this->mainConfigParser = new ConfigParser($this->configParsers);
160
        }
161
162
        return $this->mainConfigParser;
163
    }
164
165
    /**
166
     * Handle default settings.
167
     *
168
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
169
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
170
     */
171
    private function handleDefaultSettingsLoading(ContainerBuilder $container, FileLoader $loader)
172
    {
173
        $loader->load('default_settings.yml');
174
175
        foreach ($this->defaultSettingsCollection as $fileLocation => $files) {
176
            $externalLoader = new Loader\YamlFileLoader($container, new FileLocator($fileLocation));
177
            foreach ($files as $file) {
178
                $externalLoader->load($file);
179
            }
180
        }
181
    }
182
183
    private function registerRepositoriesConfiguration(array $config, ContainerBuilder $container)
184
    {
185
        if (!isset($config['repositories'])) {
186
            $config['repositories'] = array();
187
        }
188
189
        foreach ($config['repositories'] as $name => &$repository) {
190
            if (empty($repository['fields_groups']['list'])) {
191
                $repository['fields_groups']['list'] = $container->getParameter('ezsettings.default.content.field_groups.list');
192
            }
193
        }
194
195
        $container->setParameter('ezpublish.repositories', $config['repositories']);
196
    }
197
198
    private function registerSiteAccessConfiguration(array $config, ContainerBuilder $container)
199
    {
200
        if (!isset($config['siteaccess'])) {
201
            $config['siteaccess'] = array();
202
            $config['siteaccess']['list'] = array('setup');
203
            $config['siteaccess']['default_siteaccess'] = 'setup';
204
            $config['siteaccess']['groups'] = array();
205
            $config['siteaccess']['match'] = null;
206
        }
207
208
        $container->setParameter('ezpublish.siteaccess.list', $config['siteaccess']['list']);
209
        ConfigurationProcessor::setAvailableSiteAccesses($config['siteaccess']['list']);
210
        $container->setParameter('ezpublish.siteaccess.default', $config['siteaccess']['default_siteaccess']);
211
        $container->setParameter('ezpublish.siteaccess.match_config', $config['siteaccess']['match']);
212
213
        // Register siteaccess groups + reverse
214
        $container->setParameter('ezpublish.siteaccess.groups', $config['siteaccess']['groups']);
215
        $groupsBySiteaccess = array();
216 View Code Duplication
        foreach ($config['siteaccess']['groups'] as $groupName => $groupMembers) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
217
            foreach ($groupMembers as $member) {
218
                if (!isset($groupsBySiteaccess[$member])) {
219
                    $groupsBySiteaccess[$member] = array();
220
                }
221
222
                $groupsBySiteaccess[$member][] = $groupName;
223
            }
224
        }
225
        $container->setParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
226
        ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteaccess);
227
    }
228
229
    private function registerImageMagickConfiguration(array $config, ContainerBuilder $container)
230
    {
231
        if (isset($config['imagemagick'])) {
232
            $container->setParameter('ezpublish.image.imagemagick.enabled', $config['imagemagick']['enabled']);
233
            if ($config['imagemagick']['enabled']) {
234
                $container->setParameter('ezpublish.image.imagemagick.executable_path', dirname($config['imagemagick']['path']));
235
                $container->setParameter('ezpublish.image.imagemagick.executable', basename($config['imagemagick']['path']));
236
            }
237
        }
238
239
        $filters = isset($config['imagemagick']['filters']) ? $config['imagemagick']['filters'] : array();
240
        $filters = $filters + $container->getParameter('ezpublish.image.imagemagick.filters');
241
        $container->setParameter('ezpublish.image.imagemagick.filters', $filters);
242
    }
243
244
    private function registerPageConfiguration(array $config, ContainerBuilder $container)
245
    {
246
        if (isset($config['ezpage']['layouts'])) {
247
            $container->setParameter(
248
                'ezpublish.ezpage.layouts',
249
                $config['ezpage']['layouts'] + $container->getParameter('ezpublish.ezpage.layouts')
250
            );
251
        }
252
        if (isset($config['ezpage']['blocks'])) {
253
            $container->setParameter(
254
                'ezpublish.ezpage.blocks',
255
                $config['ezpage']['blocks'] + $container->getParameter('ezpublish.ezpage.blocks')
256
            );
257
        }
258
        if (isset($config['ezpage']['enabledLayouts'])) {
259
            $container->setParameter(
260
                'ezpublish.ezpage.enabledLayouts',
261
                $config['ezpage']['enabledLayouts'] + $container->getParameter('ezpublish.ezpage.enabledLayouts')
262
            );
263
        }
264
        if (isset($config['ezpage']['enabledBlocks'])) {
265
            $container->setParameter(
266
                'ezpublish.ezpage.enabledBlocks',
267
                $config['ezpage']['enabledBlocks'] + $container->getParameter('ezpublish.ezpage.enabledBlocks')
268
            );
269
        }
270
    }
271
272
    /**
273
     * Handle routing parameters.
274
     *
275
     * @param array $config
276
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
277
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
278
     */
279
    private function handleRouting(array $config, ContainerBuilder $container, FileLoader $loader)
280
    {
281
        $loader->load('routing.yml');
282
        $container->setAlias('router', 'ezpublish.chain_router');
283
284
        if (isset($config['router']['default_router']['non_siteaccess_aware_routes'])) {
285
            $container->setParameter(
286
                'ezpublish.default_router.non_siteaccess_aware_routes',
287
                array_merge(
288
                    $container->getParameter('ezpublish.default_router.non_siteaccess_aware_routes'),
289
                    $config['router']['default_router']['non_siteaccess_aware_routes']
290
                )
291
            );
292
        }
293
    }
294
295
    /**
296
     * Handle public API loading.
297
     *
298
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
299
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
300
     */
301
    private function handleApiLoading(ContainerBuilder $container, FileLoader $loader)
302
    {
303
        // Loading configuration from Core/settings
304
        $coreLoader = new Loader\YamlFileLoader(
305
            $container,
306
            new FileLocator(__DIR__ . '/../../../Publish/Core/settings')
307
        );
308
        $coreLoader->load('repository.yml');
309
        $coreLoader->load('fieldtype_external_storages.yml');
310
        $coreLoader->load('fieldtypes.yml');
311
        $coreLoader->load('indexable_fieldtypes.yml');
312
        $coreLoader->load('roles.yml');
313
        $coreLoader->load('storage_engines/common.yml');
314
        $coreLoader->load('storage_engines/cache.yml');
315
        $coreLoader->load('storage_engines/legacy.yml');
316
        $coreLoader->load('storage_engines/shortcuts.yml');
317
        $coreLoader->load('search_engines/common.yml');
318
        $coreLoader->load('utils.yml');
319
        $coreLoader->load('io.yml');
320
321
        // Public API services
322
        $loader->load('papi.yml');
323
324
        // Built-in field types
325
        $loader->load('fieldtype_services.yml');
326
327
        // Storage engine
328
        $loader->load('storage_engines.yml');
329
    }
330
331
    /**
332
     * Handle templating parameters.
333
     *
334
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
335
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
336
     */
337
    private function handleTemplating(ContainerBuilder $container, FileLoader $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
338
    {
339
        $loader->load('templating.yml');
340
    }
341
342
    /**
343
     * Handle session parameters.
344
     *
345
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
346
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
347
     */
348
    private function handleSessionLoading(ContainerBuilder $container, FileLoader $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
349
    {
350
        $loader->load('session.yml');
351
    }
352
353
    /**
354
     * Handle cache parameters.
355
     *
356
     * @param array $config
357
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
358
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
359
     *
360
     * @throws \InvalidArgumentException
361
     */
362
    private function handleCache(array $config, ContainerBuilder $container, FileLoader $loader)
363
    {
364
        $loader->load('cache.yml');
365
366
        if (isset($config['http_cache']['purge_type'])) {
367
            switch ($config['http_cache']['purge_type']) {
368
                case 'local':
369
                    $purgeService = 'ezpublish.http_cache.purge_client.local';
370
                    break;
371
                case 'http':
372
                    $purgeService = 'ezpublish.http_cache.purge_client.fos';
373
                    break;
374
                default:
375
                    if (!$container->has($config['http_cache']['purge_type'])) {
376
                        throw new \InvalidArgumentException("Invalid ezpublish.http_cache.purge_type. Can be 'single', 'multiple' or a valid service identifier implementing PurgeClientInterface.");
377
                    }
378
379
                    $purgeService = $config['http_cache']['purge_type'];
380
            }
381
382
            $container->setAlias('ezpublish.http_cache.purge_client', $purgeService);
383
        }
384
    }
385
386
    /**
387
     * Handle locale parameters.
388
     *
389
     * @param array $config
390
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
391
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
392
     */
393
    private function handleLocale(array $config, ContainerBuilder $container, FileLoader $loader)
394
    {
395
        $loader->load('locale.yml');
396
        $container->setParameter(
397
            'ezpublish.locale.conversion_map',
398
            $config['locale_conversion'] + $container->getParameter('ezpublish.locale.conversion_map')
399
        );
400
    }
401
402
    /**
403
     * Handle helpers.
404
     *
405
     * @param array $config
406
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
407
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
408
     */
409
    private function handleHelpers(array $config, ContainerBuilder $container, FileLoader $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
410
    {
411
        $loader->load('helpers.yml');
412
    }
413
414
    /**
415
     * Handles relation between SiteAccesses.
416
     * Related SiteAccesses share the same repository and root location id.
417
     *
418
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
419
     */
420
    private function handleSiteAccessesRelation(ContainerBuilder $container)
421
    {
422
        $configResolver = $container->get('ezpublish.config.resolver.core');
423
        $configResolver->setContainer($container);
424
425
        $saRelationMap = array();
426
        $saList = $container->getParameter('ezpublish.siteaccess.list');
427
        // First build the SiteAccess relation map, indexed by repository and rootLocationId.
428
        foreach ($saList as $sa) {
429
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
430
            if (!isset($saRelationMap[$repository])) {
431
                $saRelationMap[$repository] = array();
432
            }
433
434
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
435
            if (!isset($saRelationMap[$repository][$rootLocationId])) {
436
                $saRelationMap[$repository][$rootLocationId] = array();
437
            }
438
            $saRelationMap[$repository][$rootLocationId][] = $sa;
439
        }
440
        $container->setParameter('ezpublish.siteaccess.relation_map', $saRelationMap);
441
442
        // Now build the related SiteAccesses list, based on the relation map.
443
        foreach ($saList as $sa) {
444
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
445
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
446
            $container->setParameter(
447
                "ezsettings.$sa.related_siteaccesses",
448
                $saRelationMap[$repository][$rootLocationId]
449
            );
450
        }
451
    }
452
453
    /**
454
     * @param array $config
455
     * @param ContainerBuilder $container
456
     * @param FileLoader $loader
457
     */
458
    private function handleImage(array $config, ContainerBuilder $container, FileLoader $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
459
    {
460
        $loader->load('image.yml');
461
    }
462
463
    private function buildPolicyMap(ContainerBuilder $container)
464
    {
465
        $policiesBuilder = new PoliciesConfigBuilder($container);
466
        foreach ($this->policyProviders as $provider) {
467
            $provider->addPolicies($policiesBuilder);
468
        }
469
    }
470
471 View Code Duplication
    public function prepend(ContainerBuilder $container)
472
    {
473
        // Default settings for FOSHttpCacheBundle
474
        $configFile = __DIR__ . '/../Resources/config/fos_http_cache.yml';
475
        $config = Yaml::parse(file_get_contents($configFile));
476
        $container->prependExtensionConfig('fos_http_cache', $config);
477
        $container->addResource(new FileResource($configFile));
478
    }
479
480
    /**
481
     * Adds a new policy provider to the internal collection.
482
     * One can call this method from a bundle `build()` method.
483
     *
484
     * ```php
485
     * public function build(ContainerBuilder $container)
486
     * {
487
     *     $ezExtension = $container->getExtension('ezpublish');
488
     *     $ezExtension->addPolicyProvider($myPolicyProvider);
489
     * }
490
     * ```
491
     *
492
     * @since 6.0
493
     *
494
     * @param PolicyProviderInterface $policyProvider
495
     */
496
    public function addPolicyProvider(PolicyProviderInterface $policyProvider)
497
    {
498
        $this->policyProviders[] = $policyProvider;
499
    }
500
501
    /**
502
     * Adds a new config parser to the internal collection.
503
     * One can call this method from a bundle `build()` method.
504
     *
505
     * ```php
506
     * public function build(ContainerBuilder $container)
507
     * {
508
     *     $ezExtension = $container->getExtension('ezpublish');
509
     *     $ezExtension->addConfigParser($myConfigParser);
510
     * }
511
     * ```
512
     *
513
     * @since 6.0
514
     *
515
     * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface $configParser
516
     */
517
    public function addConfigParser(ParserInterface $configParser)
518
    {
519
        $this->configParsers[] = $configParser;
520
    }
521
522
    /**
523
     * Adds new default settings to the internal collection.
524
     * One can call this method from a bundle `build()` method.
525
     *
526
     * ```php
527
     * public function build(ContainerBuilder $container)
528
     * {
529
     *     $ezExtension = $container->getExtension('ezpublish');
530
     *     $ezExtension->addDefaultSettings(
531
     *         __DIR__ . '/Resources/config',
532
     *         ['default_settings.yml']
533
     *     );
534
     * }
535
     * ```
536
     *
537
     * @since 6.0
538
     *
539
     * @param string $fileLocation
540
     * @param array $files
541
     */
542
    public function addDefaultSettings($fileLocation, array $files)
543
    {
544
        $this->defaultSettingsCollection[$fileLocation] = $files;
545
    }
546
}
547