Completed
Push — ezp28009-richtext_compatibilit... ( c2c2a1...4f26ba )
by
unknown
24:20
created

EzPublishCoreExtension::getMainConfigParser()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 2
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
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\Definition\Exception\InvalidConfigurationException;
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 eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface;
27
28
class EzPublishCoreExtension extends Extension
29
{
30
    const RICHTEXT_CUSTOM_STYLES_PARAMETER = 'ezplatform.ezrichtext.custom_styles';
31
    const RICHTEXT_CUSTOM_TAGS_PARAMETER = 'ezplatform.ezrichtext.custom_tags';
32
33
    /**
34
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Suggestion\Collector\SuggestionCollector
35
     */
36
    private $suggestionCollector;
37
38
    /**
39
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
40
     */
41
    private $mainConfigParser;
42
43
    /**
44
     * @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface[]
45
     */
46
    private $configParsers;
47
48
    /**
49
     * @var PolicyProviderInterface[]
50
     */
51
    private $policyProviders = [];
52
53
    /**
54
     * Holds a collection of YAML files, as an array with directory path as a
55
     * key to the array of contained file names.
56
     *
57
     * @var array
58
     */
59
    private $defaultSettingsCollection = [];
60
61
    /**
62
     * @var \eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter[]
63
     */
64
    private $siteaccessConfigurationFilters = [];
65
66
    public function __construct(array $configParsers = array())
67
    {
68
        $this->configParsers = $configParsers;
69
        $this->suggestionCollector = new SuggestionCollector();
70
    }
71
72
    public function getAlias()
73
    {
74
        return 'ezpublish';
75
    }
76
77
    /**
78
     * Loads a specific configuration.
79
     *
80
     * @param mixed[] $configs An array of configuration values
81
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
82
     *
83
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
84
     *
85
     * @api
86
     */
87
    public function load(array $configs, ContainerBuilder $container)
88
    {
89
        $loader = new Loader\YamlFileLoader(
90
            $container,
91
            new FileLocator(__DIR__ . '/../Resources/config')
92
        );
93
94
        $configuration = $this->getConfiguration($configs, $container);
95
96
        // Note: this is where the transformation occurs
97
        $config = $this->processConfiguration($configuration, $configs);
98
99
        // Base services and services overrides
100
        $loader->load('services.yml');
101
        // Security services
102
        $loader->load('security.yml');
103
104
        if (interface_exists('FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractorInterface')) {
105
            $loader->load('routing/js_routing.yml');
106
        }
107
108
        // Default settings
109
        $this->handleDefaultSettingsLoading($container, $loader);
110
111
        $this->registerRepositoriesConfiguration($config, $container);
112
        $this->registerSiteAccessConfiguration($config, $container);
113
        $this->registerImageMagickConfiguration($config, $container);
114
        $this->registerPageConfiguration($config, $container);
115
        $this->registerRichTextConfiguration($config, $container);
116
        $this->registerUrlAliasConfiguration($config, $container);
117
118
        // Routing
119
        $this->handleRouting($config, $container, $loader);
120
        // Public API loading
121
        $this->handleApiLoading($container, $loader);
122
        $this->handleTemplating($container, $loader);
123
        $this->handleSessionLoading($container, $loader);
124
        $this->handleCache($config, $container, $loader);
125
        $this->handleLocale($config, $container, $loader);
126
        $this->handleHelpers($config, $container, $loader);
127
        $this->handleImage($config, $container, $loader);
128
        $this->handleUrlChecker($config, $container, $loader);
129
130
        // Map settings
131
        $processor = new ConfigurationProcessor($container, 'ezsettings');
132
        $processor->mapConfig($config, $this->getMainConfigParser());
133
134
        if ($this->suggestionCollector->hasSuggestions()) {
135
            $message = '';
136
            $suggestionFormatter = new YamlSuggestionFormatter();
137
            foreach ($this->suggestionCollector->getSuggestions() as $suggestion) {
138
                $message .= $suggestionFormatter->format($suggestion) . "\n\n";
139
            }
140
141
            throw new InvalidArgumentException($message);
142
        }
143
144
        $this->handleSiteAccessesRelation($container);
145
        $this->buildPolicyMap($container);
146
    }
147
148
    /**
149
     * @param array $config
150
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
151
     *
152
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration
153
     */
154
    public function getConfiguration(array $config, ContainerBuilder $container)
155
    {
156
        $configuration = new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
157
        $configuration->setSiteAccessConfigurationFilters($this->siteaccessConfigurationFilters);
158
159
        return $configuration;
160
    }
161
162
    /**
163
     * @return \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface
164
     */
165
    private function getMainConfigParser()
166
    {
167
        if ($this->mainConfigParser === null) {
168
            foreach ($this->configParsers as $parser) {
169
                if ($parser instanceof SuggestionCollectorAwareInterface) {
170
                    $parser->setSuggestionCollector($this->suggestionCollector);
171
                }
172
            }
173
174
            $this->mainConfigParser = new ConfigParser($this->configParsers);
175
        }
176
177
        return $this->mainConfigParser;
178
    }
179
180
    /**
181
     * Handle default settings.
182
     *
183
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
184
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
185
     *
186
     * @throws \Exception
187
     */
188
    private function handleDefaultSettingsLoading(ContainerBuilder $container, FileLoader $loader)
189
    {
190
        $loader->load('default_settings.yml');
191
192
        if (!$this->isRichTextBundleEnabled($container)) {
193
            $loader->load('ezrichtext_default_settings.yml');
194
        }
195
196
        foreach ($this->defaultSettingsCollection as $fileLocation => $files) {
197
            $externalLoader = new Loader\YamlFileLoader($container, new FileLocator($fileLocation));
198
            foreach ($files as $file) {
199
                $externalLoader->load($file);
200
            }
201
        }
202
    }
203
204
    private function registerRepositoriesConfiguration(array $config, ContainerBuilder $container)
205
    {
206
        if (!isset($config['repositories'])) {
207
            $config['repositories'] = array();
208
        }
209
210
        foreach ($config['repositories'] as $name => &$repository) {
211
            if (empty($repository['fields_groups']['list'])) {
212
                $repository['fields_groups']['list'] = $container->getParameter('ezsettings.default.content.field_groups.list');
213
            }
214
        }
215
216
        $container->setParameter('ezpublish.repositories', $config['repositories']);
217
    }
218
219
    private function registerSiteAccessConfiguration(array $config, ContainerBuilder $container)
220
    {
221
        if (!isset($config['siteaccess'])) {
222
            $config['siteaccess'] = array();
223
            $config['siteaccess']['list'] = array('setup');
224
            $config['siteaccess']['default_siteaccess'] = 'setup';
225
            $config['siteaccess']['groups'] = array();
226
            $config['siteaccess']['match'] = null;
227
        }
228
229
        $container->setParameter('ezpublish.siteaccess.list', $config['siteaccess']['list']);
230
        ConfigurationProcessor::setAvailableSiteAccesses($config['siteaccess']['list']);
231
        $container->setParameter('ezpublish.siteaccess.default', $config['siteaccess']['default_siteaccess']);
232
        $container->setParameter('ezpublish.siteaccess.match_config', $config['siteaccess']['match']);
233
234
        // Register siteaccess groups + reverse
235
        $container->setParameter('ezpublish.siteaccess.groups', $config['siteaccess']['groups']);
236
        $groupsBySiteaccess = array();
237 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...
238
            foreach ($groupMembers as $member) {
239
                if (!isset($groupsBySiteaccess[$member])) {
240
                    $groupsBySiteaccess[$member] = array();
241
                }
242
243
                $groupsBySiteaccess[$member][] = $groupName;
244
            }
245
        }
246
        $container->setParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
247
        ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteaccess);
