Passed
Push — main ( 987cb0...4f2490 )
by De Cramer
02:59
created

EtlDownloadFileController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
4
namespace Oliverde8\PhpEtlBundle\Controller\Admin;
5
6
use Oliverde8\PhpEtlBundle\Entity\EtlExecution;
7
use Oliverde8\PhpEtlBundle\Security\EtlExecutionVoter;
8
use Oliverde8\PhpEtlBundle\Services\ChainWorkDirManager;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
0 ignored issues
show
Bug introduced by
The type Sensio\Bundle\FrameworkE...guration\ParamConverter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\HttpFoundation\Response;
13
use Symfony\Component\Routing\Annotation\Route;
14
15
class EtlDownloadFileController extends AbstractController
16
{
17
    /** @var ChainWorkDirManager */
18
    protected $chainWorkDirManager;
19
20
    /**
21
     * EtlDownloadFileController constructor.
22
     * @param ChainWorkDirManager $chainWorkDirManager
23
     */
24
    public function __construct(ChainWorkDirManager $chainWorkDirManager)
25
    {
26
        $this->chainWorkDirManager = $chainWorkDirManager;
27
    }
28
29
    /**
30
     * @Route("/etl/execution/download", name="etl_execution_download_file")
31
     * @ParamConverter(name="execution", Class="Oliverde8PhpEtlBundle:EtlExecution")
32
     */
33
    public function index(EtlExecution $execution, string $filename): Response
34
    {
35
        $this->denyAccessUnlessGranted(EtlExecutionVoter::DOWNLOAD, EtlExecution::class);
36
37
        //TODO add Acl here for future proofing.
38
        return $this->file(
39
            $this->chainWorkDirManager->getWorkDir($execution) . "/" . $filename,
40
            "execution-{$execution->getName()}-{$execution->getId()}-" . $filename
41
        );
42
    }
43
}
44