Completed
Push — master ( c92ef6...3f980f )
by
unknown
13:33
created

ExtensionRemotePass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 24
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Extensionmanager\DependencyInjection;
19
20
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use TYPO3\CMS\Extensionmanager\Remote\RemoteRegistry;
23
24
/**
25
 * @internal
26
 */
27
final class ExtensionRemotePass implements CompilerPassInterface
28
{
29
    private $tagName;
30
31
    public function __construct(string $tagName)
32
    {
33
        $this->tagName = $tagName;
34
    }
35
36
    public function process(ContainerBuilder $container): void
37
    {
38
        $remoteRegistryDefinition = $container->findDefinition(RemoteRegistry::class);
39
40
        foreach ($container->findTaggedServiceIds($this->tagName) as $id => $tags) {
41
            $definition = $container->findDefinition($id);
42
            $definition->setPublic(true);
43
            $configuration = [];
44
45
            foreach ($tags as $attributes) {
46
                $configuration['default'] = (bool)($attributes['default'] ?? false);
47
                $configuration['enabled'] = (bool)($attributes['enabled'] ?? true);
48
            }
49
50
            $remoteRegistryDefinition->addMethodCall('registerRemote', [$id, $configuration]);
51
        }
52
    }
53
}
54