Class ClosureStrategy

Summary

Fully Qualified Name: Zend\Hydrator\Strategy\ClosureStrategy
Implements: StrategyInterface

Description

Methods

Name Description Defined By
__construct() You can describe how your values will extract and hydrate, like this: ClosureStrategy
extract() Converts the given value so that it can be extracted by the hydrator. ClosureStrategy
hydrate() Converts the given value so that it can be hydrated by the hydrator. ClosureStrategy

Method Details

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

));

Parameter Name Type Description
$extractFunc callable -
$hydrateFunc callable -

Returns:

extract()

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

Parameter Name Type Description
$value mixed The
$object array The

Returns: mixed Returns the value that should be extracted.

hydrate()

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

Parameter Name Type Description
$value mixed The
$data array The

Returns: mixed Returns the value that should be hydrated.

Top