Completed
Push — master ( 31a9ea...5d6556 )
by
unknown
03:38 queued 11s
created

TwigStringExtensionCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\DependencyInjection\Compiler;
15
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Definition;
19
use Twig\Extra\String\StringExtension;
20
21
final class TwigStringExtensionCompilerPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container): void
24
    {
25
        foreach ($container->findTaggedServiceIds('twig.extension') as $id => $attributes) {
26
            if (StringExtension::class === $container->getDefinition($id)->getClass()) {
27
                return;
28
            }
29
        }
30
31
        $definition = new Definition(StringExtension::class);
32
        $definition->addTag('twig.extension');
33
        $container->setDefinition(StringExtension::class, $definition);
34
    }
35
}
36