[TYPO3-mvc] RFC: #8083 define default __toString method in Tx_Extbase_DomainObject_AbstractDomainObject

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Nov 10 11:50:07 CET 2010


Hey,

>>>> Solution:
>>>> Add magic method __toString to return the uid
>>>
>>> What about [<class name>:<uid>]? The uid conveys very little information.
>>
>> For debugging you are right.
>>
>> For linking to an related object you use {enterprise : job.enterprise}.
>> This would fail when the related object is defined as lazy
>> (see<http://forge.typo3.org/issues/10702>)
>>
>> Returning the uid fixes this.
>
> I assume you mean linking in a FLUID context, right? Anyway, I am not against adding a default to
> string even if it shows only the uid.
>
> But I have a problem if the reason seems to be to provide a workaround. If some code needs the uid
> of object it should ask for it. Why? Because I can use a custom implementation of __toString() which
> may return something else.
>
> I suggest to fix the problem with the lazy loader first before applying a patch that only hides the
> problem.

I only can second Martins thoughts and think this should be fixed in the 
LazyLoadingProxy, although I ran into that bug just a few hours ago. For 
me the workaround was to use {enterprise: job.enterprise.uid}.

The __toString method is supposed to return a string, and not the uid.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list