protected function fill($document, \stdClass $object)
{
$metadata = $this->getMetadataFactory()->getMetadataFor(get_class($document));
$propertyAnnotations = $this->getMetadataFactory()->getObjectPropertyAnnotations($document);
foreach ($propertyAnnotations as $property => $annotation) {
$documentProperty = $property;
if ($annotation->name) {
$property = $annotation->name;
}
if (property_exists($object, $property)) {
$value = $this->hydrateValue($object->{$property}, $annotation);
$metadata->setDocumentValue($document, $documentProperty, $value);
}
}
if ($document instanceof Proxy) {
$document->__setInitialized(true);
}
return $document;
}