[TYPO3-mvc] extbase: relations simple question

Jochen Rau jochen.rau at typoplanet.de
Thu Feb 18 12:38:19 CET 2010


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).

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;
  [...]

}

>> 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.

Regards
Jochen



More information about the TYPO3-project-typo3v4mvc mailing list