Returns the ProcessedMetrics that should be computed and formatted for a DataTable of a
certain report. The ProcessedMetrics returned are those specified by the Report metadata
as well as the DataTable metadata.
public static getProcessedMetricsForTable ( |
||
$dataTable | ||
$report | ||
리턴 | Piwik\Plugin\ProcessedMetric[] |
public function computeProcessedMetrics(DataTable $dataTable) { if ($dataTable->getMetadata(self::PROCESSED_METRICS_COMPUTED_FLAG)) { return; } /** @var ProcessedMetric[] $processedMetrics */ $processedMetrics = Report::getProcessedMetricsForTable($dataTable, $this->report); if (empty($processedMetrics)) { return; } $dataTable->setMetadata(self::PROCESSED_METRICS_COMPUTED_FLAG, true); foreach ($processedMetrics as $name => $processedMetric) { if (!$processedMetric->beforeCompute($this->report, $dataTable)) { continue; } foreach ($dataTable->getRows() as $row) { if ($row->getColumn($name) === false) { // only compute the metric if it has not been computed already $computedValue = $processedMetric->compute($row); if ($computedValue !== false) { $row->addColumn($name, $computedValue); } $subtable = $row->getSubtable(); if (!empty($subtable)) { $this->computeProcessedMetrics($subtable); } } } } }