Passed
Push — master ( a333bd...23d91d )
by Dmitrii
07:12 queued 04:24
created

KarserRecaptcha3Extension::prepend()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 2
c 1
b 1
f 0
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Karser\Recaptcha3Bundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
8
use Symfony\Component\DependencyInjection\Loader;
9
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
10
11
class KarserRecaptcha3Extension extends ConfigurableExtension implements PrependExtensionInterface
12 5
{
13
    public function loadInternal(array $configs, ContainerBuilder $container)
14 5
    {
15 5
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
16 5
        $loader->load('services.yml');
17 5
        foreach ($configs as $key => $value) {
18
            $container->setParameter('karser_recaptcha3.'.$key, $value);
19 5
        }
20 5
    }
21
22 5
    public function prepend(ContainerBuilder $container)
23
    {
24 5
        if ($container->hasExtension('twig')) {
25 5
            // inject template
26 5
            $container->prependExtensionConfig('twig', ['form_themes' => ['@KarserRecaptcha3/Form/karser_recaptcha3_widget.html.twig']]);
27 5
        }
28
    }
29
}
30