[TYPO3-mvc] Overwriting TCA (fe_users)

Florian Staudacher florian_staudacher at yahoo.de
Mon Jul 12 16:05:08 CEST 2010


> Try to add these properties:
> 
> 'minitems' => 0,
> 'maxitems' => 9999,
> 
> to your TCA Inline configuration. As far as I remember the Extbase
> Relation parser needs this to identify it as one-to-many relation.
> 
> Hope that helps
> 
> Micha

Now that the other relation works, I would like to add another one to 
fe_users. 
This time it is M:N, a "watchlist": a product can be watched by many users and 
one user can watch many products.

I copied the TCA from a already working M:N relation:

user tca:
--- code ---
	'watchlist' => array(
		'exclude' => 0,
		'label'   => 'bla',
		'config'  => array(
			'type' => 'select',
			'size' => 10,
			'minitems' => 0,
			'maxitems' => 99999,
			'autoSizeMax' => 30,
			'multiple' => 0,
			'foreign_table' => 'tx_myext_domain_model_product',
			'MM' => 'tx_myext_customer_product_mm',
			'MM_opposite_field' => 'watched',
		)
	),
--- / code ---

product tca:
--- code ---
	'watched' => array(
			'exclude' => 0,
			'label' => 'bla',
			'config' => array(
				'type' => 'select',
				'size' => 10,
				'minitems' => 0,
				'maxitems' => 99999,
				'autoSizeMax' => 30,
				'multiple' => 0,
				'foreign_table' => 'fe_users',
				'MM' => 'tx_myext_customer_product_mm',
			),
		),
--- / code ---

In the BE this works fine (it seems that the BE relation parser is far more 
tolerant), but extbase refuses to do what I want with:

Tx_Extbase_Persistence_Exception
Could not determine type of relation for the property "watchlist". This is 
mainly caused by a missing type declaration above the property definition. If 
the PHPDoc comment is there, make sure it starts with "/**" and not just with 
"/*".

And yes, I quadruple checked my model for the correct PHPDoc, it looks like 
this:

--- code ---
/**
  * watchlist
  * @var Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Product>
  * @lazy
  */
protected $watchlist;

/**
  * Getter for watchlist
  *
  * @return 
Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Product> watchlist
  */
public function getWatchlist() {
	return $this->watchlist;
}
	
/**
   * setter for watchlist
   * @param 
Tx_Extbase_Persistence_ObjectStorage<Tx_MyExt_Domain_Model_Product> $watchlist 
   * @return void
   */
public function setWatchlist(Tx_Extbase_Persistence_ObjectStorage $watchlist) 
{
	$this->watchlist = $watchlist;
}
--- / code ---


I'd find it very nice if someone would find the time to write "The definitive 
guide to 1:1, 1:m and m:n relations in extbase and the $TCA" ... :-)

Thanks for the help!
Florian


More information about the TYPO3-project-typo3v4mvc mailing list