Zend\Stdlib\Hydrator\Strategy\ClosureStrategy
Synopsis
class ClosureStrategy
implements
StrategyInterface
{
- // members
- protected callable $extractFunc;
- protected callable $hydrateFunc;
- // methods
- public void __construct()
- public mixed extract()
- public mixed hydrate()
Hierarchy
Members
protected
- $extractFunc
—
Zend\Stdlib\Hydrator\Strategy\callable
Function, used in extract method, default: function ($value) { return $value; }; - $hydrateFunc
—
Zend\Stdlib\Hydrator\Strategy\callable
Function, used in hydrate method, default: function ($value) { return $value; };
Methods
public
- __construct() — 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); } ));
- extract() — Converts the given value so that it can be extracted by the hydrator.
- hydrate() — Converts the given value so that it can be hydrated by the hydrator.