Completed
Push — foshttpcache_remove ( 2e4f0c...fe84f8 )
by André
24:01
created

EzPublishCoreExtension   B

Complexity

Total Complexity 54

Size/Duplication

Total Lines 518
Duplicated Lines 1.74 %

Coupling/Cohesion

Components 1
Dependencies 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 9
loc 518
rs 7.0642
wmc 54
lcom 1
cbo 12

25 Methods

Rating   Name   Duplication   Size   Complexity  
A addPolicyProvider() 0 4 1
A buildPolicyMap() 0 7 2
A getConfiguration() 0 7 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 31 1
A handleTemplating() 0 4 1
A handleSessionLoading() 0 4 1
A handleCache() 0 9 2
A handleLocale() 0 8 1
A handleHelpers() 0 4 1
B handleSiteAccessesRelation() 0 32 5
A handleImage() 0 4 1
A __construct() 0 5 1
A getAlias() 0 4 1
A load() 0 58 4
A handleUrlChecker() 0 4 1
A addConfigParser() 0 4 1
A addDefaultSettings() 0 4 1
A addSiteAccessConfigurationFilter() 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 eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter;
19
use Symfony\Component\Config\Resource\FileResource;
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
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
    /**
60
     * @var \eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter[]
61
     */
62
    private $siteaccessConfigurationFilters = [];
63
64
    public function __construct(array $configParsers = array())
65
    {
66
        $this->configParsers = $configParsers;
67
        $this->suggestionCollector = new SuggestionCollector();
68
    }
69
70
    public function getAlias()
71
    {
72
        return 'ezpublish';
73
    }
74
75
    /**
76
     * Loads a specific configuration.
77
     *
78
     * @param mixed[] $configs An array of configuration values
79
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
80
     *
81
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
82
     *
83
     * @api
84
     */
85
    public function load(array $configs, ContainerBuilder $container)
86
    {
87
        $loader = new Loader\YamlFileLoader(
88
            $container,
89
            new FileLocator(__DIR__ . '/../Resources/config')
90
        );
91
92
        $configuration = $this->getConfiguration($configs, $container);
93
94
        // Note: this is where the transformation occurs
95
        $config = $this->processConfiguration($configuration, $configs);
96
97
        // Base services and services overrides
98
        $loader->load('services.yml');
99
        // Security services
100
        $loader->load('security.yml');
101
102
        if (interface_exists('FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractorInterface')) {
103
            $loader->load('routing/js_routing.yml');
104
        }
105
106
        // Default settings
107
        $this->handleDefaultSettingsLoading($container, $loader);
108
109
        $this->registerRepositoriesConfiguration($config, $container);
110
        $this->registerSiteAccessConfiguration($config, $container);
111
        $this->registerImageMagickConfiguration($config, $container);
112
        $this->registerPageConfiguration($config, $container);
113
114
        // Routing
115
        $this->handleRouting($config, $container, $loader);
116
        // Public API loading
117
        $this->handleApiLoading($container, $loader);
118
        $this->handleTemplating($container, $loader);
119
        $this->handleSessionLoading($container, $loader);
120
        $this->handleCache($config, $container, $loader);
121
        $this->handleLocale($config, $container, $loader);
122
        $this->handleHelpers($config, $container, $loader);
123
        $this->handleImage($config, $container, $loader);
124
        $this->handleUrlChecker($config, $container, $loader);
125
126
        // Map settings
127
        $processor = new ConfigurationProcessor($container, 'ezsettings');
128
        $processor->mapConfig($config, $this->getMainConfigParser());
129
130
        if ($this->suggestionCollector->hasSuggestions()) {
131
            $message = '';
132
            $suggestionFormatter = new YamlSuggestionFormatter();
133
            foreach ($this->suggestionCollector->getSuggestions() as $suggestion) {
134
                $message .= $suggestionFormatter->format($suggestion) . "\n\n";
135
            }
136
137
            throw new InvalidArgumentException($message);
138
        }
139
140
        $this->handleSiteAccessesRelation($container);
141
        $this->buildPolicyMap($container);
142
    }
143
144
    /**
145
     * @param array $config
146
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
147
     *
148
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration
149
     */
150
    public function getConfiguration(array $config, ContainerBuilder $container)
151
    {
152
        $configuration = new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
153
        $configuration->setSiteAccessConfigurationFilters($this->siteaccessConfigurationFilters);
154
155
        return $configuration;
156
    }
157
158
    /**
159
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
160
     */
