Piwik\API\DataTablePostProcessor::computeProcessedMetrics PHP Метод

computeProcessedMetrics() публичный Метод

public computeProcessedMetrics ( DataTable $dataTable )
$dataTable Piwik\DataTable
    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);
                    }
                }
            }
        }
    }