Passed
Push — di ( 61d74f...f00c6d )
by Arnaud
15:03 queued 11:43
created

StepPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 3
1
<?php
2
3
/**
4
 * This file is part of Cecil.
5
 *
6
 * (c) Arnaud Ligny <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cecil\DependencyInjection\CompilerPass;
15
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19
/**
20
 * Compiler pass for automatic registration of build steps.
21
 *
22
 * This compiler pass finds all services tagged with 'cecil.step'
23
 * and makes them available for the build process.
24
 * Steps are executed in the order defined in Builder::STEPS constant.
25
 */
26
class StepPass implements CompilerPassInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function process(ContainerBuilder $container): void
32
    {
33
        // Si le Builder n'existe pas, on ne fait rien
34
        if (!$container->has('Cecil\Builder')) {
35
            return;
36
        }
37
38
        $taggedServices = $container->findTaggedServiceIds('cecil.step');
39
40
        // Pour l'instant, on s'assure simplement que les steps sont bien enregistrés
41
        // L'ordre d'exécution est géré par Builder::STEPS
42
        // Cette passe pourrait être étendue pour permettre une configuration plus dynamique
43
44
        foreach ($taggedServices as $id => $tags) {
45
            $definition = $container->findDefinition($id);
46
47
            // S'assurer que les steps sont publics pour être accessibles par le Builder
48
            $definition->setPublic(true);
49
        }
50
    }
51
}
52