protected function getLatestVersion($element)
{
//TODO move this maybe to a service method, since this is also used in ObjectController and DocumentControllers
if ($element instanceof Document) {
$latestVersion = $element->getLatestVersion();
if ($latestVersion) {
$latestDoc = $latestVersion->loadData();
if ($latestDoc instanceof Document) {
$element = $latestDoc;
$element->setModificationDate($element->getModificationDate());
}
}
}
if ($element instanceof Object\Concrete) {
$modificationDate = $element->getModificationDate();
$latestVersion = $element->getLatestVersion();
if ($latestVersion) {
$latestObj = $latestVersion->loadData();
if ($latestObj instanceof ConcreteObject) {
$element = $latestObj;
$element->setModificationDate($modificationDate);
}
}
}
return $element;
}