class HydratorFactory (View source)

The HydratorFactory class is responsible for instantiating a correct hydrator type based on document's ClassMetadata

Methods

__construct(DocumentManager $dm, EventManager $evm, $hydratorDir, $hydratorNs, $autoGenerate)

No description

setUnitOfWork(UnitOfWork $uow)

Sets the UnitOfWork instance.

getHydratorFor(string $className)

Gets the hydrator object for the given document class.

generateHydratorClasses(array $classes, string $toDir = null)

Generates hydrator classes for all given classes.

array
hydrate(object $document, array $data, array $hints = [])

Hydrate array of MongoDB document data into the given document object.

Details

__construct(DocumentManager $dm, EventManager $evm, $hydratorDir, $hydratorNs, $autoGenerate)

Parameters

DocumentManager $dm
EventManager $evm
$hydratorDir
$hydratorNs
$autoGenerate

Exceptions

HydratorException

setUnitOfWork(UnitOfWork $uow)

Sets the UnitOfWork instance.

Parameters

UnitOfWork $uow

HydratorInterface getHydratorFor(string $className)

Gets the hydrator object for the given document class.

Parameters

string $className

Return Value

HydratorInterface $hydrator

generateHydratorClasses(array $classes, string $toDir = null)

Generates hydrator classes for all given classes.

Parameters

array $classes The classes (ClassMetadata instances) for which to generate hydrators.
string $toDir The target directory of the hydrator classes. If not specified, the directory configured on the Configuration of the DocumentManager used by this factory is used.

array hydrate(object $document, array $data, array $hints = [])

Hydrate array of MongoDB document data into the given document object.

Parameters

object $document The document object to hydrate the data into.
array $data The array of document data.
array $hints Any hints to account for during reconstitution/lookup of the document.

Return Value

array $values The array of hydrated values.