14
14
namespace OpCacheGUI \OpCache ;
15
15
16
16
use OpCacheGUI \Format \Byte ;
17
- use OpCacheGUI \I18n \FileTranslator ;
17
+ use OpCacheGUI \I18n \Translator ;
18
18
19
19
/**
20
20
* Container for the current status of OpCache
@@ -37,6 +37,11 @@ class Status
37
37
*/
38
38
private $ byteFormatter ;
39
39
40
+ /**
41
+ * @var \OpCacheGUI\I18n\Translator A translator
42
+ */
43
+ private $ translator ;
44
+
40
45
/**
41
46
* @var array The (unfiltered) output of opcache_get_status()
42
47
*/
@@ -45,12 +50,14 @@ class Status
45
50
/**
46
51
* Creates instance
47
52
*
48
- * @param \OpCacheGUI\Format\Byte $byteFormatter Formatter of byte values
49
- * @param array $statusData The (unfiltered) output of opcache_get_status()
53
+ * @param \OpCacheGUI\Format\Byte $byteFormatter Formatter of byte values
54
+ * @param \OpCacheGUI\I18n\Translator $translator A translator
55
+ * @param array $statusData The (unfiltered) output of opcache_get_status()
50
56
*/
51
- public function __construct (Byte $ byteFormatter , array $ statusData )
57
+ public function __construct (Byte $ byteFormatter , Translator $ translator , array $ statusData )
52
58
{
53
59
$ this ->byteFormatter = $ byteFormatter ;
60
+ $ this ->translator = $ translator ;
54
61
$ this ->statusData = $ statusData ;
55
62
}
56
63
@@ -94,23 +101,22 @@ public function getMemoryInfo()
94
101
public function getGraphMemoryInfo ()
95
102
{
96
103
$ memory = $ this ->statusData ['memory_usage ' ];
97
- global $ translator ;
98
104
99
105
return json_encode ([
100
106
[
101
107
'value ' => $ memory ['used_memory ' ],
102
108
'color ' => self ::RED ,
103
- 'label ' => $ translator ->translate ('graph.memory.used ' ),
109
+ 'label ' => $ this -> translator ->translate ('graph.memory.used ' ),
104
110
],
105
111
[
106
112
'value ' => $ memory ['free_memory ' ],
107
113
'color ' => self ::GREEN ,
108
- 'label ' => $ translator ->translate ('graph.memory.free ' ),
114
+ 'label ' => $ this -> translator ->translate ('graph.memory.free ' ),
109
115
],
110
116
[
111
117
'value ' => $ memory ['wasted_memory ' ],
112
118
'color ' => self ::DARK_GREEN ,
113
- 'label ' => $ translator ->translate ('graph.memory.wasted ' ),
119
+ 'label ' => $ this -> translator ->translate ('graph.memory.wasted ' ),
114
120
],
115
121
]);
116
122
}
@@ -181,23 +187,22 @@ public function getStatsInfo()
181
187
public function getGraphKeyStatsInfo ()
182
188
{
183
189
$ stats = $ this ->statusData ['opcache_statistics ' ];
184
- global $ translator ;
185
190
186
191
return json_encode ([
187
192
[
188
193
'value ' => $ stats ['num_cached_scripts ' ],
189
194
'color ' => self ::RED ,
190
- 'label ' => $ translator ->translate ('graph.keys.scripts ' ),
195
+ 'label ' => $ this -> translator ->translate ('graph.keys.scripts ' ),
191
196
],
192
197
[
193
198
'value ' => $ stats ['max_cached_keys ' ] - $ stats ['num_cached_keys ' ],
194
199
'color ' => self ::GREEN ,
195
- 'label ' => $ translator ->translate ('graph.keys.free ' ),
200
+ 'label ' => $ this -> translator ->translate ('graph.keys.free ' ),
196
201
],
197
202
[
198
203
'value ' => $ stats ['num_cached_keys ' ] - $ stats ['num_cached_scripts ' ],
199
204
'color ' => self ::DARK_GREEN ,
200
- 'label ' => $ translator ->translate ('graph.keys.wasted ' ),
205
+ 'label ' => $ this -> translator ->translate ('graph.keys.wasted ' ),
201
206
],
202
207
]);
203
208
}
@@ -210,23 +215,22 @@ public function getGraphKeyStatsInfo()
210
215
public function getGraphHitStatsInfo ()
211
216
{
212
217
$ stats = $ this ->statusData ['opcache_statistics ' ];
213
- global $ translator ;
214
218
215
219
return json_encode ([
216
220
[
217
221
'value ' => $ stats ['hits ' ],
218
222
'color ' => self ::RED ,
219
- 'label ' => $ translator ->translate ('graph.hits.hits ' ),
223
+ 'label ' => $ this -> translator ->translate ('graph.hits.hits ' ),
220
224
],
221
225
[
222
226
'value ' => $ stats ['misses ' ],
223
227
'color ' => self ::GREEN ,
224
- 'label ' => $ translator ->translate ('graph.hits.misses ' ),
228
+ 'label ' => $ this -> translator ->translate ('graph.hits.misses ' ),
225
229
],
226
230
[
227
231
'value ' => $ stats ['blacklist_misses ' ],
228
232
'color ' => self ::DARK_GREEN ,
229
- 'label ' => $ translator ->translate ('graph.hits.blacklist ' ),
233
+ 'label ' => $ this -> translator ->translate ('graph.hits.blacklist ' ),
230
234
],
231
235
]);
232
236
}
0 commit comments