[TYPO3-mvc] ObjectStorage triggers Exception while using Tx_Extbase_Persistence_Manager->persistAll()
Hauke Stange
hstange at eheundjanneck.de
Mon Aug 15 12:55:24 CEST 2011
Hi there.
I want to store some DomainObjects via their corresponding Repository.
Those objects have an one to many relationship and therefore an
ObjectStorage whith one of their property.
I add those objects to the repository by using replace() and add(). But
when calling persistAll() I got the following exception:
"An object of class "Tx_Extbase_Persistence_ObjectStorage" could not be
converted to a plain value."
When I look at the method which throws this exception I somehow get
confused. It's thrown by Typo3DbBackend->getPlainValue() due to the fact
that an ObjectStorage doesn't implement
Tx_Extbase_DomainObject_DomainObjectInterface. I thought this mapper
stuff does all the handling with those object relationships?
What am I doing wrong?
protected function updateVersorgungsbereiche(array $versorgungsbereiche)
{
$indexBereich = array();
$repo =
t3lib_div::makeInstance('Tx_Gpqg_Domain_Repository_VersorgungsbereichRepository');
foreach ($repo->findAll() as $bereich) {
$indexBereich[$bereich->getBereich()] = $bereich;
}
foreach ($versorgungsbereiche as $versorgungsbereich) {
if (in_array($versorgungsbereich->getBereich(),
array_keys($indexBereich))) {
$repo->replace($indexBereich[$versorgungsbereich->getBereich()],
$versorgungsbereich);
} else {
$repo->add($versorgungsbereich);
}
}
$persistenceManager =
t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();
}
Regards,
Hauke
More information about the TYPO3-project-typo3v4mvc
mailing list