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); } ));
Signature
public function __construct([callable
$extractFunc = null,
[callable
$hydrateFunc = null]] )
Parameters
$extractFunc
—
object
- anonymous function, that extract values from object
$hydrateFunc
—
object
- anonymous function, that hydrate values into object