Completed
Push — symfony4 ( c6a911...b0a2f3 )
by
unknown
37:19
created

ReplaceServiceContainerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the FieldTypeCollectionPass class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Base\Container\Compiler;
10
11
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
15
/**
16
 * This Pass overrides all services to be public.
17
 *
18
 * It is a workaround to the change in Symfony 4 which makes all services private by default.
19
 * Our integration tests are not prepared for this as they get services directly from the Container.
20
 *
21
 * WARNING! DO NOT USE IT IN YOUR APPLICATION.
22
 *
23
 * Inspired by \Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass
24
 */
25
class ReplaceServiceContainerPass implements CompilerPassInterface
26
{
27
    /**
28
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $containerBuilder
29
     */
30
    public function process(ContainerBuilder $containerBuilder)
31
    {
32
        foreach ($containerBuilder->getDefinitions() as $id => $definition) {
33
            $methodCalls = $definition->getMethodCalls();
34
            foreach ($methodCalls as $callIndex => $methodCall) {
35
                if ($methodCall[0] !== 'setContainer') {
36
                    continue;
37
                }
38
            }
39
        }
40
    }
41
}
42