Class FilterComposite

Summary

Fully Qualified Name: Laminas\Hydrator\Filter\FilterComposite
Implements: FilterInterface

Description

Methods

Name Description Defined By
__construct() We can pass a list of OR/AND filters through construct FilterComposite
addFilter() Add a filter to the composite. Has to be indexed with $name in order to identify a specific filter. FilterComposite
filter() Filter the composite based on the AND and OR condition FilterComposite
hasFilter() Check if $name has a filter registered FilterComposite
removeFilter() Remove a filter from the composition FilterComposite

Method Details

__construct()

We can pass a list of OR/AND filters through construct

Parameter Name Type Description
$orFilters callable[]|\FilterInterface[]
$andFilters callable[]|\FilterInterface[]

Returns:

addFilter()

Add a filter to the composite. Has to be indexed with $name in order to identify a specific filter.

This example will exclude all methods from the hydration, that starts with 'getService' $composite->addFilter('exclude',

function ($method) {
    if (preg_match('/^getService/', $method) {
        return false;
    }
    return true;
}, FilterComposite::CONDITION_AND

);

Parameter Name Type Description
$filter callable|\FilterInterface
$condition int Can
$name

Returns:

filter()

Filter the composite based on the AND and OR condition

Will return true if one from the "or conditions" and all from the "and condition" returns true. Otherwise false

Parameter Name Type Description
$property string Parameter

Returns:

hasFilter()

Check if $name has a filter registered

Parameter Name Type Description
$name

Returns:

removeFilter()

Remove a filter from the composition

Parameter Name Type Description
$name

Returns:

Top