Methods

You can describe how your values will extract and hydrate, like this: $hydrator->addStrategy('category', new ClosureStrategy( function (Category $value) { return (int) $value->id; }, function ($value) { return new Category((int) $value); } ));

__construct(\Zend\Stdlib\Hydrator\Strategy\callable $extractFunc, \Zend\Stdlib\Hydrator\Strategy\callable $hydrateFunc) 

Parameters

$extractFunc

\Zend\Stdlib\Hydrator\Strategy\callable
  • anonymous function, that extract values from object

$hydrateFunc

\Zend\Stdlib\Hydrator\Strategy\callable
  • anonymous function, that hydrate values into object

Converts the given value so that it can be extracted by the hydrator.

extract(mixed $value) : mixed

Parameters

$value

mixed

The original value.

Returns

mixedReturns the value that should be extracted.

Converts the given value so that it can be hydrated by the hydrator.

hydrate(mixed $value) : mixed

Parameters

$value

mixed

The original value.

Returns

mixedReturns the value that should be hydrated.

 Properties

 

Function, used in extract method, default: function ($value) { return $value; };

$extractFunc : \Zend\Stdlib\Hydrator\Strategy\callable

 

Function, used in hydrate method, default: function ($value) { return $value; };

$hydrateFunc : \Zend\Stdlib\Hydrator\Strategy\callable