|
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
|
|
|
return response()->make($exporter->export(), [ |
|
|
|
|
|
|
55
|
|
|
"Content-Type" => "application/csv", |
|
56
|
|
|
"Content-Disposition" => "attachment; filename=export_{$exporter->getFileName()}.csv", |
|
57
|
|
|
"Pragma" => "no-cache" |
|
58
|
|
|
]); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function import(ImportTranslationsRequest $request, TranslationsImporter $importer) |
|
62
|
|
|
{ |
|
63
|
|
|
$importer->import($request->file('file')); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
return redirect()->route('admin.translation.translation.index')->withSuccess(trans('translation::translations.Translations imported')); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
private function requireAssets() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->assetManager->addAsset('bootstrap-editable.css', Module::asset('translation:vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css')); |
|
71
|
|
|
$this->assetManager->addAsset('bootstrap-editable.js', Module::asset('translation:vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js')); |
|
72
|
|
|
$this->assetPipeline->requireJs('bootstrap-editable.js'); |
|
73
|
|
|
$this->assetPipeline->requireCss('bootstrap-editable.css'); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: