本文整理汇总了PHP中Piwik\Metrics::getMappingFromIdToName方法的典型用法代码示例。如果您正苦于以下问题:PHP Metrics::getMappingFromIdToName方法的具体用法?PHP Metrics::getMappingFromIdToName怎么用?PHP Metrics::getMappingFromIdToName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Metrics
的用法示例。
在下文中一共展示了Metrics::getMappingFromIdToName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectColumnToSort
/**
* Sets the column to be used for sorting
*
* @param Row $row
* @return int
*/
protected function selectColumnToSort($row)
{
$value = $row->getColumn($this->columnToSort);
if ($value !== false) {
return $this->columnToSort;
}
$columnIdToName = Metrics::getMappingFromIdToName();
// sorting by "nb_visits" but the index is Metrics::INDEX_NB_VISITS in the table
if (isset($columnIdToName[$this->columnToSort])) {
$column = $columnIdToName[$this->columnToSort];
$value = $row->getColumn($column);
if ($value !== false) {
return $column;
}
}
// eg. was previously sorted by revenue_per_visit, but this table
// doesn't have this column; defaults with nb_visits
$column = Metrics::INDEX_NB_VISITS;
$value = $row->getColumn($column);
if ($value !== false) {
return $column;
}
// even though this column is not set properly in the table,
// we select it for the sort, so that the table's internal state is set properly
return $this->columnToSort;
}
示例2: testGetMappingFromIdToName
/**
* @group Core
*/
public function testGetMappingFromIdToName()
{
$mapping = Metrics::getMappingFromIdToName();
$expectedMapping = array('nb_uniq_visitors' => 1, 'nb_visits' => 2, 'nb_actions' => 3, 'max_actions' => 4, 'sum_visit_length' => 5, 'bounce_count' => 6, 'nb_users' => 39, 'nb_visits_converted' => 7, 'nb_conversions' => 8, 'revenue' => 23, 'goals' => 10, 'sum_daily_nb_uniq_visitors' => 11, 'sum_daily_nb_users' => 40, 'nb_hits' => 12, 'sum_time_spent' => 13, 'sum_time_generation' => 30, 'nb_hits_with_time_generation' => 31, 'min_time_generation' => 32, 'max_time_generation' => 33, 'exit_nb_uniq_visitors' => 14, 'exit_nb_visits' => 15, 'sum_daily_exit_nb_uniq_visitors' => 16, 'entry_nb_uniq_visitors' => 17, 'sum_daily_entry_nb_uniq_visitors' => 18, 'entry_nb_visits' => 19, 'entry_nb_actions' => 20, 'entry_sum_visit_length' => 21, 'entry_bounce_count' => 22, 'nb_hits_following_search' => 29, 'quantity' => 24, 'price' => 25, 'price_viewed' => 27, 'orders' => 26, 'nb_events' => 34, 'sum_event_value' => 35, 'min_event_value' => 36, 'max_event_value' => 37, 'nb_events_with_value' => 38, 'nb_impressions' => 41, 'nb_interactions' => 42);
$this->assertEquals($expectedMapping, $mapping);
}
示例3: __construct
/**
* Constructor.
*
* @param DataTable $table The table to pivot.
* @param string $report The ID of the report being pivoted, eg, `'Referrers.getKeywords'`.
* @param string $pivotByDimension The ID of the dimension to pivot by, eg, `'Referrers.Keyword'`.
* @param string|false $pivotColumn The metric that should be displayed in the pivot table, eg, `'nb_visits'`.
* If `false`, the first non-label column is used.
* @param false|int $pivotByColumnLimit The number of columns to limit the pivot table to.
* @param bool $isFetchingBySegmentEnabled Whether to allow fetching by segment.
* @throws Exception if pivoting the report by a dimension is unsupported.
*/
public function __construct($table, $report, $pivotByDimension, $pivotColumn, $pivotByColumnLimit = false, $isFetchingBySegmentEnabled = true)
{
parent::__construct($table);
Log::debug("PivotByDimension::%s: creating with [report = %s, pivotByDimension = %s, pivotColumn = %s, " . "pivotByColumnLimit = %s, isFetchingBySegmentEnabled = %s]", __FUNCTION__, $report, $pivotByDimension, $pivotColumn, $pivotByColumnLimit, $isFetchingBySegmentEnabled);
$this->pivotColumn = $pivotColumn;
$this->pivotByColumnLimit = $pivotByColumnLimit ?: self::getDefaultColumnLimit();
$this->isFetchingBySegmentEnabled = $isFetchingBySegmentEnabled;
$namesToId = Metrics::getMappingFromIdToName();
$this->metricIndexValue = isset($namesToId[$this->pivotColumn]) ? $namesToId[$this->pivotColumn] : null;
$this->setPivotByDimension($pivotByDimension);
$this->setThisReportMetadata($report);
$this->checkSupportedPivot();
}