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

AlpixelMediaExtension::prepend()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
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