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

DownloadRoutesLoader::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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\Routing;
14
15
use Symfony\Component\Routing\Route;
16
17
/**
18
 * Download routes loader.
19
 *
20
 * @author Beñat Espiña <[email protected]>
21
 */
22
class DownloadRoutesLoader extends RoutesLoader
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function supports($resource, $type = null)
28
    {
29
        return 'bengor_file_download' === $type;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    protected function register($file, array $config)
36
    {
37
        $this->routes->add(
38
            'bengor_file_' . $file . '_download',
39
            new Route(
40
                $config['upload_dir'] . '/{filename}',
41
                [
42
                    '_controller'       => 'BenGorFileBundle:Download:' . $config['storage'],
43
                    'uploadDestination' => $config['upload_destination'],
44
                ],
45
                [],
46
                [],
47
                '',
48
                [],
49
                ['GET']
50
            )
51
        );
52
    }
53
}
54