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

LegacyServicePass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 4
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