Completed
Push — master ( 20fbc5...e0c1a4 )
by Benjamin
02:38
created

AlpixelMediaExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 11 1
A prepend() 0 9 2
1
<?php
2
3
namespace Alpixel\Bundle\MediaBundle\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\Extension;
10
11
/**
12
 * This is the class that loads and manages your bundle configuration.
13
 *
14
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
15
 */
16
class AlpixelMediaExtension extends Extension implements PrependExtensionInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function load(array $configs, ContainerBuilder $container)
22
    {
23
        $configuration = new Configuration();
24
        $config = $this->processConfiguration($configuration, $configs);
25
26
        $container->setParameter('alpixel_media.upload_folder', $config['upload_folder']);
27
        $container->setParameter('alpixel_media.allowed_mimetypes', $config['allowed_mimetypes']);
28
29
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
30
        $loader->load('services.yml');
31
    }
32
33
    public function prepend(ContainerBuilder $container)
34
    {
35
        $parser = new Parser();
36
        $config = $parser->parse(file_get_contents(__DIR__ . '/../Resources/config/config.yml'));
37
38
        foreach ($config as $key => $configuration) {
39
            $container->prependExtensionConfig($key, $configuration);
40
        }
41
    }
42
}
43