Completed
Pull Request — 0.3 (#13)
by jean
14:52
created

DeprecatedStepCompilerPass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 15 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Darkilliant\ProcessBundle\DependencyInjection\CompilerPass;
6
7
use Darkilliant\ProcessBundle\Step\AbstractConfigurableStep;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
class DeprecatedStepCompilerPass implements CompilerPassInterface
12
{
13
    public function process(ContainerBuilder $container)
14
    {
15
        $config = $container->getParameter('darkilliant_process');
16
17
        foreach ($config['process'] as $processName => $process) {
18
            $deprecateds = [];
19
            foreach ($process['steps'] as $step) {
20
                if (class_exists($step['service']) && true === call_user_func_array([$step['service'], 'isDeprecated'], [])) {
21
                    $deprecateds[] = $step['service'];
22
                }
23
            }
24
            $config['process'][$processName]['deprecated'] = $deprecateds;
25
        }
26
27
        $container->setParameter('darkilliant_process', $config);
28
    }
29
}
30