[TYPO3-mvc] Copy object and add to repository

Fabian Fisahn fisahn at its-immaterial.com
Thu Apr 7 09:17:59 CEST 2011


Hi Franz,

On 07.04.11 01:31, Franz Koch wrote:
> 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();
> }

works great!, Thank you.

Is there a comparable method for
Tx_Extbase_Persistence_LazyObjectStorage and/or
Tx_Extbase_Persistence_ObjectStorage?

I didn't find something in the source.

Fabian



More information about the TYPO3-project-typo3v4mvc mailing list