Completed
Push — master ( 5acd05...f1dd04 )
by Beñat
02:15 queued 34s
created

GetFilesController::byIdsAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
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\Controller\Api;
14
15
use BenGorFile\File\Application\Query\ListFilesOfIdsQuery;
16
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
17
use Symfony\Component\HttpFoundation\JsonResponse;
18
use Symfony\Component\HttpFoundation\Request;
19
20
/**
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
class GetFilesController extends Controller
24
{
25
    public function byIdsAction(Request $request, $fileClass)
26
    {
27
        $ids = $request->get('ids');
28
        if (!$ids) {
29
            return new JsonResponse(['error' => 'The "ids" parameter not found'], 400);
30
        }
31
32
        $ids = explode(',', $ids);
33
34
        return new JsonResponse(
35
            $this->get(
36
                'bengor.file.application.query.list_' . $fileClass . 'files_of_ids'
37
            )->__invoke(new ListFilesOfIdsQuery($ids))
38
        );
39
    }
40
}
41