private function hydrateNode(Node $node, $className = null, $andProxy = false) { if ($entity = $this->entityManager->getUnitOfWork()->getEntityById($node->identity())) { return $entity; } $cl = $className !== null ? $className : $this->className; $cm = $className === null ? $this->classMetadata : $this->entityManager->getClassMetadataFor($cl); $pmVersion = !method_exists(Version::class, 'getVersion') ? 1 : (int) Version::getVersion()[0]; $em = $this->entityManager; if ($andProxy) { if ($pmVersion >= 2) { $initializer = function ($ghostObject, $method, array $parameters, &$initializer, array $properties) use($cm, $node, $em, $pmVersion) { $initializer = null; /* foreach ($cm->getPropertiesMetadata() as $field => $meta) { if ($node->hasValue($field)) { $key = null; if ($meta->getReflectionProperty()->isPrivate()) { $key = '\\0' . $cm->getClassName() . '\\0' . $meta->getPropertyName(); } else if($meta->getReflectionProperty()->isProtected()) { $key = '' . "\0" . '*' . "\0" . $meta->getPropertyName(); } else if ($meta->getReflectionProperty()->isPublic()) { $key = $meta->getPropertyName(); } if (null !== $key) { $properties[$key] = $node->value($field); } foreach ($cm->getLabeledProperties() as $labeledProperty) { //$v = $node->hasLabel($labeledProperty->getLabelName()) ? true : false; //$labeledProperty->setLabel($instance, $v); } } } */ foreach ($cm->getSimpleRelationships(false) as $relationship) { if (!$relationship->isCollection()) { $finder = new RelationshipsFinder($em, $relationship->getTargetEntity(), $relationship); $instances = $finder->find($node->identity()); if (count($instances) > 0) { $properties[ProxyUtils::getPropertyIdentifier($relationship->getReflectionProperty(), $cm->getClassName())] = $instances[0]; } } } return true; }; } else { $initializer = function ($ghostObject, $method, array $parameters, &$initializer) use($cm, $node, $em, $pmVersion) { $initializer = null; foreach ($cm->getPropertiesMetadata() as $field => $meta) { if ($node->hasValue($field)) { $meta->setValue($ghostObject, $node->value($field)); } } foreach ($cm->getSimpleRelationships(false) as $relationship) { if (!$relationship->isCollection()) { $finder = new RelationshipsFinder($em, $relationship->getTargetEntity(), $relationship); $instances = $finder->find($node->identity()); if (count($instances) > 0) { $relationship->setValue($ghostObject, $instances[0]); } } } $cm->setId($ghostObject, $node->identity()); return true; }; } $proxyOptions = ['skippedProperties' => ['' . "