RegisterCompilerPass::getMethodName()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Zenstruck\BackupBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
abstract class RegisterCompilerPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 10
    final public function process(ContainerBuilder $container)
18
    {
19 10
        $definitionName = $this->getDefinitionName();
20
21 10
        if (false === $container->hasDefinition($definitionName)) {
22 5
            return;
23
        }
24
25 5
        $definition = $container->getDefinition($definitionName);
26 5
        $taggedServices = $container->findTaggedServiceIds($this->getTagName());
27
28 5
        foreach (array_keys($taggedServices) as $id) {
29 5
            $definition->addMethodCall($this->getMethodName(), array(new Reference($id)));
30
        }
31 5
    }
32
33
    /**
34
     * @return string
35
     */
36
    abstract protected function getDefinitionName();
37
38
    /**
39
     * @return string
40
     */
41
    abstract protected function getTagName();
42
43
    /**
44
     * @return string
45
     */
46
    abstract protected function getMethodName();
47
}
48