public function getter($element, $chain, EntityMetadata $sourceEntityMeta)
{
$column = array_shift($chain);
$propertyMeta = $sourceEntityMeta->getProperty($column);
// check if property exists
$value = $element->hasValue($column) ? $element->getValue($column) : null;
if ($value instanceof IRelationshipCollection) {
throw new InvalidStateException('You can not sort by hasMany relationship.');
}
if (!$chain) {
return $this->normalizeValue($value, $propertyMeta);
} else {
$targetEntityMeta = $this->metadataStorage->get($propertyMeta->relationship->entity);
return $this->getter($value, $chain, $targetEntityMeta);
}
}