1
|
|
|
<?php namespace Modules\Translation\Http\Controllers\Admin; |
2
|
|
|
|
3
|
|
|
use Illuminate\Http\Request; |
4
|
|
|
use Modules\Core\Http\Controllers\Admin\AdminBaseController; |
5
|
|
|
use Modules\Translation\Entities\TranslationTranslation; |
6
|
|
|
use Modules\Translation\Exporters\TranslationsExporter; |
7
|
|
|
use Modules\Translation\Http\Requests\ImportTranslationsRequest; |
8
|
|
|
use Modules\Translation\Importers\TranslationsImporter; |
9
|
|
|
use Modules\Translation\Repositories\TranslationRepository; |
10
|
|
|
use Modules\Translation\Services\TranslationsService; |
11
|
|
|
use Pingpong\Modules\Facades\Module; |
12
|
|
|
|
13
|
|
|
class TranslationController extends AdminBaseController |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var TranslationsService |
17
|
|
|
*/ |
18
|
|
|
private $translationsService; |
19
|
|
|
/** |
20
|
|
|
* @var TranslationRepository |
21
|
|
|
*/ |
22
|
|
|
private $translation; |
23
|
|
|
|
24
|
|
|
public function __construct(TranslationsService $translationsService, TranslationRepository $translation) |
25
|
|
|
{ |
26
|
|
|
parent::__construct(); |
27
|
|
|
|
28
|
|
|
$this->translationsService = $translationsService; |
29
|
|
|
$this->translation = $translation; |
30
|
|
|
$this->requireAssets(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Display a listing of the resource. |
35
|
|
|
* |
36
|
|
|
* @return Response |
37
|
|
|
*/ |
38
|
|
|
public function index() |
39
|
|
|
{ |
40
|
|
|
$translations = $this->translationsService->getFileAndDatabaseMergedTranslations(); |
41
|
|
|
|
42
|
|
|
return view('translation::admin.translations.index', compact('translations')); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function update(TranslationTranslation $translationTranslation, Request $request) |
46
|
|
|
{ |
47
|
|
|
$this->translation->updateTranslationToValue($translationTranslation, $request->get('oldValue')); |
48
|
|
|
|
49
|
|
|
return redirect()->route('admin.translation.translation.index')->withSuccess('Translation saved.'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function export(TranslationsExporter $exporter) |
53
|
|
|
{ |
54
|
|
|
$exporter->export(); |
55
|
|
|
|
56
|
|
|
return redirect()->route('admin.translation.translation.index')->withSuccess(trans('translation::translations.Translations exported')); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function import(ImportTranslationsRequest $request, TranslationsImporter $importer) |
60
|
|
|
{ |
61
|
|
|
$importer->import($request->file('file')); |
|
|
|
|
62
|
|
|
|
63
|
|
|
return redirect()->route('admin.translation.translation.index')->withSuccess(trans('translation::translations.Translations imported')); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
private function requireAssets() |
67
|
|
|
{ |
68
|
|
|
$this->assetManager->addAsset('bootstrap-editable.css', Module::asset('translation:vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css')); |
69
|
|
|
$this->assetManager->addAsset('bootstrap-editable.js', Module::asset('translation:vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js')); |
70
|
|
|
$this->assetPipeline->requireJs('bootstrap-editable.js'); |
71
|
|
|
$this->assetPipeline->requireCss('bootstrap-editable.css'); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.