Passed
Push — master ( 8bedb0...30cbc3 )
by Christian
02:47
created

Core23FormExtensionsExtension::prepend()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\FormExtensions\Bridge\Symfony\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
17
use Symfony\Component\DependencyInjection\Loader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
final class Core23FormExtensionsExtension extends Extension implements PrependExtensionInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function load(array $configs, ContainerBuilder $container): void
26
    {
27
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
28
        $loader->load('form.xml');
29
        $loader->load('validator.xml');
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function prepend(ContainerBuilder $container): void
36
    {
37
        if ($container->hasExtension('twig')) {
38
            // add custom form widgets
39
            $container->prependExtensionConfig('twig', [
40
                'form_themes' => ['@Core23FormExtensions/Form/widgets.html.twig'],
41
            ]);
42
        }
43
    }
44
}
45