Completed
Push — master ( 5abf4c...fec7e8 )
by
unknown
36:16 queued 36:12
created

ListController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\TranslationsBundle\Controller;
13
14
use ONGR\FilterManagerBundle\Search\SearchResponse;
15
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
16
use Symfony\Component\HttpFoundation\JsonResponse;
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\Response;
19
20
/**
21
 * Controller used for displaying translations.
22
 */
23
class ListController extends Controller
24
{
25
    /**
26
     * Returns a JsonResponse with available locales and active tags
27
     * @return JsonResponse
28
     */
29
    public function getInitialDataAction()
30
    {
31
        $out = [];
32
        $out['locales'] = $this->getParameter('ongr_translations.managed_locales');
33
        $out['tags'] = $this->get('ongr_translations.translation_manager')->getTags();
34
        $out['domains'] = $this->get('ongr_translations.translation_manager')->getDomains();
35
        return new JsonResponse($out);
36
    }
37
38
    /**
39
     * @param Request $request
40
     * @return JsonResponse
41
     */
42
    public function listAction(Request $request)
43
    {
44
        /** @var SearchResponse $filterResponse */
45
        $filterResponse = $this->get('ongr_translations.filter_manager')->handleRequest($request);
46
47
        return new JsonResponse(iterator_to_array($filterResponse->getResult()));
48
    }
49
50
    /**
51
     * Renders view with filter manager response.
52
     *
53
     * @param Request $request Request.
54
     *
55
     * @return Response
56
     */
57
    public function indexAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
        return $this->render(
60
            'ONGRTranslationsBundle:List:list.html.twig',
61
            ['locales' => $this->getParameter('ongr_translations.managed_locales')]
62
        );
63
    }
64
}
65