Class ClosureStrategy

Summary

Fully Qualified Name: Laminas\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 null|callable function
$hydrateFunc null|callable function

Returns:

extract()

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

{@inheritDoc}

Parameter Name Type Description
$value
$object

Returns:

hydrate()

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

{@inheritDoc}

Parameter Name Type Description
$value
$data

Returns:

Top