Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2014-11-12 07:28:12 +0300
committerdiosmosis <benaka@piwik.pro>2014-11-12 07:28:12 +0300
commitd07d24c59780587c58727a5295951a2dfcb8fc58 (patch)
tree30b83680ad82aa33094bbc349209847b147d9db7 /core/Plugin/Metric.php
parent4fd080617e0242dd2fb45c0f7ae09e66e21107c0 (diff)
Fixing ViewDataTableTest UI test.
Diffstat (limited to 'core/Plugin/Metric.php')
-rw-r--r--core/Plugin/Metric.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/Plugin/Metric.php b/core/Plugin/Metric.php
index 9200c0a607..6fe5fd4b22 100644
--- a/core/Plugin/Metric.php
+++ b/core/Plugin/Metric.php
@@ -132,13 +132,31 @@ abstract class Metric
$mappingNameToId = Metrics::getMappingFromNameToId();
}
+ $columnName = self::getActualMetricColumn($table, $columnName, $mappingNameToId);
+ return $table->getColumn($columnName);
+ }
+
+ /**
+ * Helper method that determines the actual column for a metric in a {@link Piwik\DataTable}.
+ *
+ * @param DataTable $table
+ * @param string $columnName
+ * @param int[]|null $mappingNameToId A custom mapping of metric names to special index values. By
+ * default {@link Metrics::getMappingFromNameToId()} is used.
+ * @return string
+ */
+ public static function getActualMetricColumn(DataTable $table, $columnName, $mappingNameToId = null)
+ {
+ if (empty($mappingIdToName)) {
+ $mappingNameToId = Metrics::getMappingFromNameToId();
+ }
+
$firstRow = $table->getFirstRow();
if (!empty($firstRow)
&& $firstRow->getColumn($columnName) === false
) {
$columnName = $mappingNameToId[$columnName];
}
-
- return $table->getColumn($columnName);
+ return $columnName;
}
} \ No newline at end of file