Class FilterComposite

Summary

Fully Qualified Name: Zend\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 Will return true if one from the "or conditions" and all from the "and condition" returns true. Otherwise false 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 array
$andFilters array

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
$name string
$filter callable|\FilterInterface
$condition int Can

Returns: \FilterComposite

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
string $property Parameter
$property

Returns: bool

hasFilter()

Check if $name has a filter registered

Parameter Name Type Description
string $name Identifier
$name

Returns: bool

removeFilter()

Remove a filter from the composition

Parameter Name Type Description
string $name Identifier
$name

Returns: \FilterComposite

Top