Completed
Push — master ( cc7cf3...f7d42d )
by Kamil
19s
created

WinzouStateMachinePass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler;
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
10
11
/**
12
 * Marks WinzouStateMachineBundle's services as public for compatibility with both Symfony 3.4 and 4.0+.
13
 *
14
 * @see https://github.com/winzou/StateMachineBundle/pull/44
15
 */
16
final class WinzouStateMachinePass implements CompilerPassInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function process(ContainerBuilder $container): void
22
    {
23
        foreach (['sm.factory', 'sm.callback_factory', 'sm.callback.cascade_transition'] as $id) {
24
            try {
25
                $container->findDefinition($id)->setPublic(true);
26
            } catch (ServiceNotFoundException $exception) {}
27
        }
28
    }
29
}
30