LoevgaardDandomainStockExtension::prepend()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 7
cp 0
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\DandomainStockBundle\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
10
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
11
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
12
13
class LoevgaardDandomainStockExtension extends Extension implements PrependExtensionInterface
14
{
15 2
    public function load(array $configs, ContainerBuilder $container)
16
    {
17 2
        $configuration = new Configuration();
18 2
        $config = $this->processConfiguration($configuration, $configs);
19
20 1
        $container->setParameter('loevgaard_dandomain_stock.dandomain_order_state_ids', $config['dandomain_order_state_ids']);
21
22 1
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
23 1
        $loader->load('services.yml');
24 1
    }
25
26
    public function prepend(ContainerBuilder $container)
27
    {
28
        $ext = 'doctrine';
29
30
        if (!$container->hasExtension($ext)) {
31
            throw new \LogicException('You need to enable the doctrine bundle');
32
        }
33
34
        $container->prependExtensionConfig($ext, [
35
            'orm' => [
36
                'mappings' => [
37
                    'Loevgaard\\DandomainStock\\Entity' => [
38
                        'type' => 'annotation',
39
                        'dir' => '%kernel.project_dir%/vendor/loevgaard/dandomain-stock-entities/src/Entity',
40
                        'is_bundle' => false,
41
                        'prefix' => 'Loevgaard\\DandomainStock\\Entity',
42
                    ],
43
                ],
44
            ],
45
        ]);
46
    }
47
}
48