<?php
namespace Hydrators;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Hydrator\HydratorException;
use Doctrine\ODM\MongoDB\Hydrator\HydratorInterface;
use Doctrine\ODM\MongoDB\Query\Query;
use Doctrine\ODM\MongoDB\UnitOfWork;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
/**
* THIS CLASS WAS GENERATED BY THE DOCTRINE ODM. DO NOT EDIT THIS FILE.
*/
class AppAdminDocumentHubHydrator implements HydratorInterface
{
private $dm;
private $unitOfWork;
private $class;
public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $class)
{
$this->dm = $dm;
$this->unitOfWork = $uow;
$this->class = $class;
}
public function hydrate(object $document, array $data, array $hints = array()): array
{
$hydratedData = array();
$mapping = $this->class->fieldMappings['chain'];
$className = $mapping['targetDocument'];
$targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
$mappedByMapping = $targetClass->fieldMappings[$mapping['mappedBy']];
$mappedByFieldName = ClassMetadata::getReferenceFieldName($mappedByMapping['storeAs'], $mapping['mappedBy']);
$criteria = array_merge(
array($mappedByFieldName => $data['_id']),
isset($this->class->fieldMappings['chain']['criteria']) ? $this->class->fieldMappings['chain']['criteria'] : array()
);
$sort = isset($this->class->fieldMappings['chain']['sort']) ? $this->class->fieldMappings['chain']['sort'] : array();
$return = $this->unitOfWork->getDocumentPersister($className)->load($criteria, null, array(), 0, $sort);
$this->class->reflFields['chain']->setValue($document, $return);
$hydratedData['chain'] = $return;
/** @Field(type="string") */
if (isset($data['workingTime']) || (! empty($this->class->fieldMappings['workingTime']['nullable']) && array_key_exists('workingTime', $data))) {
$value = $data['workingTime'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['workingTime']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['workingTime']->setValue($document, $return);
$hydratedData['workingTime'] = $return;
}
/** @Field(type="string") */
if (isset($data['address']) || (! empty($this->class->fieldMappings['address']['nullable']) && array_key_exists('address', $data))) {
$value = $data['address'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['address']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['address']->setValue($document, $return);
$hydratedData['address'] = $return;
}
/** @Field(type="string") */
if (isset($data['coordinates']) || (! empty($this->class->fieldMappings['coordinates']['nullable']) && array_key_exists('coordinates', $data))) {
$value = $data['coordinates'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['coordinates']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['coordinates']->setValue($document, $return);
$hydratedData['coordinates'] = $return;
}
/** @Field(type="string") */
if (isset($data['map']) || (! empty($this->class->fieldMappings['map']['nullable']) && array_key_exists('map', $data))) {
$value = $data['map'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['map']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['map']->setValue($document, $return);
$hydratedData['map'] = $return;
}
/** @Field(type="string") */
if (isset($data['delivery']) || (! empty($this->class->fieldMappings['delivery']['nullable']) && array_key_exists('delivery', $data))) {
$value = $data['delivery'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['delivery']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['delivery']->setValue($document, $return);
$hydratedData['delivery'] = $return;
}
/** @Field(type="string") */
if (isset($data['assembly']) || (! empty($this->class->fieldMappings['assembly']['nullable']) && array_key_exists('assembly', $data))) {
$value = $data['assembly'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['assembly']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['assembly']->setValue($document, $return);
$hydratedData['assembly'] = $return;
}
/** @Field(type="string") */
if (isset($data['documents']) || (! empty($this->class->fieldMappings['documents']['nullable']) && array_key_exists('documents', $data))) {
$value = $data['documents'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['documents']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['documents']->setValue($document, $return);
$hydratedData['documents'] = $return;
}
/** @Field(type="hash") */
if (isset($data['features']) || (! empty($this->class->fieldMappings['features']['nullable']) && array_key_exists('features', $data))) {
$value = $data['features'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['features']['type'];
$return = $value;
} else {
$return = null;
}
$this->class->reflFields['features']->setValue($document, $return);
$hydratedData['features'] = $return;
}
/** @Field(type="hash") */
if (isset($data['acceptanceItems']) || (! empty($this->class->fieldMappings['acceptanceItems']['nullable']) && array_key_exists('acceptanceItems', $data))) {
$value = $data['acceptanceItems'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['acceptanceItems']['type'];
$return = $value;
} else {
$return = null;
}
$this->class->reflFields['acceptanceItems']->setValue($document, $return);
$hydratedData['acceptanceItems'] = $return;
}
/** @Field(type="hash") */
if (isset($data['rules']) || (! empty($this->class->fieldMappings['rules']['nullable']) && array_key_exists('rules', $data))) {
$value = $data['rules'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['rules']['type'];
$return = $value;
} else {
$return = null;
}
$this->class->reflFields['rules']->setValue($document, $return);
$hydratedData['rules'] = $return;
}
/** @Many */
$mongoData = isset($data['maps']) ? $data['maps'] : null;
if ($mongoData !== null && ! is_array($mongoData)) {
throw HydratorException::associationTypeMismatch('App\Admin\Document\Hub', 'maps', 'array', gettype($mongoData));
}
$return = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $this->class->fieldMappings['maps']);
$return->setHints($hints);
$return->setOwner($document, $this->class->fieldMappings['maps']);
$return->setInitialized(false);
if ($mongoData) {
$return->setMongoData($mongoData);
}
$this->class->reflFields['maps']->setValue($document, $return);
$hydratedData['maps'] = $return;
/** @Many */
$mongoData = isset($data['contacts']) ? $data['contacts'] : null;
if ($mongoData !== null && ! is_array($mongoData)) {
throw HydratorException::associationTypeMismatch('App\Admin\Document\Hub', 'contacts', 'array', gettype($mongoData));
}
$return = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $this->class->fieldMappings['contacts']);
$return->setHints($hints);
$return->setOwner($document, $this->class->fieldMappings['contacts']);
$return->setInitialized(false);
if ($mongoData) {
$return->setMongoData($mongoData);
}
$this->class->reflFields['contacts']->setValue($document, $return);
$hydratedData['contacts'] = $return;
/** @Many */
$mongoData = isset($data['workingTimes']) ? $data['workingTimes'] : null;
if ($mongoData !== null && ! is_array($mongoData)) {
throw HydratorException::associationTypeMismatch('App\Admin\Document\Hub', 'workingTimes', 'array', gettype($mongoData));
}
$return = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $this->class->fieldMappings['workingTimes']);
$return->setHints($hints);
$return->setOwner($document, $this->class->fieldMappings['workingTimes']);
$return->setInitialized(false);
if ($mongoData) {
$return->setMongoData($mongoData);
}
$this->class->reflFields['workingTimes']->setValue($document, $return);
$hydratedData['workingTimes'] = $return;
/** @Field(type="id") */
if (isset($data['_id']) || (! empty($this->class->fieldMappings['id']['nullable']) && array_key_exists('_id', $data))) {
$value = $data['_id'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['id']['type'];
$return = $value instanceof \MongoDB\BSON\ObjectId ? (string) $value : $value;
} else {
$return = null;
}
$this->class->reflFields['id']->setValue($document, $return);
$hydratedData['id'] = $return;
}
/** @Field(type="boolean") */
if (isset($data['active']) || (! empty($this->class->fieldMappings['active']['nullable']) && array_key_exists('active', $data))) {
$value = $data['active'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['active']['type'];
$return = (bool) $value;
} else {
$return = null;
}
$this->class->reflFields['active']->setValue($document, $return);
$hydratedData['active'] = $return;
}
/** @Field(type="collection") */
if (isset($data['images']) || (! empty($this->class->fieldMappings['images']['nullable']) && array_key_exists('images', $data))) {
$value = $data['images'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['images']['type'];
$return = $value;
} else {
$return = null;
}
$this->class->reflFields['images']->setValue($document, $return);
$hydratedData['images'] = $return;
}
/** @Field(type="string") */
if (isset($data['name']) || (! empty($this->class->fieldMappings['name']['nullable']) && array_key_exists('name', $data))) {
$value = $data['name'];
if ($value !== null) {
$typeIdentifier = $this->class->fieldMappings['name']['type'];
$return = (string) $value;
} else {
$return = null;
}
$this->class->reflFields['name']->setValue($document, $return);
$hydratedData['name'] = $return;
}
return $hydratedData;
}
}