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, string|null $hydratorDir, string|null $hydratorNs, int $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|null $toDir = null)

Generates hydrator classes for all given classes.

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

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

Details

__construct(DocumentManager $dm, EventManager $evm, string|null $hydratorDir, string|null $hydratorNs, int $autoGenerate)

Parameters

DocumentManager $dm
EventManager $evm
string|null $hydratorDir
string|null $hydratorNs
int $autoGenerate

Exceptions

HydratorException

setUnitOfWork(UnitOfWork $uow)

Sets the UnitOfWork instance.

Parameters

UnitOfWork $uow

getHydratorFor(string $className)

Gets the hydrator object for the given document class.

Parameters

string $className

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

Generates hydrator classes for all given classes.

Parameters

array $classes The classes (ClassMetadata instances) for which to generate hydrators.
string|null $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.

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

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

Parameters

object $document
array $data
array $hints