[TYPO3-mvc] extbase: relations simple question

Dmitri Pusarev dimaip at gmail.com
Thu Feb 18 12:57:05 CET 2010


Hi Jochen.
Jochen Rau wrote:
> Hi Dmitry.
> 
> On 18.02.10 11:58, Dmitri Pusarev wrote:
>>> If you have defined your relation Client<->Project to use a foreign
>>> key you only have to apply one wire. The Kickstarter will add a
>>> property "client" to your Project automatically and "fills" it with
>>> the related Client.
>> Where does it add it to? I have created a relation from Client to
>> Project, zero to many foreign field, and called it projects.
>> Then I saved, and opened the Project model file, and there is no Client
>> property defined. Is it some kind of magic property that it does not
>> have to be in the model file? Really I don't get it:(
> 
> Whoops. I was to fast ;-)
> 
> It doesn't add it automatically (and it should not do that).
That makes sense. Maybe in the relation setup add a checkbox to create a 
relation the other way, when necessary.
> 
> Simply add the property manually as done in the BlogExample:
> 
> class Tx_BlogExample_Domain_Model_Post extends 
> Tx_Extbase_DomainObject_AbstractEntity {
> 
>     /**
>      * @var Tx_BlogExample_Domain_Model_Blog
>      * @lazy
>      */
>     protected $blog;
>  [...]
> 
> }
What is the difference of adding it manually instead of just adding 
another relation wire in kickstarter with zero to one relation, as I do?
> 
>>> The foreign key field "client" holds the uid of the client. As the
>>> property "client" is annotated with the class name, Extbase tries to
>>> translate the uid in the appropriate Client object.
>>>
>>> In your Client there will be a property "project" holding all related
>>> Project objects as expected.
>>>
>>> Be aware of circular dependencies (building a Project->building
>>> related Client->building Projects->building Client .....). Try to add
>>> @lazy to the "client" property if necessary.
>> Where can I read more about @lazy and other things? I've just read the
>> docs for extbase from svn.
> 
> We are aware of the lack of proper documentation. At the T3BOARD10 I'll 
> meet with Franz Ripfel to update the Quick Start Guide.
Yeah, that'd be great! So far most of the knowledge I gained from the 
source, debugging my extension. Btw, I'm glad that kickstarter didn't 
work for me from the beginning, so I spent two month learning to do 
everything manually.
> 
> Regards
> Jochen
> 

Thanks for your help!
Dmitri.


More information about the TYPO3-project-typo3v4mvc mailing list