248
    }
249
250
    private function registerImageMagickConfiguration(array $config, ContainerBuilder $container)
251
    {
252
        if (isset($config['imagemagick'])) {
253
            $container->setParameter('ezpublish.image.imagemagick.enabled', $config['imagemagick']['enabled']);
254
            if ($config['imagemagick']['enabled']) {
255
                $container->setParameter('ezpublish.image.imagemagick.executable_path', dirname($config['imagemagick']['path']));
256
                $container->setParameter('ezpublish.image.imagemagick.executable', basename($config['imagemagick']['path']));
257
            }
258
        }
259
260
        $filters = isset($config['imagemagick']['filters']) ? $config['imagemagick']['filters'] : array();
261
        $filters = $filters + $container->getParameter('ezpublish.image.imagemagick.filters');
262
        $container->setParameter('ezpublish.image.imagemagick.filters', $filters);
263
    }
264
265
    private function registerPageConfiguration(array $config, ContainerBuilder $container)
266
    {
267
        if (isset($config['ezpage']['layouts'])) {
268
            $container->setParameter(
269
                'ezpublish.ezpage.layouts',
270
                $config['ezpage']['layouts'] + $container->getParameter('ezpublish.ezpage.layouts')
271
            );
272
        }
273
        if (isset($config['ezpage']['blocks'])) {
274
            $container->setParameter(
275
                'ezpublish.ezpage.blocks',
276
                $config['ezpage']['blocks'] + $container->getParameter('ezpublish.ezpage.blocks')
277
            );
278
        }
279
        if (isset($config['ezpage']['enabledLayouts'])) {
280
            $container->setParameter(
281
                'ezpublish.ezpage.enabledLayouts',
282
                $config['ezpage']['enabledLayouts'] + $container->getParameter('ezpublish.ezpage.enabledLayouts')
283
            );
284
        }
285
        if (isset($config['ezpage']['enabledBlocks'])) {
286
            $container->setParameter(
287
                'ezpublish.ezpage.enabledBlocks',
288
                $config['ezpage']['enabledBlocks'] + $container->getParameter('ezpublish.ezpage.enabledBlocks')
289
            );
290
        }
291
    }
