Piwik\DataTable\Filter\

MetadataCallbackAddMetadata

Executes a callback for each row of a DataTable and adds the result to the row as a metadata value.

Only metadata values are passed to the callback.

Basic usage example

// add a logo metadata based on the url metadata
$dataTable->filter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik\Plugins\MyPlugin\getLogoFromUrl'));

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):
    • $table (DataTable) — The DataTable that will eventually be filtered.
    • $metadataToRead (string|array) — The metadata to read from each row and pass to the callback.
    • $metadataToAdd (string) — The name of the metadata to add.
    • $functionToApply (callable) — The callback to execute for each row. The result will be added as metadata with the name $metadataToAdd.
    • $applyToSummaryRow (bool) — True if the callback should be applied to the summary row, false if otherwise.

filter()

See MetadataCallbackAddMetadata.

Signature

  • It accepts the following parameter(s):

  • It does not return anything.

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.

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.