Completed
Pull Request — master (#6)
by Antonio
03:35
created

LegacyServicePass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 1
1
<?php
2
/**
3
 * TODO: remove this manipulation when the support for 2.1 is dropped
4
 */
5
6
namespace Flagbit\Bundle\ProductClonerBundle\DependencyInjection\Compiler;
7
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class LegacyServicePass implements CompilerPassInterface
13
{
14
    public function process(ContainerBuilder $container)
15
    {
16
17
        if (!$container->hasDefinition('pim_catalog.builder.variant_product')) {
18
            $productControllerService = $container->getDefinition('flagbit_product_cloner.controller.product');
19
20
            foreach ($productControllerService->getArguments() as $key => $argument) {
21
                if ((string)$argument === 'pim_catalog.builder.variant_product') {
22
                    $productControllerService->setArgument($key, new Reference('pim_catalog.builder.product'));
23
                }
24
            }
25
        }
26
    }
27
}
28