292
293
    /**
294
     * Register parameters of global RichText configuration.
295
     *
296
     * @param array $config
297
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
298
     */
299
    private function registerRichTextConfiguration(array $config, ContainerBuilder $container)
300
    {
301 View Code Duplication
        if (isset($config['ezrichtext']['custom_tags'])) {
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...
302
            $container->setParameter(
303
                static::RICHTEXT_CUSTOM_TAGS_PARAMETER,
304
                $config['ezrichtext']['custom_tags']
305
            );
306
        }
307 View Code Duplication
        if (isset($config['ezrichtext']['custom_styles'])) {
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...
308
            $container->setParameter(
309
                static::RICHTEXT_CUSTOM_STYLES_PARAMETER,
310
                $config['ezrichtext']['custom_styles']
311
            );
312
        }
313
        // keep BC
314
        if (!empty($config['ezrichtext']) && $this->isRichTextBundleEnabled($container)) {
315
            $container->prependExtensionConfig('ezrichtext', $config['ezrichtext']);
316
            if (!empty($config['ezrichtext']['custom_tags']) || !empty($config['ezrichtext']['custom_styles'])) {
317
                @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
318
                    'ezpublish.ezrichtext configuration is deprecated since v7.4, move entire configuration node to ezrichtext extension',
319
                    E_USER_DEPRECATED
320
                );
321
            }
322
        }
323
    }
324
325
    /**
326
     * Handle routing parameters.
327
     *
328
     * @param array $config
329
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
330
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
331
     */
332
    private function handleRouting(array $config, ContainerBuilder $container, FileLoader $loader)
333
    {
334
        $loader->load('routing.yml');
335
        $container->setAlias('router', 'ezpublish.chain_router');
336
337
        if (isset($config['router']['default_router']['non_siteaccess_aware_routes'])) {
338
            $container->setParameter(
339
                'ezpublish.default_router.non_siteaccess_aware_routes',
340
                array_merge(
341
                    $container->getParameter('ezpublish.default_router.non_siteaccess_aware_routes'),
342
                    $config['router']['default_router']['non_siteaccess_aware_routes']
343
                )
344
            );
345
        }
346
    }
347
348
    /**
349
     * Handle public API loading.
350
     *
351
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
352
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
353
     */
354
    private function handleApiLoading(ContainerBuilder $container, FileLoader $loader)
