1 | <?php namespace Modules\Translation\Http\Controllers\Api; |
||
8 | class TranslationController extends Controller |
||
9 | { |
||
10 | /** |
||
11 | * @var TranslationRepository |
||
12 | */ |
||
13 | private $translation; |
||
14 | |||
15 | public function __construct(TranslationRepository $translation) |
||
19 | |||
20 | public function update(Request $request) |
||
21 | { |
||
22 | $this->translation->saveTranslationForLocaleAndKey( |
||
23 | $request->get('locale'), |
||
24 | $request->get('key'), |
||
25 | $request->get('value') |
||
26 | ); |
||
27 | } |
||
28 | |||
29 | public function clearCache() |
||
33 | |||
34 | public function revisions(Request $request) |
||
35 | { |
||
36 | $translation = $this->translation->findTranslationByKey($request->get('key')); |
||
37 | $translation = $translation->translate($request->get('locale')); |
||
38 | |||
39 | if (null === $translation) { |
||
40 | return response()->json(['<tr><td>' . trans('translation::translations.No Revisions yet') . '</td></tr>']); |
||
41 | } |
||
42 | |||
43 | return response()->json($this->formatRevisionHistory($translation->revisionHistory)); |
||
44 | } |
||
45 | |||
46 | private function formatRevisionHistory(Collection $revisionHistory) |
||
60 | |||
61 | private function getRevisionTemplate($history) |
||
62 | { |
||
77 | |||
78 | private function getCreatedRevisionTemplate($history) |
||
93 | } |
||
94 |