Piwik\Plugin\Report::getMetricsForTable PHP Method

getMetricsForTable() public static method

Includes ProcessedMetrics and Metrics.
public static getMetricsForTable ( DataTable $dataTable, Report $report = null, string $baseType = 'Piwik\Plugin\Metric' ) : Metric[]
$dataTable Piwik\DataTable
$report Report
$baseType string The base type each metric class needs to be of.
return Metric[]
    public static function getMetricsForTable(DataTable $dataTable, Report $report = null, $baseType = 'Piwik\\Plugin\\Metric')
    {
        $metrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME) ?: array();
        if (!empty($report)) {
            $metrics = array_merge($metrics, $report->getProcessedMetricsById());
        }
        $result = array();
        /** @var Metric $metric */
        foreach ($metrics as $metric) {
            if (!$metric instanceof $baseType) {
                continue;
            }
            $result[$metric->getName()] = $metric;
        }
        return $result;
    }

Usage Example

Example #1
0
 /**
  * @param DataTable $dataTable
  * @param Report $report
  * @return Metric[]
  */
 private function getMetricsToFormat(DataTable $dataTable, Report $report = null)
 {
     return Report::getMetricsForTable($dataTable, $report, $baseType = 'Piwik\\Plugin\\Metric');
 }
All Usage Examples Of Piwik\Plugin\Report::getMetricsForTable