[TYPO3-mvc] M:M relations with fe_user as foreign table

Pascal Jungblut mail at pascal-jungblut.com
Wed Sep 30 17:51:59 CEST 2009


Hello,

I'm currently working with Extbase (from svn) and I encountered a  
problem with M:M Tables and fe_users.

My setup:

Tx_MyExt_Domain_Model_Person extends  
Tx_Extbase_Domain_Model_FrontendUser {
}


--- snip ---
TCA:
$GLOBALS['TCA']['fe_users']['columns']['friends'] = array(
	'exclude' => 1,
	'config' => array(
		'type' => 'select',
		'size' => 10,
		'minitems' => 0,
		'maxitems' => 9999,
		'autoSizeMax' => 30,
		'multiple' => 1,
		'foreign_class' => 'Tx_MyExt_Domain_Model_Person',
		'foreign_table' => 'fe_users',
		'MM' => 'tx_myext_person_friend_mm',
		'MM_insert_fields' => array('tablenames' => 'fe_users'),
		'MM_match_fields' => array('tablenames' => 'fe_users'),
	)
);

--- snip ---

The tx_myext_person_friend_mm is an exact copy of another M:M table  
I'm using but without fe_users as the foreign_table. So the M:M table  
with foreign_table = tx_myext_domain_model_another_object works. But  
when I want to access $person->getFriends() I get an error that $this- 
 >friends in Tx_MyExt_Domain_Model_Person is not an object, even  
though I did:

--- snip ---
$this->friends = new Tx_Extbase_Persistence_ObjectStorage();
--- snip ---

...in the constructor of the Person class.

Note: In the constructor itself, directly after instantiating $this- 
 >friends, it is instanceof(Tx_Extbase_Persistence_ObjectStorage).  
When I call the getter/setter it's no object any more.

Any hints on how to use fe_user as a foreign table with a different  
class than Tx_Extbase_Domain_Model_FrontendUser?

Greetings,
Pascal


More information about the TYPO3-project-typo3v4mvc mailing list