161
    private function getMainConfigParser()
162
    {
163
        if ($this->mainConfigParser === null) {
164
            foreach ($this->configParsers as $parser) {
165
                if ($parser instanceof SuggestionCollectorAwareInterface) {
166
                    $parser->setSuggestionCollector($this->suggestionCollector);
167
                }
168
            }
169
170
            $this->mainConfigParser = new ConfigParser($this->configParsers);
171
        }
172
173
        return $this->mainConfigParser;
174
    }
175
176
    /**
177
     * Handle default settings.
178
     *
179
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
180
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
181
     */
182
    private function handleDefaultSettingsLoading(ContainerBuilder $container, FileLoader $loader)
183
    {
184
        $loader->load('default_settings.yml');
185
186
        foreach ($this->defaultSettingsCollection as $fileLocation => $files) {
187
            $externalLoader = new Loader\YamlFileLoader($container, new FileLocator($fileLocation));
188
            foreach ($files as $file) {
189
                $externalLoader->load($file);
190
            }
191
        }
192
    }
193
194
    private function registerRepositoriesConfiguration(array $config, ContainerBuilder $container)
195
    {
196
        if (!isset($config['repositories'])) {
197
            $config['repositories'] = array();
198
        }
199
200
        foreach ($config['repositories'] as $name => &$repository) {
201
            if (empty($repository['fields_groups']['list'])) {
202
                $repository['fields_groups']['list'] = $container->getParameter('ezsettings.default.content.field_groups.list');
203
            }
204
        }
205
206
        $container->setParameter('ezpublish.repositories', $config['repositories']);
207
    }
208
209
    private function registerSiteAccessConfiguration(array $config, ContainerBuilder $container)
210
    {
211
        if (!isset($config['siteaccess'])) {
212
            $config['siteaccess'] = array();
213
            $config['siteaccess']['list'] = array('setup');
214
            $config['siteaccess']['default_siteaccess'] = 'setup';
215
            $config['siteaccess']['groups'] = array();
216
            $config['siteaccess']['match'] = null;
217
        }
218
219
        $container->setParameter('ezpublish.siteaccess.list', $config['siteaccess']['list']);
220
        ConfigurationProcessor::setAvailableSiteAccesses($config['siteaccess']['list']);
221
        $container->setParameter('ezpublish.siteaccess.default', $config['siteaccess']['default_siteaccess']);
222
        $container->setParameter('ezpublish.siteaccess.match_config', $config['siteaccess']['match']);
223
224
        // Register siteaccess groups + reverse
225
        $container->setParameter('ezpublish.siteaccess.groups', $config['siteaccess']['groups']);
226
        $groupsBySiteaccess = array();
227 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...
228
            foreach ($groupMembers as $member) {
229
                if (!isset($groupsBySiteaccess[$member])) {
230
                    $groupsBySiteaccess[$member] = array();
231
                }
232
233
                $groupsBySiteaccess[$member][] = $groupName;
234
            }
235
        }
236
        $container->setParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
237
        ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteaccess);
238
    }
239
240
    private function registerImageMagickConfiguration(array $config, ContainerBuilder $container)
241
    {
242
        if (isset($config['imagemagick'])) {
243
            $container->setParameter('ezpublish.image.imagemagick.enabled', $config['imagemagick']['enabled']);
244
            if ($config['imagemagick']['enabled']) {
245
                $container->setParameter('ezpublish.image.imagemagick.executable_path', dirname($config['imagemagick']['path']));
246
                $container->setParameter('ezpublish.image.imagemagick.executable', basename($config['imagemagick']['path']));
247
            }
248
        }
249
250
        $filters = isset($config['imagemagick']['filters']) ? $config['imagemagick']['filters'] : array();
251
        $filters = $filters + $container->getParameter('ezpublish.image.imagemagick.filters');
252
        $container->setParameter('ezpublish.image.imagemagick.filters', $filters);
253
    }
254
255
    private function registerPageConfiguration(array $config, ContainerBuilder $container)
