[TYPO3-mvc] Single table inheritance (extbase)

Jochen Rau jochen.rau at typoplanet.de
Fri Dec 18 15:01:31 CET 2009


Hi Steffen.

schrieb Steffen Ritter:
> Jochen Rau schrieb:
>> 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 .
>
> Hey Jochen,
> i don't know if it's "enough". Think of 4 extensions extendending
> fe_user table extending generic object and you extension wants to use
> all of the otheres - if available.

It's never enough ;-). Think about integration in TCEforms ...

I don't intend to implement support for traits/mixins in this first step 
(e.g. a class extends multiple classes on the same hierarchical level). 
Those are really complicated to deal with and I am not sure if we should 
support traits/mixins at all.

We should now focus on the "regular" class hierarchy. This has the 
drawback of multiple class hierarchies if you want to add properties or 
functionality from different extensions.

But in this first step we are able to support the most important 
usecase. Mapping a class hierarchy inside a _single_ extension.

> It's same case as of fe content-elements. they are all compatible
> objects using. so their has to be a dynamic possibility to say "get me
> this record as objectxy" or define repository get my objects as main
> type oder subtype etc.

The "dynamic possibility" is currently implemented half-way in Extbase: 
The DataMapper slides up-the class hierarchy unless he finds a class 
that has a configured table. An example:

class Tx_MyExt_Domain_Model_Person
extends Tx_Extbase_Domain_Model_FrontendUser
extends Tx_Extbase_DomainObject_AbstractEntity {}

Let's assume we have a table tx_myext_domain_model_person. The 
DataMapper tries to find records holding data of an Object 
Tx_MyExt_Domain_Model_Person. It resolves the table 
tx_myext_domain_model_person and we're done.

Now, let's assume we have no table tx_myext_domain_model_person but a 
table fe_users which is mapped on Tx_Extbase_Domain_Model_FrontendUser 
by configuration (works already). The DataMapper could not find a table 
tx_myext_domain_model_person. He goes on to the parent class 
Tx_Extbase_Domain_Model_FrontendUser resolves the table fe_users and 
we're done again.

Unfortunately there is no way to resolve the target class of a tuple of 
fe_users without having the uids. The proposed way adds the appropriate 
field. In case of tt_content we can reuse the information from CType.

> But in general you "idea" would help (me too) but sounds a bit
> "geflickschustert".

Oh, I definitely strive for a clean solution without "Flicken". ;-)

Regards
Jochen

-- 
Every nit picked is a bug fixed



More information about the TYPO3-project-typo3v4mvc mailing list