protected function handleArrayData(array $source, $targetType, array &$convertedChildProperties, PropertyMappingConfigurationInterface $configuration = null)
{
if (!isset($source['__identity'])) {
if ($this->reflectionService->isClassAnnotatedWith($targetType, ValueObject::class) === true) {
// Allow creation for ValueObjects by default, but prevent if explicitly disallowed
if ($configuration !== null && $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) === false) {
throw new InvalidPropertyMappingConfigurationException('Creation of value objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE');
}
} elseif ($configuration === null || $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) !== true) {
throw new InvalidPropertyMappingConfigurationException('Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE');
}
$object = $this->buildObject($convertedChildProperties, $targetType);
} elseif ($configuration !== null && $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_IDENTITY_CREATION_ALLOWED) === true) {
$object = $this->fetchObjectFromPersistence($source['__identity'], $targetType);
if ($object === null) {
$object = $this->buildObject($convertedChildProperties, $targetType);
$this->setIdentity($object, $source['__identity']);
}
} else {
$object = $this->fetchObjectFromPersistence($source['__identity'], $targetType);
if ($object === null) {
return new TargetNotFoundError(sprintf('Object of type %s with identity "%s" not found.', $targetType, print_r($source['__identity'], true)), 1412283038);
}
if (count($convertedChildProperties) > 0 && ($configuration === null || $configuration->getConfigurationValue(PersistentObjectConverter::class, self::CONFIGURATION_MODIFICATION_ALLOWED) !== true)) {
throw new InvalidPropertyMappingConfigurationException('Modification of persistent objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_MODIFICATION_ALLOWED" to TRUE.', 1297932028);
}
}
return $object;
}