256
    {
257
        if (isset($config['ezpage']['layouts'])) {
258
            $container->setParameter(
259
                'ezpublish.ezpage.layouts',
260
                $config['ezpage']['layouts'] + $container->getParameter('ezpublish.ezpage.layouts')
261
            );
262
        }
263
        if (isset($config['ezpage']['blocks'])) {
264
            $container->setParameter(
265
                'ezpublish.ezpage.blocks',
266
                $config['ezpage']['blocks'] + $container->getParameter('ezpublish.ezpage.blocks')
267
            );
268
        }
269
        if (isset($config['ezpage']['enabledLayouts'])) {
270
            $container->setParameter(
271
                'ezpublish.ezpage.enabledLayouts',
272
                $config['ezpage']['enabledLayouts'] + $container->getParameter('ezpublish.ezpage.enabledLayouts')
273
            );
274
        }
275
        if (isset($config['ezpage']['enabledBlocks'])) {
276
            $container->setParameter(
277
                'ezpublish.ezpage.enabledBlocks',
278
                $config['ezpage']['enabledBlocks'] + $container->getParameter('ezpublish.ezpage.enabledBlocks')
279
            );
280
        }
281
    }
282
283
    /**
284
     * Handle routing parameters.
285
     *
286
     * @param array $config
287
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
288
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
289
     */
290
    private function handleRouting(array $config, ContainerBuilder $container, FileLoader $loader)
291
    {
292
        $loader->load('routing.yml');
293
        $container->setAlias('router', 'ezpublish.chain_router');
294
295
        if (isset($config['router']['default_router']['non_siteaccess_aware_routes'])) {
296
            $container->setParameter(
297
                'ezpublish.default_router.non_siteaccess_aware_routes',
298
                array_merge(
299
                    $container->getParameter('ezpublish.default_router.non_siteaccess_aware_routes'),
300
                    $config['router']['default_router']['non_siteaccess_aware_routes']
301
                )
302
            );
303
        }
304
    }
305
306
    /**
307
     * Handle public API loading.
308
     *
309
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
310
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
311
     */
312
    private function handleApiLoading(ContainerBuilder $container, FileLoader $loader)
313
    {
314
        // Loading configuration from Core/settings
315
        $coreLoader = new Loader\YamlFileLoader(
316
            $container,
317
            new FileLocator(__DIR__ . '/../../../Publish/Core/settings')
318
        );
319
        $coreLoader->load('repository.yml');
320
        $coreLoader->load('repository/inner.yml');
321
        $coreLoader->load('repository/signalslot.yml');
322
        $coreLoader->load('fieldtype_external_storages.yml');
323
        $coreLoader->load('fieldtypes.yml');
324
        $coreLoader->load('indexable_fieldtypes.yml');
325
        $coreLoader->load('roles.yml');
326
        $coreLoader->load('storage_engines/common.yml');
327
        $coreLoader->load('storage_engines/cache.yml');
328
        $coreLoader->load('storage_engines/legacy.yml');
329
        $coreLoader->load('storage_engines/shortcuts.yml');
330
        $coreLoader->load('search_engines/common.yml');
331
        $coreLoader->load('utils.yml');
332
        $coreLoader->load('io.yml');
333
334
        // Public API services
335
        $loader->load('papi.yml');
336
337
        // Built-in field types
338
        $loader->load('fieldtype_services.yml');
339
340
        // Storage engine
341
        $loader->load('storage_engines.yml');
342
    }
343
344
    /**
345
     * Handle templating parameters.
346
     *
347
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
348
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
349
     */
350
    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...
351
    {
352
        $loader->load('templating.yml');
353
    }
354
355
    /**
356
     * Handle session parameters.
357
     *
358
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
359
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
360
     */
361
    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...
362
    {
363
        $loader->load('session.yml');
364
    }
365
366
    /**
367
     * Handle cache parameters.
368
     *
369
     * @param array $config
370
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
371
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
372
     *
373
     * @throws \InvalidArgumentException
374
     */
375
    private function handleCache(array $config, ContainerBuilder $container, FileLoader $loader)
376
    {
377
        $loader->load('cache.yml');
378
379
        $purgeService = null;
0 ignored issues
show
Unused Code introduced by
$purgeService is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
380
        if (isset($config['http_cache']['purge_type'])) {
381
            $container->setParameter('ezpublish.http_cache.purge_type', $config['http_cache']['purge_type']);
382
        }
383
    }
384
385
    /**
386
     * Handle locale parameters.
387
     *
388
     * @param array $config
389
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
390
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
391
     */
392
    private function handleLocale(array $config, ContainerBuilder $container, FileLoader $loader)
393
    {
394
        $loader->load('locale.yml');
395
        $container->setParameter(
396
            'ezpublish.locale.conversion_map',
397
            $config['locale_conversion'] + $container->getParameter('ezpublish.locale.conversion_map')
398
        );
399
    }
