protected function convertValue($propertyValue, $dataType)
{
$rawType = TypeHandling::truncateElementType($dataType);
// This hardcoded handling is to circumvent rewriting PropertyMappers that convert objects. Usually they expect the source to be an object already and break if not.
if (!TypeHandling::isSimpleType($rawType) && !is_object($propertyValue) && !is_array($propertyValue)) {
return null;
}
if ($rawType === 'array') {
$conversionTargetType = 'array<string>';
} elseif (TypeHandling::isSimpleType($rawType)) {
$conversionTargetType = TypeHandling::normalizeType($rawType);
} else {
$conversionTargetType = 'array';
}
$propertyMappingConfiguration = $this->createConfiguration($dataType);
$convertedValue = $this->propertyMapper->convert($propertyValue, $conversionTargetType, $propertyMappingConfiguration);
if ($convertedValue instanceof \Neos\Error\Messages\Error) {
throw new PropertyException($convertedValue->getMessage(), $convertedValue->getCode());
}
return $convertedValue;
}