Completed
Push — master ( c7deb4...314746 )
by Beñat
09:20 queued 06:49
created

RoutesPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 2
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\DependencyInjection\Compiler;
14
15
use BenGorFile\FileBundle\DependencyInjection\Compiler\Routing\DownloadRoutesLoaderBuilder;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19
/**
20
 * Load routes compiler pass.
21
 *
22
 * Based on configuration the routes are created dynamically.
23
 *
24
 * @author Beñat Espiña <[email protected]>
25
 */
26
class RoutesPass implements CompilerPassInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function process(ContainerBuilder $container)
32
    {
33
        $config = $container->getParameter('bengor_file.config');
34
35
        $downloadConfiguration = [];
36
37
        foreach ($config['file_class'] as $key => $file) {
38
            $downloadConfiguration[$key] = [
39
                'storage'            => $file['storage'],
40
                'upload_destination' => $file['upload_destination'],
41
                'upload_dir'         => $file['upload_dir'],
42
            ];
43
        }
44
45
        (new DownloadRoutesLoaderBuilder($container, $downloadConfiguration))->build();
46
    }
47
}
48