400
401
    /**
402
     * Handle helpers.
403
     *
404
     * @param array $config
405
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
406
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
407
     */
408
    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...
409
    {
410
        $loader->load('helpers.yml');
411
    }
412
413
    /**
414
     * Handles relation between SiteAccesses.
415
     * Related SiteAccesses share the same repository and root location id.
416
     *
417
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
418
     */
419
    private function handleSiteAccessesRelation(ContainerBuilder $container)
420
    {
421
        $configResolver = $container->get('ezpublish.config.resolver.core');
422
        $configResolver->setContainer($container);
423
424
        $saRelationMap = array();
425
        $saList = $container->getParameter('ezpublish.siteaccess.list');
426
        // First build the SiteAccess relation map, indexed by repository and rootLocationId.
427
        foreach ($saList as $sa) {
428
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
429
            if (!isset($saRelationMap[$repository])) {
430
                $saRelationMap[$repository] = array();
431
            }
432
433
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
434
            if (!isset($saRelationMap[$repository][$rootLocationId])) {
435
                $saRelationMap[$repository][$rootLocationId] = array();
436
            }
437
            $saRelationMap[$repository][$rootLocationId][] = $sa;
438
        }
439
        $container->setParameter('ezpublish.siteaccess.relation_map', $saRelationMap);
440
441
        // Now build the related SiteAccesses list, based on the relation map.
442
        foreach ($saList as $sa) {
443
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
444
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
445
            $container->setParameter(
446
                "ezsettings.$sa.related_siteaccesses",
447
                $saRelationMap[$repository][$rootLocationId]
448
            );
449
        }
450
    }
451
452
    /**
453
     * @param array $config
454
     * @param ContainerBuilder $container
455
     * @param FileLoader $loader
456
     */
457
    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...
458
    {
459
        $loader->load('image.yml');
460
    }
461
462
    private function handleUrlChecker($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...
463
    {
464
        $loader->load('url_checker.yml');
465
    }
466
467
    private function buildPolicyMap(ContainerBuilder $container)
468
    {
469
        $policiesBuilder = new PoliciesConfigBuilder($container);
470
        foreach ($this->policyProviders as $provider) {
471
            $provider->addPolicies($policiesBuilder);
472
        }
473
    }
474
475
    /**
476
     * Adds a new policy provider to the internal collection.
477
     * One can call this method from a bundle `build()` method.
478
     *
479
     * ```php
480
     * public function build(ContainerBuilder $container)
481
     * {
482
     *     $ezExtension = $container->getExtension('ezpublish');
483
     *     $ezExtension->addPolicyProvider($myPolicyProvider);
484
     * }
485
     * ```
486
     *
487
     * @since 6.0
488
     *
489
     * @param PolicyProviderInterface $policyProvider
490
     */
491
    public function addPolicyProvider(PolicyProviderInterface $policyProvider)
492
    {
493
        $this->policyProviders[] = $policyProvider;
494
    }
495
496
    /**
497
     * Adds a new config parser to the internal collection.
498
     * One can call this method from a bundle `build()` method.
499
     *
500
     * ```php
501
     * public function build(ContainerBuilder $container)
502
     * {
503
     *     $ezExtension = $container->getExtension('ezpublish');
504
     *     $ezExtension->addConfigParser($myConfigParser);
505
     * }
506
     * ```
507
     *
508
     * @since 6.0
509
     *
510
     * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface $configParser
511
     */
512
    public function addConfigParser(ParserInterface $configParser)
513
    {
514
        $this->configParsers[] = $configParser;
515
    }
516
517
    /**
518
     * Adds new default settings to the internal collection.
519
     * One can call this method from a bundle `build()` method.
520
     *
521
     * ```php
522
     * public function build(ContainerBuilder $container)
523
     * {
524
     *     $ezExtension = $container->getExtension('ezpublish');
525
     *     $ezExtension->addDefaultSettings(
526
     *         __DIR__ . '/Resources/config',
527
     *         ['default_settings.yml']
528
     *     );
529
     * }
530
     * ```
531
     *
532
     * @since 6.0
533
     *
534
     * @param string $fileLocation
535
     * @param array $files
536
     */
537
    public function addDefaultSettings($fileLocation, array $files)
538
    {
539
        $this->defaultSettingsCollection[$fileLocation] = $files;
540
    }
541
542
    public function addSiteAccessConfigurationFilter(SiteAccessConfigurationFilter $filter)
543
    {
544
        $this->siteaccessConfigurationFilters[] = $filter;
545
    }
546
}
547