protected function convertElementToValue(\XMLReader $reader, $currentType, $currentEncoding, $currentClassName, $currentNodeIdentifier, $currentProperty)
{
switch ($currentType) {
case 'object':
if ($currentClassName === 'DateTime') {
$stringValue = trim($reader->value);
$value = $this->propertyMapper->convert($stringValue, $currentClassName, $this->propertyMappingConfiguration);
if ($this->propertyMapper->getMessages()->hasErrors()) {
throw new ImportException(sprintf('Could not convert element <%s> to DateTime for node %s', $currentProperty, $currentNodeIdentifier), 1472992032);
}
} elseif ($currentEncoding === 'json') {
$decodedJson = json_decode($reader->value, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new ImportException(sprintf('Could not parse encoded JSON in element <%s> for node %s: %s', $currentProperty, $currentNodeIdentifier, json_last_error_msg()), 1472992033);
}
$value = $this->propertyMapper->convert($decodedJson, $currentClassName, $this->propertyMappingConfiguration);
if ($this->propertyMapper->getMessages()->hasErrors()) {
throw new ImportException(sprintf('Could not convert element <%s> to %s for node %s', $currentProperty, $currentClassName, $currentNodeIdentifier), 1472992034);
}
} else {
throw new ImportException(sprintf('Unsupported encoding "%s"', $currentEncoding), 1404397061);
}
break;
case 'string':
$value = $reader->value;
break;
default:
$value = $this->propertyMapper->convert($reader->value, $currentType, $this->propertyMappingConfiguration);
if ($this->propertyMapper->getMessages()->hasErrors()) {
throw new ImportException(sprintf('Could not convert element <%s> to %s for node %s', $currentProperty, $currentType, $currentNodeIdentifier), 1472992035);
}
return $value;
}
$this->persistEntities($value);
return $value;
}