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) |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
return $this->render( |
60
|
|
|
'ONGRTranslationsBundle:List:list.html.twig', |
61
|
|
|
['locales' => $this->getParameter('ongr_translations.managed_locales')] |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.