private function loadEmbedManyCollection(PersistentCollection $collection) { $embeddedDocuments = $collection->getMongoData(); $mapping = $collection->getMapping(); $owner = $collection->getOwner(); if ($embeddedDocuments) { foreach ($embeddedDocuments as $key => $embeddedDocument) { $className = $this->dm->getClassNameFromDiscriminatorValue($mapping, $embeddedDocument); $embeddedMetadata = $this->dm->getClassMetadata($className); $embeddedDocumentObject = $embeddedMetadata->newInstance(); $data = $this->hydratorFactory->hydrate($embeddedDocumentObject, $embeddedDocument); $this->uow->registerManaged($embeddedDocumentObject, null, $data); $this->uow->setParentAssociation($embeddedDocumentObject, $mapping, $owner, $mapping['name'] . '.' . $key); $collection->add($embeddedDocumentObject); } } }
private function loadEmbedManyCollection(PersistentCollection $collection) { $embeddedDocuments = $collection->getMongoData(); $mapping = $collection->getMapping(); $owner = $collection->getOwner(); if ($embeddedDocuments) { foreach ($embeddedDocuments as $key => $embeddedDocument) { $className = $this->uow->getClassNameForAssociation($mapping, $embeddedDocument); $embeddedMetadata = $this->dm->getClassMetadata($className); $embeddedDocumentObject = $embeddedMetadata->newInstance(); $this->uow->setParentAssociation($embeddedDocumentObject, $mapping, $owner, $mapping['name'] . '.' . $key); $data = $this->hydratorFactory->hydrate($embeddedDocumentObject, $embeddedDocument); $id = $embeddedMetadata->identifier && isset($data[$embeddedMetadata->identifier]) ? $data[$embeddedMetadata->identifier] : null; $this->uow->registerManaged($embeddedDocumentObject, $id, $data); if (CollectionHelper::isHash($mapping['strategy'])) { $collection->set($key, $embeddedDocumentObject); } else { $collection->add($embeddedDocumentObject); } } } }