1 | <?php |
||
8 | class LocalesAreInstalled implements Check |
||
9 | { |
||
10 | /** @var Collection */ |
||
11 | protected $missingLocales; |
||
12 | |||
13 | /** @var string|null */ |
||
14 | protected $message; |
||
15 | |||
16 | /** @var SystemFunctions */ |
||
17 | protected $systemFunctions; |
||
18 | |||
19 | /** |
||
20 | * LocalesAreInstalled constructor. |
||
21 | * |
||
22 | * @param SystemFunctions $systemFunctions |
||
23 | */ |
||
24 | 24 | public function __construct(SystemFunctions $systemFunctions) |
|
28 | |||
29 | /** |
||
30 | * The name of the check. |
||
31 | * |
||
32 | * @param array $config |
||
33 | * @return string |
||
34 | */ |
||
35 | public function name(array $config): string |
||
39 | |||
40 | /** |
||
41 | * Perform the actual verification of this check. |
||
42 | * |
||
43 | * @param array $config |
||
44 | * @return bool |
||
45 | */ |
||
46 | 24 | public function check(array $config): bool |
|
47 | { |
||
48 | 24 | $this->missingLocales = new Collection(array_get($config, 'required_locales', [])); |
|
|
|||
49 | 24 | if ($this->missingLocales->isEmpty()) { |
|
50 | 4 | return true; |
|
51 | } |
||
52 | |||
53 | 20 | if (!$this->systemFunctions->isFunctionAvailable('shell_exec')) { |
|
54 | 4 | $this->message = trans('self-diagnosis::checks.locales_are_installed.message.shell_exec_not_available'); |
|
55 | 4 | return false; |
|
56 | } |
||
57 | |||
58 | 16 | if ($this->systemFunctions->isWindowsOperatingSystem()) { |
|
59 | 4 | $this->message = trans('self-diagnosis::checks.locales_are_installed.message.cannot_run_on_windows'); |
|
60 | 4 | return false; |
|
61 | } |
||
62 | |||
63 | 12 | $locales = $this->systemFunctions->callShellExec('locale -a'); |
|
64 | 12 | if ($locales === null || $locales === '') { |
|
65 | 4 | $this->message = trans('self-diagnosis::checks.locales_are_installed.message.locale_command_not_available'); |
|
66 | 4 | return false; |
|
67 | } |
||
68 | |||
69 | 8 | $locales = explode("\n" , $locales); |
|
70 | |||
71 | $this->missingLocales = $this->missingLocales->reject(function ($loc) use ($locales) { |
||
72 | 8 | return in_array($loc, $locales); |
|
73 | 8 | }); |
|
74 | |||
75 | 8 | return $this->missingLocales->isEmpty(); |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * The error message to display in case the check does not pass. |
||
80 | * |
||
81 | * @param array $config |
||
82 | * @return string |
||
83 | */ |
||
84 | 16 | public function message(array $config): string |
|
94 | } |
||
95 |
This function has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.