DoSSettingsExtension   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 0
cbo 3
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBundleConfiguration() 0 4 1
B prepend() 0 27 6
1
<?php
2
3
namespace DoS\SettingsBundle\DependencyInjection;
4
5
use DoS\ResourceBundle\DependencyInjection\AbstractResourceExtension;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
9
10
class DoSSettingsExtension extends AbstractResourceExtension implements PrependExtensionInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected function getBundleConfiguration()
16
    {
17
        return new Configuration();
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function prepend(ContainerBuilder $container)
24
    {
25
        $configs = $container->getExtensionConfig($this->getAlias());
26
        // use the Configuration class to generate a config array with
27
        $config = $this->processConfiguration(new Configuration(), $configs);
28
29
        // no need for sylius
30
        foreach ($config['resources'] as &$resources) {
31
            foreach($resources as &$classes) {
32
                if (array_key_exists('interface', $classes)) {
33
                    unset($classes['interface']);
34
                }
35
36
                if (array_key_exists('form', $classes)) {
37
                    unset($classes['form']);
38
                }
39
            }
40
41
            if (array_key_exists('validation_groups', $resources)) {
42
                unset($resources['validation_groups']);
43
            }
44
        }
45
46
        $container->prependExtensionConfig('sylius_settings', array(
47
            'resources' => $config['resources'],
48
        ));
49
    }
50
}
51