Methods

Initializes a new instance of this class.

__construct() 

Add a new filter to take care of what needs to be hydrated.

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

To exclude e.g. the method getServiceLocator:

$composite->addFilter("servicelocator",
    function ($property) {
        list($class, $method) = explode('::', $property);
        if ($method === 'getServiceLocator') {
            return false;
        }
        return true;
    }, FilterComposite::CONDITION_AND
);

Parameters

$name

string

Index in the composite

$filter

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

$condition

int

Returns

Adds the given strategy under the given name.

addStrategy(string $name, \Zend\Stdlib\Hydrator\Strategy\StrategyInterface $strategy) : \Zend\Stdlib\Hydrator\HydratorInterface

Parameters

$name

string

The name of the strategy to register.

$strategy

\Zend\Stdlib\Hydrator\Strategy\StrategyInterface

The strategy to register.

Returns

Convert a name for extraction.

extractName(string $name, null $object) : mixed

If no naming strategy exists, the plain value is returned.

Parameters

$name

string

The name to convert.

$object

null

The object is optionally provided as context.

Returns

mixed

Converts a value for extraction.

extractValue(string $name, mixed $value, mixed $object) : mixed

If no strategy exists the plain value is returned.

Parameters

$name

string

The name of the strategy to use.

$value

mixed

The value that should be converted.

$object

mixed

The object is optionally provided as context.

Returns

mixed

Gets the strategy with the given name.

getStrategy(string $name) : \Zend\Stdlib\Hydrator\Strategy\StrategyInterface

Parameters

$name

string

The name of the strategy to get.

Exceptions

\Zend\Stdlib\Exception\InvalidArgumentException

Returns

Check whether a specific filter exists at key $name or not

hasFilter(string $name) : bool

Parameters

$name

string

Index in the composite

Returns

bool

Checks if a naming strategy exists.

hasNamingStrategy() : bool

Returns

bool

Checks if the strategy with the given name exists.

hasStrategy(string $name) : bool

Parameters

$name

string

The name of the strategy to check for.

Returns

bool

Converts a value for hydration.

hydrateName(string $name, array $data) : mixed

If no naming strategy exists, the plain value is returned.

Parameters

$name

string

The name to convert.

$data

array

The whole data is optionally provided as context.

Returns

mixed

Converts a value for hydration.

hydrateValue(string $name, mixed $value, array $data) : mixed

If no strategy exists the plain value is returned.

Parameters

$name

string

The name of the strategy to use.

$value

mixed

The value that should be converted.

$data

array

The whole data is optionally provided as context.

Returns

mixed

Remove a filter from the composition.

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

To not extract "has" methods, you simply need to unregister it

$filterComposite->removeFilter('has');

Parameters

$name

Returns

Removes the naming strategy

removeNamingStrategy() : \Zend\Stdlib\Hydrator\self

Returns

\Zend\Stdlib\Hydrator\self

Removes the strategy with the given name.

removeStrategy(string $name) : \Zend\Stdlib\Hydrator\HydratorInterface

Parameters

$name

string

The name of the strategy to remove.

Returns

Adds the given naming strategy

setNamingStrategy(\Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface $strategy) : \Zend\Stdlib\Hydrator\self

Parameters

Returns

\Zend\Stdlib\Hydrator\self

 Properties

 

Composite to filter the methods, that need to be hydrated

$filterComposite : \Zend\Stdlib\Hydrator\Filter\FilterComposite

 

An instance of NamingStrategyInterface

$namingStrategy : \Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface

 

The list with strategies that this hydrator has.

$strategies : \ArrayObject