Completed
Pull Request — master (#89)
by
unknown
62:49
created

ListController::getInitialDataAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

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 8
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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\ElasticsearchBundle\Result\DocumentIterator;
15
use ONGR\ElasticsearchBundle\Result\Result;
16
use ONGR\ElasticsearchDSL\Aggregation\TermsAggregation;
17
use ONGR\ElasticsearchBundle\Service\Repository;
18
use ONGR\FilterManagerBundle\Filter\ViewData;
19
use ONGR\FilterManagerBundle\Search\SearchResponse;
20
use ONGR\TranslationsBundle\Document\Translation;
21
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
22
use Symfony\Component\HttpFoundation\JsonResponse;
23
use Symfony\Component\HttpFoundation\Request;
24
use Symfony\Component\HttpFoundation\Response;
25
26
/**
27
 * Controller used for displaying translations.
28
 */
29
class ListController extends Controller
30
{
31
    /**
32
     * Returns a JsonResponse with available locales and active tags
33
     * @return JsonResponse
34
     */
35
    public function getInitialDataAction()
36
    {
37
        $out = [];
38
        $out['locales'] = $this->getParameter('ongr_translations.managed_locales');
39
        $out['tags'] = $this->get('ongr_translations.translation_manager')->getTags();
40
        $out['domains'] = $this->get('ongr_translations.translation_manager')->getDomains();
41
        return new JsonResponse($out);
42
    }
43
44
    /**
45
     * @param Request $request
46
     * @return JsonResponse
47
     */
48
    public function getTranslationsAction(Request $request)
49
    {
50
        /** @var SearchResponse $filterResponse */
51
        $filterResponse = $this->get('ongr_translations.filter_manager')->handleRequest($request);
52
53
        return new JsonResponse(iterator_to_array($filterResponse->getResult()));
54
    }
55
56
    /**
57
     * Renders view with filter manager response.
58
     *
59
     * @param Request $request Request.
60
     *
61
     * @return Response
62
     */
63
    public function listAction(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...
64
    {
65
        return $this->render(
66
            'ONGRTranslationsBundle:List:list.html.twig',
67
            ['locales' => $this->getParameter('ongr_translations.managed_locales')]
68
        );
69
    }
70
}
71