[TYPO3-mvc] Single table inheritance (extbase)

Jochen Rau jochen.rau at typoplanet.de
Thu Dec 17 21:40:47 CET 2009


Hi Kristian.

> I have four classes: abstract Location, Hall, WorkOfArt and Exhibition.
> Hall, WorkOfArt and Exhibition all extend Location, and have the
> properties: title and description.
> Halls contains artworks.
> Exhibition contain a mix of halls and artworks.
>
> I would prefer to persist the three classes: Hall, WorkOfArt and
> Exhibition In the same tx_..._location table and distinguish the record
> types by a location_type column.
> The reason for this is that I then in my tca could write:
>
> $TCA['tx_smkfloorplan_domain_model_location'] = array(
> ....
> 'columns' => array(
> //Mix of halls and artworks
> 'locations' => array(
> ...
> 'config' => array(
> 'foreign_table' => 'tx_..._location'
>
> My problem is then with the DataMapper, since the the objectType is
> given by the repository.
>
> Do you have any suggestions for solving my problem apart from extending
> the DataMapper and overwriting mapSingleRow. How would you solve the
> mixed list situation, with the default "concrete table" strategy?

Ahh, funny! I thought a lot about how to support single table 
inheritance the last few days. This is one of the last cornerstones to 
build generic domain models, and to map tt_content on 
Tx_Typo3_Domain_Model_Content_TextWithImage ;-) . And it enables us to 
build a very flexible Content Model on top of the existing ones. 
(Actually Extbase/Fluid renders the whole body output of my development 
environment. I am really looking forward to have FCEs \w TemplaVoila ;-) ).

My current conception is to have a column tx_extbase_target for every 
table responsible for multiple concrete classes. And to implement a 
mapping rule for legacy tables (like CType -> target class). This can be 
defined in config.tx_extbase.persistence.classes .

Any further suggestions or use cases?

Regards
Jochen






-- Every nit picked is a bug fixed



More information about the TYPO3-project-typo3v4mvc mailing list