[TYPO3-mvc] TCA type "inline" - again

Martin Kutschker masi-no at spam-typo3.org
Fri Jan 1 23:03:54 CET 2010


Hi!

Instead of replying to my previous post I want to start a new thread.

TCA type "inline" is fun when it comes to mapping the data. Let's assume this data model.


   1     n       n     1
CD---------Track---------Recording
title      number        title
tracks     recording     artist
producer   CD

In the TCA the tracks field of the CD is declared as inline. The CD ExtBase model has a property
$tracks defined as Tx_Extbase_Persistence_ObjectStorage<Tx_Track>.

What now happens currently in ExtBase is not really useful and/or buggy as I have explained in my
earlier post.

So let's think about what should happen with the mentioned configuration.

As the property $tracks holds tracks the data mapper must establish a "has many" relation to the
tracks table (what it does is to treat it as a "has many and belongs to many" relation to the
recordings). Ideally it would load also the the recordings form the DB and set the $recording
property of the track object.
 The easy way is to use two selects for this. More complicated would be to load both records in one
go. The SQL is actually easy. The problem is that we would have to prefix of one table (probably the
relation table, "track" in our example), to avoid problems with duplicate fields names.

An alternative approach would be to have a $recordings property in the CD model. If it is declared
as Tx_Extbase_Persistence_ObjectStorage<Tx_Recording> then the data mapper can tread the table
"track" as it were an ordinary MM-table. The drawback of this approach is that you loose all
attributes of the Track objects. So I would think of it as a kind of "second class" property.

What I needed - and I think it was v4 developers expect - is the former setup. This doesn't work at
all. The latter may work, but I haven't tested it yet.

Masi


More information about the TYPO3-project-typo3v4mvc mailing list