Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 648 Bytes

02-filters.md

File metadata and controls

18 lines (12 loc) · 648 Bytes

Filters

Filters can be used to remove formatted objects from the final result.

Filters are only applied when calling FormatterInterface::formatMany or TraversableFormatterInterface::formatTraversable.

The callable should be an implementation of the $callback parameter defined in the array_filter function. Returning true if the element should not be filtered.

Usage

$filter = function (array $data) {
    // Expressions returning true remove the formatted object from the result.
    return $data['count'] !== 126;
};

$formatter->addFilter(filter);