355
    {
356
        // Loading configuration from Core/settings
357
        $coreLoader = new Loader\YamlFileLoader(
358
            $container,
359
            new FileLocator(__DIR__ . '/../../../Publish/Core/settings')
360
        );
361
        $coreLoader->load('repository.yml');
362
        $coreLoader->load('repository/inner.yml');
363
        $coreLoader->load('repository/signalslot.yml');
364
        $coreLoader->load('repository/siteaccessaware.yml');
365
        $coreLoader->load('fieldtype_external_storages.yml');
366
        $coreLoader->load('fieldtypes.yml');
367
        $coreLoader->load('indexable_fieldtypes.yml');
368
        $coreLoader->load('roles.yml');
369
        $coreLoader->load('storage_engines/common.yml');
370
        $coreLoader->load('storage_engines/cache.yml');
371
        $coreLoader->load('storage_engines/legacy.yml');
372
        $coreLoader->load('storage_engines/shortcuts.yml');
373
        $coreLoader->load('search_engines/common.yml');
374
        $coreLoader->load('utils.yml');
375
        $coreLoader->load('io.yml');
376
        $coreLoader->load('policies.yml');
377
        $coreLoader->load('notification.yml');
378
        $coreLoader->load('user_preference.yml');
379
380
        if (!$this->isRichTextBundleEnabled($container)) {
381
            $coreLoader->load('richtext.yml');
382
        }
383
384
        // Public API services
385
        $loader->load('papi.yml');
386
387
        // Built-in field types
388
        $loader->load('fieldtype_services.yml');
389
390
        // Storage engine
391
        $loader->load('storage_engines.yml');
392
    }
393
394
    /**
395
     * Handle templating parameters.
396
     *
397
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
398
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
399
     */
400
    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...
401
    {
402
        $loader->load('templating.yml');
403
    }
404
405
    /**
406
     * Handle session parameters.
407
     *
408
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
409
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
410
     */
411
    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...
412
    {
413
        $loader->load('session.yml');
414
    }
415
416
    /**
417
     * Handle cache parameters.
418
     *
419
     * @param array $config
420
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
421
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
422
     *
423
     * @throws \InvalidArgumentException
424
     */
425
    private function handleCache(array $config, ContainerBuilder $container, FileLoader $loader)
426
    {
427
        $loader->load('cache.yml');
428
429
        $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...
430
        if (isset($config['http_cache']['purge_type'])) {
431
            $container->setParameter('ezpublish.http_cache.purge_type', $config['http_cache']['purge_type']);
432
        }
433
    }
434
435
    /**
436
     * Handle locale parameters.
437
     *
438
     * @param array $config
439
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
440
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
441
     */
442
    private function handleLocale(array $config, ContainerBuilder $container, FileLoader $loader)
443
    {
444
        $loader->load('locale.yml');
445
        $container->setParameter(
446
            'ezpublish.locale.conversion_map',
447
            $config['locale_conversion'] + $container->getParameter('ezpublish.locale.conversion_map')
448
        );
449
    }
450
451
    /**
452
     * Handle helpers.
453
     *
454
     * @param array $config
455
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
456
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
457
     */
458
    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...
459
    {
460
        $loader->load('helpers.yml');
461
    }
462
463
    /**
464
     * Handles relation between SiteAccesses.
465
     * Related SiteAccesses share the same repository and root location id.
466
     *
467
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
468
     */
469
    private function handleSiteAccessesRelation(ContainerBuilder $container)
470
    {
471
        $configResolver = $container->get('ezpublish.config.resolver.core');
472
        $configResolver->setContainer($container);
473
474
        $saRelationMap = array();
475
        $saList = $container->getParameter('ezpublish.siteaccess.list');
476
        // First build the SiteAccess relation map, indexed by repository and rootLocationId.
477
        foreach ($saList as $sa) {
478
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
479
            if (!isset($saRelationMap[$repository])) {
480
                $saRelationMap[$repository] = array();
481
            }
482
483
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
484
            if (!isset($saRelationMap[$repository][$rootLocationId])) {
485
                $saRelationMap[$repository][$rootLocationId] = array();
486
            }
487
            $saRelationMap[$repository][$rootLocationId][] = $sa;
488
        }
489
        $container->setParameter('ezpublish.siteaccess.relation_map', $saRelationMap);
490
491
        // Now build the related SiteAccesses list, based on the relation map.
492
        foreach ($saList as $sa) {
493
            $repository = $configResolver->getParameter('repository', 'ezsettings', $sa);
494
            $rootLocationId = $configResolver->getParameter('content.tree_root.location_id', 'ezsettings', $sa);
495
            $container->setParameter(
496
                "ezsettings.$sa.related_siteaccesses",
497
                $saRelationMap[$repository][$rootLocationId]
498
            );
499
        }
500
    }
