[TYPO3-mvc] Re: Need resources: create translation of extbase domain object.

Philipp Wrann philippwrann at gmail.com
Tue Sep 15 13:36:53 CEST 2015


Loading the translated entity from persistence is NOT possible if the original language has allready been loaded.

That way you can create new initial translations but you are not able to load an objects translation.

So its kind of useless. I ended up with 350 translations per record before recognized the problem...

$persistenceSession = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
/* @var $persistenceSession \TYPO3\CMS\Extbase\Persistence\Generic\Session */
$persistenceSession->unregisterObject($object);

Then i can receive the translated entity.

BUT then i can not update that entity, it throws an exception:
The object of type "..." given to update must be persisted already, but is new

But when i debug the entity it says "persistent entity"

$persistenceSession->isReconstitutedEntity($translated) also returns TRUE.

When doing:
$persistenceSession = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
/* @var $persistenceSession \TYPO3\CMS\Extbase\Persistence\Generic\Session */
$persistenceSession->unregisterObject($object);
$query = $this->repository->createQuery();
$query->getQuerySettings()->setLanguageUid($sysLanguageUid);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->getQuerySettings()->setLanguageMode('strict');
$query->getQuerySettings()->setIgnoreEnableFields(TRUE);
$query->matching($query->equals('uid',$object->getUid()));
$translated = $query->execute()->getFirst();
if ($translated === NULL) {
	$translated = $this->getNewTranslation($object, $sysLanguageUid);
} else {
	$persistenceSession->registerObject($translated,$object->_getProperty('localizedUid'));
}
$persistenceSession->registerObject($object,$object->getUid());
return $translated;

it seems that i can modify and update both - but i am very sure something else will break because that is kind of a lowlevel hack.

Can anyone give me a hint here?


More information about the TYPO3-project-typo3v4mvc mailing list