• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmc-eu / twigx-bundle / 4329044787

pending completion
4329044787

push

github

literat
Release 3.2.0

80 of 94 relevant lines covered (85.11%)

25.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/DependencyInjection/CompilerPass/OverrideServiceCompilerPass.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Lmc\TwigXBundle\DependencyInjection\CompilerPass;
6

7
use Lmc\TwigXBundle\Compiler\ComponentLexer;
8
use Lmc\TwigXBundle\DependencyInjection\TwigXExtension;
9
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Definition;
12
use Symfony\Component\DependencyInjection\Reference;
13

14
class OverrideServiceCompilerPass implements CompilerPassInterface
15
{
16
    public function process(ContainerBuilder $container): void
17
    {
18
        $twigDefinition = $container->getDefinition('twig');
16✔
19

20
        $twigLoaderDefinition = $container->findDefinition('twig.loader');
16✔
21

22
        /** @var array<string> $paths */
23
        $paths = $container->getParameter(TwigXExtension::PARAMETER_PATHS);
16✔
24
        $pathAlias = $container->getParameter(TwigXExtension::PARAMETER_PATH_ALIAS);
16✔
25

26
        $this->addGlobPath($twigLoaderDefinition, TwigXExtension::DEFAULT_PARTIALS_PATH, TwigXExtension::DEFAULT_PARTIALS_ALIAS);
16✔
27

28
        foreach ($paths as $path) {
16✔
29
            $twigLoaderDefinition->addMethodCall('addPath', [$path, $pathAlias]);
12✔
30

31
            if ($path === TwigXExtension::DEFAULT_COMPONENTS_PATH) {
12✔
32
                $this->addGlobPath($twigLoaderDefinition, $path, TwigXExtension::DEFAULT_PATH_ALIAS);
×
33
            }
34
        }
35

36
        $twigDefinition->addMethodCall('setLexer', [new Reference(ComponentLexer::class)]);
16✔
37
    }
38

39
    private function addGlobPath(Definition $twigLoaderDefinition, string $path, string $alias): void
40
    {
41
        if ($paths = glob($path, GLOB_ONLYDIR)) {
16✔
42
            foreach ($paths as $path) {
16✔
43
                $twigLoaderDefinition->addMethodCall('addPath', [$path, $alias]);
16✔
44
            }
45
        }
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc