Piwik\DataTable\Filter\
Replaces column names in each row of a table using an array that maps old column names new ones.
If no mapping is provided, this column will use one that maps index metric names (which are integers) with their string column names. In the database, reports are stored with integer metric names because it results in blobs that take up less space. When loading the reports, the column names must be replaced, which is handled by this class. (See Metrics for more information about integer metric names.)
Basic example
// filter use in a plugin's API method
public function getMyReport($idSite, $period, $date, $segment = false, $expanded = false)
{
$dataTable = Archive::createDataTableFromArchive('MyPlugin_MyReport', $idSite, $period, $date, $segment, $expanded);
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
}
The class defines the following methods:
__construct()
— Constructor.filter()
ash; See ReplaceColumnNames.enableRecursive()
ash; Enables/Disables recursive filtering. Inherited from BaseFilter
filterSubTable()
ash; Filters a row's subtable, if one exists and is loaded in memory. Inherited from BaseFilter
__construct()
Constructor.
It accepts the following parameter(s):
$table
(DataTable
) —
$mappingToApply
(array
|null
) —
The name mapping to apply. Must map old column names with new ones, eg, array('OLD_COLUMN_NAME' => 'NEW_COLUMN NAME', 'OLD_COLUMN_NAME2' => 'NEW_COLUMN NAME2') If null, Metrics::$mappingFromIdToName is used.
filter()
See ReplaceColumnNames.
It accepts the following parameter(s):
$table
(DataTable
) —It does not return anything or a mixed result.
enableRecursive()
Enables/Disables recursive filtering. Whether this property is actually used is up to the derived BaseFilter class.
It accepts the following parameter(s):
$enable
(bool
) —It does not return anything or a mixed result.
filterSubTable()
Filters a row's subtable, if one exists and is loaded in memory.
$row
(Row
) —
The row whose subtable should be filter.