Piwik\DataTable\Filter\

Truncate

Truncates a DataTable by merging all rows after a certain index into a new summary row.

The ReplaceSummaryRowLabel filter will be queued after the table is truncated.

Examples

Basic usage

$dataTable->filter('Truncate', array($truncateAfter = 500));

Using a custom summary row label

$dataTable->filter('Truncate', array($truncateAfter = 500, $summaryRowLabel = Matomo (formerly Piwik)::translate('General_Total')));

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):

    • $table (DataTable) —

    • $truncateAfter (int) — The row index to truncate at. All rows passed this index will be removed.

    • $labelSummaryRow (string) — The label to use for the summary row. Defaults to Piwik::translate('General_Others').
    • $columnToSortByBeforeTruncating (string) — The column to sort by before truncation, eg, 'nb_visits'.
    • $filterRecursive (bool) — If true executes this filter on all subtables descending from $table.

filter()

Executes the filter, see Truncate.

Signature

  • It accepts the following parameter(s):

  • 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.