[TYPO3-mvc] Copy object and add to repository
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Apr 7 01:31:04 CEST 2011
Hey Fabian,
> thanks, cool solution. I tried a SQL level solution, but thats nicer.
>
> But: it doesn't work with lazy properties. I got an exception, thats one
> argument should be of for example type "Tx...Brand", instance of
> Tx_Extbase_Persistence_LazyLoadingProxy given
>
> If I remove the @lazy addition it works, but makes my application slower.
>
> Is that a known bug?
It's not a bug. In your setters you defined that you expect a certain
class to be passed as argument - if that's not the case PHP is throwing
an exception. The only way to prevent this while keeping lazyLoading is
to first load the real instance of a lazyloaded property and then assign
it to the object:
...
$propertyValue = Tx_....getProperty(....);
if (is_object($propertyValue) && $propertyValue instanceof
Tx_Extbase_Persistence_LazyLoadingProxy) {
$propertyValue = $propertyValue->_loadRealInstance();
}
...
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list