getProcessedMetricsForTable() public static method

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 $dataTable, Report $report = null ) : Piwik\Plugin\ProcessedMetric[]
$dataTable Piwik\DataTable
$report Report
return Piwik\Plugin\ProcessedMetric[]
コード例 #1
0
 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);
                 }
             }
         }
     }
 }