Piwik\DataTable\Filter\
Replaces one or more column values in each row of a DataTable with the results of a callback.
Basic usage example
$truncateString = function ($value, $truncateLength) {
if (strlen($value) > $truncateLength) {
return substr(0, $truncateLength);
} else {
return $value;
}
};
// label, url and truncate_length are columns in $dataTable
$dataTable->filter('ColumnCallbackReplace', array('label', 'url'), $truncateString, null, array('truncate_length'));
The class defines the following methods:
__construct() — Constructor.filter() ash; See ColumnCallbackReplace.enableRecursive() ash; Enables/Disables recursive filtering. Inherited from BaseFilterfilterSubTable() 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) —
$columnsToFilter (array|string) —
The columns whose values should be passed to the callback and then replaced with the callback's result.
$functionToApply (callable) —
The function to execute. Must take the column value as a parameter and return a value that will be used to replace the original.$functionParameters (array|null) —
deprecated - use an anonymous function instead.$extraColumnParameters (array) —
Extra column values that should be passed to the callback, but shouldn't be replaced.filter()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.