protected function createDocument($class, \stdClass $orientObject)
{
$metadata = $this->getMetadataFactory()->getMetadataFor($class);
/**
* when a record from OrientDB doesn't have a RID
* it means it's an embedded object, which can not be
* lazily loaded.
*/
if (isset($orientObject->{'@rid'})) {
$rid = new Rid($orientObject->{'@rid'});
if ($this->getUnitOfWork()->hasProxyFor($rid)) {
$document = $this->getUnitOfWork()->getProxyFor($rid);
} else {
$document = $this->getProxyFactory()->getProxy($class, array($metadata->getRidPropertyName() => $rid->getValue()));
}
} else {
$class = $metadata->getName();
$document = new $class();
}
$this->fill($document, $orientObject);
return $document;
}