ExportCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleDataProviders() 0 9 2
A process() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2020-2025 Iain Cambridge
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
10
 * the Free Software Foundation, either version 2.1 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
namespace Parthenon\Export\Compiler;
23
24
use Parthenon\Common\Compiler\AbstractCompilerPass;
25
use Parthenon\Export\Exporter\ExporterManager;
26
use Parthenon\Export\Normaliser\NormaliserManager;
27
use Symfony\Component\DependencyInjection\ContainerBuilder;
28
29
final class ExportCompilerPass extends AbstractCompilerPass
30
{
31
    public function process(ContainerBuilder $container)
32
    {
33
        $this->handle($container, NormaliserManager::class, 'parthenon.export.normaliser', 'addNormaliser');
34
        $this->handle($container, ExporterManager::class, 'parthenon.export.exporter', 'addExporter');
35
36
        $this->handleDataProviders($container);
37
    }
38
39
    public function handleDataProviders(ContainerBuilder $container)
40
    {
41
        $definitions = $container->findTaggedServiceIds('parthenon.export.data_provider');
42
43
        foreach ($definitions as $id => $definitionData) {
44
            $definition = $container->getDefinition($id);
45
            $definition->setPublic(true);
46
            // Just to be safe, even though it should be the same object returned by reference, overwrite it.
47
            $container->setDefinition($id, $definition);
48
        }
49
    }
50
}
51