Completed
Push — EZP-31046-chain-config-resolve... ( cbbd6c...51eaf2 )
by
unknown
14:38
created

EzPublishCoreExtension   C

Complexity

Total Complexity 56

Size/Duplication

Total Lines 529
Duplicated Lines 1.7 %

Coupling/Cohesion

Components 1
Dependencies 16

Importance

Changes 0
Metric Value
dl 9
loc 529
rs 5.5199
c 0
b 0
f 0
wmc 56
lcom 1
cbo 16

28 Methods

Rating   Name   Duplication   Size   Complexity  
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
A getConfiguration() 0 7 1
A prepend() 0 4 1
A getMainConfigParser() 0 14 4
A __construct() 0 5 1
A getAlias() 0 4 1
B load() 0 62 4
A handleDefaultSettingsLoading() 0 11 3
A registerRepositoriesConfiguration() 0 14 4
A registerSiteAccessConfiguration() 9 30 5
A registerImageMagickConfiguration() 0 14 4
A handleRouting() 0 16 2
A handleApiLoading() 0 38 1
A handleImage() 0 17 4
A handleUrlChecker() 0 4 1
A buildPolicyMap() 0 7 2
A addPolicyProvider() 0 4 1
A addConfigParser() 0 4 1
A addDefaultSettings() 0 4 1
A addSiteAccessConfigurationFilter() 0 4 1
A registerUrlAliasConfiguration() 0 8 2
A prependTranslatorConfiguration() 0 13 3
A registerUrlWildcardsConfiguration() 0 4 1
A handleUrlWildcards() 0 6 2

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\Compiler\QueryTypePass;
12
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigParser;
13
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
14
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollector;
15
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollectorAwareInterface;
16
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Formatter\YamlSuggestionFormatter;
17
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PoliciesConfigBuilder;
18
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface;
19
use eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter;
20
use eZ\Publish\Core\QueryType\QueryType;
21
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
22
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
23
use Symfony\Component\Filesystem\Filesystem;
24
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
25
use Symfony\Component\DependencyInjection\ContainerBuilder;
26
use Symfony\Component\DependencyInjection\Loader;
27
use Symfony\Component\DependencyInjection\Loader\FileLoader;
28
use Symfony\Component\Config\FileLocator;
29
use InvalidArgumentException;
30
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface;
31
32
class EzPublishCoreExtension extends Extension implements PrependExtensionInterface
33
{
34
    /** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollector */
35
    private $suggestionCollector;
36
37
    /** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface */
38
    private $mainConfigParser;
39
40
    /** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface[] */
41
    private $configParsers;
42
43
    /** @var PolicyProviderInterface[] */
44
    private $policyProviders = [];
45
46
    /**
47
     * Holds a collection of YAML files, as an array with directory path as a
48
     * key to the array of contained file names.
49
     *
50
     * @var array
51
     */
52
    private $defaultSettingsCollection = [];
53
54
    /** @var \eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter[] */
55
    private $siteaccessConfigurationFilters = [];
56
57
    public function __construct(array $configParsers = [])
58
    {
59
        $this->configParsers = $configParsers;
60
        $this->suggestionCollector = new SuggestionCollector();
61
    }
62
63
    public function getAlias()
64
    {
65
        return 'ezpublish';
66
    }
67
68
    /**
69
     * Loads a specific configuration.
70
     *
71
     * @param mixed[] $configs An array of configuration values
72
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
73
     *
74
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
75
     *
76
     * @api
77
     */
78
    public function load(array $configs, ContainerBuilder $container)
79
    {
80
        $loader = new Loader\YamlFileLoader(
81
            $container,
82
            new FileLocator(__DIR__ . '/../Resources/config')
83
        );
84
85
        $configuration = $this->getConfiguration($configs, $container);
86
87
        // Note: this is where the transformation occurs
88
        $config = $this->processConfiguration($configuration, $configs);
89
90
        // Base services and services overrides
91
        $loader->load('services.yml');
92
        // Security services
93
        $loader->load('security.yml');
94
95
        if (interface_exists('FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractorInterface')) {
96
            $loader->load('routing/js_routing.yml');
97
        }
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->registerUrlAliasConfiguration($config, $container);
106
        $this->registerUrlWildcardsConfiguration($config, $container);
107
108
        // Routing
109
        $this->handleRouting($config, $container, $loader);
110
        // Public API loading
111
        $this->handleApiLoading($container, $loader);
112
        $this->handleTemplating($container, $loader);
113
        $this->handleSessionLoading($container, $loader);
114
        $this->handleCache($config, $container, $loader);
115
        $this->handleLocale($config, $container, $loader);
116
        $this->handleHelpers($config, $container, $loader);
117
        $this->handleImage($config, $container, $loader);
118
        $this->handleUrlChecker($config, $container, $loader);
119
        $this->handleUrlWildcards($config, $container, $loader);
120
121
        // Map settings
122
        $processor = new ConfigurationProcessor($container, 'ezsettings');
123
        $processor->mapConfig($config, $this->getMainConfigParser());
124
125
        if ($this->suggestionCollector->hasSuggestions()) {
126
            $message = '';
127
            $suggestionFormatter = new YamlSuggestionFormatter();
128
            foreach ($this->suggestionCollector->getSuggestions() as $suggestion) {
129
                $message .= $suggestionFormatter->format($suggestion) . "\n\n";
130
            }
131
132
            throw new InvalidArgumentException($message);
133
        }
134
135
        $this->buildPolicyMap($container);
136
137
        $container->registerForAutoconfiguration(QueryType::class)
138
            ->addTag(QueryTypePass::QUERY_TYPE_SERVICE_TAG);
139
    }
140
141
    /**
142
     * @param array $config
143
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
144
     *
145
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration
146
     */
147
    public function getConfiguration(array $config, ContainerBuilder $container)
148
    {
149
        $configuration = new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
150
        $configuration->setSiteAccessConfigurationFilters($this->siteaccessConfigurationFilters);
151
152
        return $configuration;
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158
    public function prepend(ContainerBuilder $container)
159
    {
160
        $this->prependTranslatorConfiguration($container);
161
    }
162
163
    /**
164
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
165
     */
166
    private function getMainConfigParser()
167
    {
168
        if ($this->mainConfigParser === null) {
169
            foreach ($this->configParsers as $parser) {
170
                if ($parser instanceof SuggestionCollectorAwareInterface) {
171
                    $parser->setSuggestionCollector($this->suggestionCollector);
172
                }
173
            }
174
175
            $this->mainConfigParser = new ConfigParser($this->configParsers);
176
        }
177
178
        return $this->mainConfigParser;
179
    }
180
181
    /**
182
     * Handle default settings.
183
     *
184
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
185
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
186
     *
187
     * @throws \Exception
188
     */
189
    private function handleDefaultSettingsLoading(ContainerBuilder $container, FileLoader $loader)
190
    {
191
        $loader->load('default_settings.yml');
192
193
        foreach ($this->defaultSettingsCollection as $fileLocation => $files) {
194
            $externalLoader = new Loader\YamlFileLoader($container, new FileLocator($fileLocation));
195
            foreach ($files as $file) {
196
                $externalLoader->load($file);
197
            }
198
        }
199
    }
200
201
    private function registerRepositoriesConfiguration(array $config, ContainerBuilder $container)
202
    {
203
        if (!isset($config['repositories'])) {
204
            $config['repositories'] = [];
205
        }
206
207
        foreach ($config['repositories'] as $name => &$repository) {
208
            if (empty($repository['fields_groups']['list'])) {
209
                $repository['fields_groups']['list'] = $container->getParameter('ezsettings.default.content.field_groups.list');
210
            }
211
        }
212
213
        $container->setParameter('ezpublish.repositories', $config['repositories']);
214
    }
215
216
    private function registerSiteAccessConfiguration(array $config, ContainerBuilder $container)
217
    {
218
        if (!isset($config['siteaccess'])) {
219
            $config['siteaccess'] = [];
220
            $config['siteaccess']['list'] = ['setup'];
221
            $config['siteaccess']['default_siteaccess'] = 'setup';
222
            $config['siteaccess']['groups'] = [];
223
            $config['siteaccess']['match'] = null;
224
        }
225
226
        $container->setParameter('ezpublish.siteaccess.list', $config['siteaccess']['list']);
227
        ConfigurationProcessor::setAvailableSiteAccesses($config['siteaccess']['list']);
228
        $container->setParameter('ezpublish.siteaccess.default', $config['siteaccess']['default_siteaccess']);
229
        $container->setParameter('ezpublish.siteaccess.match_config', $config['siteaccess']['match']);
230
231
        // Register siteaccess groups + reverse
232
        $container->setParameter('ezpublish.siteaccess.groups', $config['siteaccess']['groups']);
233
        $groupsBySiteaccess = [];
234 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...
235
            foreach ($groupMembers as $member) {
236
                if (!isset($groupsBySiteaccess[$member])) {
237
                    $groupsBySiteaccess[$member] = [];
238
                }
239
240
                $groupsBySiteaccess[$member][] = $groupName;
241
            }
242
        }
243
        $container->setParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
244
        ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteaccess);
245
    }
