diff options
author | diosmosis <benaka@piwik.pro> | 2014-11-12 07:28:12 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-11-12 07:28:12 +0300 |
commit | d07d24c59780587c58727a5295951a2dfcb8fc58 (patch) | |
tree | 30b83680ad82aa33094bbc349209847b147d9db7 /core/Plugin/Metric.php | |
parent | 4fd080617e0242dd2fb45c0f7ae09e66e21107c0 (diff) |
Fixing ViewDataTableTest UI test.
Diffstat (limited to 'core/Plugin/Metric.php')
-rw-r--r-- | core/Plugin/Metric.php | 22 |
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 |