ColumnCallbackReplace
This documentation is for an outdated Matomo version.
Click here if you want to read this article for the latest version.
Click here if you want to read this article for the latest version.
Piwik\DataTable\Filter\
ColumnCallbackReplace
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'));
Methods
The class defines the following methods:
__construct()— Constructor.filter()ash; See ColumnCallbackReplace.enableRecursive()ash; Enables/Disables recursive filtering. Inherited fromBaseFilterfilterSubTable()ash; Filters a row's subtable, if one exists and is loaded in memory. Inherited fromBaseFilter
__construct()
Constructor.
Signature
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()
Signature
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.
Signature
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.
Signature
- It accepts the following parameter(s):
$row(Row) — The row whose subtable should be filter.
- It does not return anything or a mixed result.