501
502
    /**
503
     * @param array $config
504
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
505
     * @param \Symfony\Component\DependencyInjection\Loader\FileLoader $loader
506
     */
507
    private function handleImage(array $config, ContainerBuilder $container, FileLoader $loader)
508
    {
509
        $loader->load('image.yml');
510
511
        $providers = [];
512
        if (isset($config['image_placeholder'])) {
513
            foreach ($config['image_placeholder'] as $name => $value) {
514
                if (isset($providers[$name])) {
515
                    throw new InvalidConfigurationException("A image_placeholder named $name already exists");
516
                }
517
518
                $providers[$name] = $value;
519
            }
520
        }
521
522
        $container->setParameter('image_alias.placeholder_providers', $providers);
523
    }
524
525
    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...
526
    {
527
        $loader->load('url_checker.yml');
528
    }
529
530
    private function buildPolicyMap(ContainerBuilder $container)
531
    {
532
        $policiesBuilder = new PoliciesConfigBuilder($container);
533
        foreach ($this->policyProviders as $provider) {
534
            $provider->addPolicies($policiesBuilder);
535
        }
536
    }
537
538
    /**
539
     * Adds a new policy provider to the internal collection.
540
     * One can call this method from a bundle `build()` method.
541
     *
542
     * ```php
543
     * public function build(ContainerBuilder $container)
544
     * {
545
     *     $ezExtension = $container->getExtension('ezpublish');
546
     *     $ezExtension->addPolicyProvider($myPolicyProvider);
547
     * }
548
     * ```
549
     *
550
     * @since 6.0
551
     *
552
     * @param PolicyProviderInterface $policyProvider
553
     */
554
    public function addPolicyProvider(PolicyProviderInterface $policyProvider)
555
    {
556
        $this->policyProviders[] = $policyProvider;
557
    }
558
559
    /**
560
     * Adds a new config parser to the internal collection.
561
     * One can call this method from a bundle `build()` method.
562
     *
563
     * ```php
564
     * public function build(ContainerBuilder $container)
565
     * {
566
     *     $ezExtension = $container->getExtension('ezpublish');
567
     *     $ezExtension->addConfigParser($myConfigParser);
568
     * }
569
     * ```
570
     *
571
     * @since 6.0
572
     *
573
     * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface $configParser
574
     */
575
    public function addConfigParser(ParserInterface $configParser)
576
    {
577
        $this->configParsers[] = $configParser;
578
    }
579
580
    /**
581
     * Adds new default settings to the internal collection.
582
     * One can call this method from a bundle `build()` method.
583
     *
584
     * ```php
585
     * public function build(ContainerBuilder $container)
586
     * {
587
     *     $ezExtension = $container->getExtension('ezpublish');
588
     *     $ezExtension->addDefaultSettings(
589
     *         __DIR__ . '/Resources/config',
590
     *         ['default_settings.yml']
591
     *     );
592
     * }
593
     * ```
594
     *
595
     * @since 6.0
596
     *
597
     * @param string $fileLocation
598
     * @param array $files
599
     */
600
    public function addDefaultSettings($fileLocation, array $files)
601
    {
602
        $this->defaultSettingsCollection[$fileLocation] = $files;
603
    }
604
605
    public function addSiteAccessConfigurationFilter(SiteAccessConfigurationFilter $filter)
606
    {
607
        $this->siteaccessConfigurationFilters[] = $filter;
608
    }
609
610
    /**
611
     * @param array $config
612
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
613
     */
614
    private function registerUrlAliasConfiguration(array $config, ContainerBuilder $container)
615
    {
616
        if (!isset($config['url_alias'])) {
617
            $config['url_alias'] = ['slug_converter' => []];
618
        }
619
620
        $container->setParameter('ezpublish.url_alias.slug_converter', $config['url_alias']['slug_converter']);
621
    }
622
623
    private function isRichTextBundleEnabled(ContainerBuilder $container)
624
    {
625
        return $container->hasParameter('kernel.bundles')
626
            && array_key_exists(
627
                'EzPlatformRichTextBundle',
628
                $container->getParameter('kernel.bundles')
629
            );
630
    }
631
}
632