Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
TraceVariableDataProvider | |
0.00% |
0 / 31 |
|
0.00% |
0 / 3 |
110 | |
0.00% |
0 / 1 |
prepare | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
56 | |||
getValue | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
getCache | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace oat\taoOutcomeUi\model\table; |
4 | |
5 | use common_Logger; |
6 | use core_kernel_classes_Resource; |
7 | use oat\taoOutcomeUi\model\ResultsService; |
8 | use tao_helpers_Date; |
9 | use tao_models_classes_table_Column; |
10 | use tao_models_classes_table_DataProvider; |
11 | |
12 | class TraceVariableDataProvider implements tao_models_classes_table_DataProvider |
13 | { |
14 | public const PROP_TRACE_VARIABLE = 'trace_variable'; |
15 | |
16 | /** @var array */ |
17 | public $cache; |
18 | |
19 | public function prepare($resources, $columns) |
20 | { |
21 | $this->cache = []; |
22 | $resultsService = ResultsService::singleton(); |
23 | |
24 | foreach ($resources as $result) { |
25 | $itemResults = $resultsService->getVariables($result, false); |
26 | |
27 | foreach ($itemResults as $itemResultUri => $vars) { |
28 | foreach ($vars as $var) { |
29 | // cache the variable data |
30 | /** @var \taoResultServer_models_classes_Variable $varData */ |
31 | $varData = $var[0]->variable; |
32 | |
33 | if ( |
34 | !$varData instanceof \taoResultServer_models_classes_TraceVariable |
35 | || $var[0]->callIdItem !== null |
36 | ) { |
37 | continue; |
38 | } |
39 | |
40 | $epoch = $varData->getEpoch(); |
41 | $trace = $varData->getTrace(); |
42 | $identifier = $varData->getIdentifier(); |
43 | |
44 | $readableTime = ""; |
45 | if ($epoch != "") { |
46 | $displayDate = tao_helpers_Date::displayeDate( |
47 | tao_helpers_Date::getTimeStamp($epoch), |
48 | tao_helpers_Date::FORMAT_VERBOSE |
49 | ); |
50 | $readableTime = "@" . $displayDate; |
51 | } |
52 | |
53 | $this->cache[$result][(string) $epoch] = [ |
54 | $trace, |
55 | $identifier, |
56 | $readableTime |
57 | ]; |
58 | } |
59 | } |
60 | } |
61 | } |
62 | |
63 | public function getValue(core_kernel_classes_Resource $resource, tao_models_classes_table_Column $column) |
64 | { |
65 | $returnValue = []; |
66 | |
67 | if (isset($this->cache[$resource->getUri()])) { |
68 | $returnValue = $this->cache[$resource->getUri()]; |
69 | } else { |
70 | common_Logger::d('no data for resource: ' . $resource->getUri() . ' column: ' . $column->getIdentifier()); |
71 | } |
72 | |
73 | return $returnValue; |
74 | } |
75 | |
76 | public function getCache() |
77 | { |
78 | return $this->cache; |
79 | } |
80 | } |