1 | <?php |
||||
2 | |||||
3 | namespace HexMakina\kadro\Controllers; |
||||
4 | |||||
5 | use HexMakina\LocalFS\Text\JSON; |
||||
6 | |||||
7 | class Traduko extends \HexMakina\kadro\Controllers\ORM |
||||
8 | { |
||||
9 | |||||
10 | public const JSON_FILENAME = 'user_interface_{LANGUAGE}.json'; |
||||
11 | |||||
12 | public function authorize($permission = null): bool |
||||
13 | { |
||||
14 | return parent::authorize('group_admin'); |
||||
15 | } |
||||
16 | |||||
17 | public function routeBack($route_name = null, $route_params = []): string |
||||
18 | { |
||||
19 | return $this->router()->hyp('traduko'); |
||||
20 | } |
||||
21 | |||||
22 | public function update_file($lang = 'fra') |
||||
23 | { |
||||
24 | try { |
||||
25 | $locale_path = $this->get('settings.locale.json_path'); |
||||
26 | self::create_file($locale_path, $lang); |
||||
27 | |||||
28 | $this->logger()->notice($this->l('KADRO_SYSTEM_FILE_UPDATED')); |
||||
29 | } catch (\Exception $e) { |
||||
30 | $this->logger()->warning($this->l('KADRO_SYSTEM_FILE_UPDATED')); |
||||
31 | } |
||||
32 | $this->router()->hop('traduko'); |
||||
33 | } |
||||
34 | |||||
35 | public static function create_file($locale_path, $lang) |
||||
36 | { |
||||
37 | $res = $this->modelClassName()::filter(['lang' => $lang]); |
||||
38 | $assoc = []; |
||||
39 | foreach ($res as $id => $trad) { |
||||
40 | if (!isset($assoc[$trad->kategorio])) { |
||||
41 | $assoc[$trad->kategorio] = []; |
||||
42 | } |
||||
43 | if (!isset($assoc[$trad->kategorio][$trad->sekcio])) { |
||||
44 | $assoc[$trad->kategorio][$trad->sekcio] = []; |
||||
45 | } |
||||
46 | |||||
47 | $assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang; |
||||
48 | } |
||||
49 | |||||
50 | $file_path = str_replace('{LANGUAGE}', $lang, $locale_path); |
||||
51 | |||||
52 | $file = new JSON($file_path, 'w+'); |
||||
53 | $file->set_content(JSON::from_php($assoc)); |
||||
54 | } |
||||
55 | |||||
56 | public static function init($locale_path) |
||||
57 | { |
||||
58 | $languages = array_keys(array_slice(Traduko::inspect(Traduko::relationalMappingName())->columns(), 4)); |
||||
0 ignored issues
–
show
The method
relationalMappingName() does not exist on HexMakina\kadro\Controllers\Traduko .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
59 | foreach ($languages as $l) { |
||||
60 | self::create_file($locale_path, $l); |
||||
61 | } |
||||
62 | |||||
63 | return $languages; |
||||
64 | } |
||||
65 | } |
||||
66 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.