246
247
    private function registerImageMagickConfiguration(array $config, ContainerBuilder $container)
248
    {
249
        if (isset($config['imagemagick'])) {
250
            $container->setParameter('ezpublish.image.imagemagick.enabled', $config['imagemagick']['enabled']);
251
            if ($config['imagemagick']['enabled']) {
252
                $container->setParameter('ezpublish.image.imagemagick.executable_path', dirname($config['imagemagick']['path']));
253
                $container->setParameter('ezpublish.image.imagemagick.executable', basename($config['imagemagick']['path']));
254
            }
255
        }
256
257
        $filters = isset($config['imagemagick']['filters']) ? $config['imagemagick']['filters'] : [];
258
        $filters = $filters + $container->getParameter('ezpublish.image.imagemagick.filters');
259
        $container->setParameter('ezpublish.image.imagemagick.filters', $filters);
260
    }
261
262
    /**
263
     * Handle routing parameters.
264
     *
265
     * @param array $config
266
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
267
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
268
     */
269
    private function handleRouting(array $config, ContainerBuilder $container, FileLoader $loader)
270
    {
271
        $loader->load('routing.yml');
272
        $container->setAlias('router', 'ezpublish.chain_router');
273
        $container->getAlias('router')->setPublic(true);
274
275
        if (isset($config['router']['default_router']['non_siteaccess_aware_routes'])) {
276
            $container->setParameter(
277
                'ezpublish.default_router.non_siteaccess_aware_routes',
278
                array_merge(
279
                    $container->getParameter('ezpublish.default_router.non_siteaccess_aware_routes'),
280
                    $config['router']['default_router']['non_siteaccess_aware_routes']
281
                )
282
            );
283
        }
284
    }
285
286
    /**
287
     * Handle public API loading.
288
     *
289
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
290
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
291
     */
292
    private function handleApiLoading(ContainerBuilder $container, FileLoader $loader)
293
    {
294
        // Loading configuration from Core/settings
295
        $coreLoader = new Loader\YamlFileLoader(
296
            $container,
297
            new FileLocator(__DIR__ . '/../../../Publish/Core/settings')
298
        );
299
        $coreLoader->load('repository.yml');
300
        $coreLoader->load('repository/inner.yml');
301
        $coreLoader->load('repository/event.yml');
302
        $coreLoader->load('repository/siteaccessaware.yml');
303
        $coreLoader->load('repository/autowire.yml');
304
        $coreLoader->load('fieldtype_external_storages.yml');
305
        $coreLoader->load('fieldtypes.yml');
306
        $coreLoader->load('indexable_fieldtypes.yml');
307
        $coreLoader->load('fieldtype_services.yml');
308
        $coreLoader->load('roles.yml');
309
        $coreLoader->load('storage_engines/common.yml');
310
        $coreLoader->load('storage_engines/cache.yml');
311
        $coreLoader->load('storage_engines/legacy.yml');
312
        $coreLoader->load('storage_engines/shortcuts.yml');
313
        $coreLoader->load('search_engines/common.yml');
314
        $coreLoader->load('utils.yml');
315
        $coreLoader->load('io.yml');
316
        $coreLoader->load('policies.yml');
317
        $coreLoader->load('notification.yml');
318
        $coreLoader->load('user_preference.yml');
319
        $coreLoader->load('events.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
        $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...
367
        if (isset($config['http_cache']['purge_type'])) {
368
            $container->setParameter('ezpublish.http_cache.purge_type', $config['http_cache']['purge_type']);
369
        }
370
    }
371
372
    /**
373
     * Handle locale parameters.
374
     *
375
     * @param array $config
376
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
377
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
378
     */
379
    private function handleLocale(array $config, ContainerBuilder $container, FileLoader $loader)
380
    {
381
        $loader->load('locale.yml');
382
        $container->setParameter(
383
            'ezpublish.locale.conversion_map',
384
            $config['locale_conversion'] + $container->getParameter('ezpublish.locale.conversion_map')
385
        );
386
    }
387
388
    /**
389
     * Handle helpers.
390
     *
391
     * @param array $config
392
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
393
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
394
     */
395
    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...
396
    {
397
        $loader->load('helpers.yml');
398
    }
399
400
    /**
401
     * @param array $config
402
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
403
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
404
     */
405
    private function handleImage(array $config, ContainerBuilder $container, FileLoader $loader)
406
    {
407
        $loader->load('image.yml');
408
409
        $providers = [];
410
        if (isset($config['image_placeholder'])) {
411
            foreach ($config['image_placeholder'] as $name => $value) {
412
                if (isset($providers[$name])) {
413
                    throw new InvalidConfigurationException("A image_placeholder named $name already exists");
414
                }
415
416
                $providers[$name] = $value;
417
            }
418
        }
419
420
        $container->setParameter('image_alias.placeholder_providers', $providers);
421
    }
422
423
    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...
424
    {
425
        $loader->load('url_checker.yml');
426
    }
427
428
    private function buildPolicyMap(ContainerBuilder $container)
429
    {
430
        $policiesBuilder = new PoliciesConfigBuilder($container);
431
        foreach ($this->policyProviders as $provider) {
432
            $provider->addPolicies($policiesBuilder);
433
        }
434
    }
435
436
    /**
437
     * Adds a new policy provider to the internal collection.
438
     * One can call this method from a bundle `build()` method.
439
     *
440
     * ```php
441
     * public function build(ContainerBuilder $container)
442
     * {
443
     *     $ezExtension = $container->getExtension('ezpublish');
444
     *     $ezExtension->addPolicyProvider($myPolicyProvider);
445
     * }
446
     * ```
447
     *
448
     * @since 6.0
449
     *
450
     * @param PolicyProviderInterface $policyProvider
451
     */
452
    public function addPolicyProvider(PolicyProviderInterface $policyProvider)
453
    {
454
        $this->policyProviders[] = $policyProvider;
455
    }
456
457
    /**
458
     * Adds a new config parser to the internal collection.
459
     * One can call this method from a bundle `build()` method.
460
     *
461
     * ```php
462
     * public function build(ContainerBuilder $container)
463
     * {
464
     *     $ezExtension = $container->getExtension('ezpublish');
465
     *     $ezExtension->addConfigParser($myConfigParser);
466
     * }
467
     * ```
468
     *
469
     * @since 6.0
470
     *
471
     * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface $configParser
472
     */
473
    public function addConfigParser(ParserInterface $configParser)
474
    {
475
        $this->configParsers[] = $configParser;
476
    }
477
478
    /**
479
     * Adds new default settings to the internal collection.
480
     * One can call this method from a bundle `build()` method.
481
     *
482
     * ```php
483
     * public function build(ContainerBuilder $container)
484
     * {
485
     *     $ezExtension = $container->getExtension('ezpublish');
486
     *     $ezExtension->addDefaultSettings(
487
     *         __DIR__ . '/Resources/config',
488
     *         ['default_settings.yml']
489
     *     );
490
     * }
491
     * ```
492
     *
493
     * @since 6.0
494
     *
495
     * @param string $fileLocation
496
     * @param array $files
497
     */
498
    public function addDefaultSettings($fileLocation, array $files)
499
    {
500
        $this->defaultSettingsCollection[$fileLocation] = $files;
501
    }
502
503
    public function addSiteAccessConfigurationFilter(SiteAccessConfigurationFilter $filter)
504
    {
505
        $this->siteaccessConfigurationFilters[] = $filter;
506
    }
507
508
    /**
509
     * @param array $config
510
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
511
     */
512
    private function registerUrlAliasConfiguration(array $config, ContainerBuilder $container)
513
    {
514
        if (!isset($config['url_alias'])) {
515
            $config['url_alias'] = ['slug_converter' => []];
516
        }
517
518
        $container->setParameter('ezpublish.url_alias.slug_converter', $config['url_alias']['slug_converter']);
519
    }
520
521
    /**
522
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
523
     */
524
    private function prependTranslatorConfiguration(ContainerBuilder $container)
525
    {
526
        if (!$container->hasExtension('framework')) {
527
            return;
528
        }
529
530
        $fileSystem = new Filesystem();
531
        $translationsPath = $container->getParameterBag()->get('kernel.root_dir') . '/../vendor/ezplatform-i18n';
532
533
        if ($fileSystem->exists($translationsPath)) {
534
            $container->prependExtensionConfig('framework', ['translator' => ['paths' => [$translationsPath]]]);
535
        }
536
    }
537
538
    /**
539
     * @param array $config
540
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
541
     */
542
    private function registerUrlWildcardsConfiguration(array $config, ContainerBuilder $container): void
543
    {
544
        $container->setParameter('ezpublish.url_wildcards.enabled', $config['url_wildcards']['enabled'] ?? false);
545
    }
546
547
    /**
548
     * Loads configuration for UrlWildcardsRouter service if enabled.
549
     *
550
     * @param array $config
551
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
552
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
553
     */
554
    private function handleUrlWildcards(array $config, ContainerBuilder $container, Loader\YamlFileLoader $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...
555
    {
556
        if ($container->getParameter('ezpublish.url_wildcards.enabled')) {
557
            $loader->load('url_wildcard.yml');
558
        }
559
    }
560
}
561