[TYPO3-mvc] DAM and relation RELATION_HAS_ONE for single object relation

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu May 27 22:41:33 CEST 2010


Hey there,

I just started porting my extbase baby to the current SVN version and 
ported my changes/patches on extbase from back then to current version. 
Everything seems to work just fine, besides of one thing: Relations 
where the DB has a relation type RELATION_HAS_MANY (MM table) but the 
model is indicating RELATION_HAS_ONE. In those cases, extbase is 
treating the DB relation as RELATION_HAS_ONE and is using the property 
value (which is the number of relations by default) as UID for fetching 
the object which is obviously wrong.

As long as extbase relied on TCA only, everything worked just fine - but 
now it's a mess :(


Example:

-------- TCA (regular DAM field) ------------
'image' => array(
	'label' => 'my image'
	'config' => array(
		'form_type' => 'user',
		'userFunc' => EXT:dam/lib/class.tx_dam_tcefunc.php:&	 
tx_dam_tceFunc->getSingleField_typeMedia',
		'type' => 'group',
		'internal_type' => 'db',
		'allowed' => 'tx_dam',
		'prepend_tname' => '1',
		'MM' => 'tx_dam_mm_ref',
		'MM_foreign_select' => 1,
		'MM_opposite_field' => 'file_usage',
		'MM_match_fields' => array (
			'ident' => 'image',
		),
		#...
		'size' => 1,
		'maxitems' => 1,
		'minitems' => 0
	)
)
---------------------------------------------

--------- Property declaration in my model --
/**
  * image
  * @var Tx_MyExt_Domain_Model_DamMedia
  * @lazy
  */
protected $image;
----------------------------------------------


Everything is working (extbase is resolving the relations and fetching 
objects), except of the fact that I get the wrong images (always the 
image with UID 1). Is there some annotation I can set in my model 
besides of turning it into a ObjectStorage (which is no option for me as 
it's totally awkward to access the single image in fluid then)?

If I start switching the relation type to RELATION_HAS_MANY I get an 
TYPO3 exception that the object type could not be determined, because of 
the missing 'elementType' in my annotation. So does anybody see a chance 
on how to fix those special cases?

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list