Methods

Define default Filter

__construct(array $orFilter, array $andFilter) 

Parameters

$orFilter

array

$andFilter

array

Exceptions

\Zend\Stdlib\Exception\InvalidArgumentException

Add a filter to the composite.

addFilter(string $name, \Zend\Stdlib\Hydrator\Filter\callable | \Zend\Stdlib\Hydrator\Filter\FilterInterface $filter, int $condition) : \Zend\Stdlib\Hydrator\Filter\FilterComposite

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
);

Parameters

$name

string

$filter

\Zend\Stdlib\Hydrator\Filter\callable\Zend\Stdlib\Hydrator\Filter\FilterInterface

$condition

int

Can be either FilterComposite::CONDITION_OR or FilterComposite::CONDITION_AND

Exceptions

\Zend\Stdlib\Exception\InvalidArgumentException

Returns

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.

filter(\Zend\Stdlib\Hydrator\Filter\$property $property) : bool

Otherwise false

Parameters

$property

\Zend\Stdlib\Hydrator\Filter\$property

string Parameter will be e.g. Parent\Namespace\Class::method

Returns

bool

Check if $name has a filter registered

hasFilter(\Zend\Stdlib\Hydrator\Filter\$name $name) : bool

Parameters

$name

\Zend\Stdlib\Hydrator\Filter\$name

string Identifier for the filter

Returns

bool

Remove a filter from the composition

removeFilter(\Zend\Stdlib\Hydrator\Filter\$name $name) : \Zend\Stdlib\Hydrator\Filter\FilterComposite

Parameters

$name

\Zend\Stdlib\Hydrator\Filter\$name

string Identifier for the filter

Returns

 Properties

 

$andFilter

$andFilter : \ArrayObject

 

$orFilter

$orFilter : \ArrayObject

 Constants

 

Constant to add with "and" conditition

CONDITION_AND 

 

Constant to add with "or" conditition

CONDITION_OR