[TYPO3-mvc] Extending an existing model and adding fields

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Dec 23 14:58:54 CET 2010


Hi,

>>> I think an example helps clarifiying this.
>>>
>>> The administrator model only inherits from FrontendUser, it doesn't add
>>> anything.  I'd like to have a model - let's call it Customer - which
>>> inherits from FrontendUser but also has member variables like for
>>> example an address.
>>>
>>> I can now add a member variable address and a getter and setter to my
>>> Customer model.  What I don't know is how to make this persistent.
>>
>> The magic words are single table inheritance. Different models using the
>> same table for data storage and each having shared but also different
>> properties available. Isn't that an option for you?
>
>
> Like i seid above, I hoped extbase would bring a - in my eyes - cleaner
> approache.

well, it's still based on Typo3 v4.


>> Ok, so you really don't want to touch the fe_users table. The only
>> possibility I see then is to do the implementation upside down. I'd then
>> create a customer table and model, and add a property "credentials" or
>> "login" to that model, where this would be the relation to the
>> FrontendUser. The FrontendUser itself would only be used to save the
>> credentials as well as the usergroups. That's what I did in a current
>> project, but this also has quite some downsides if you have to interact
>> with foreign extensions. You really get in trouble with those ones
>> relying on fe_user data like first_name or last_name, which would not be
>> available in the fe_users table as you store this information in your
>> own table then. So if you need this information also in the fe_users
>> table, you either have to map your getters and setters to fetch/save the
>> data directly in the FrontendUser or keep the relevant data in both
>> tables in sync. I'm currently still struggling on how to do it best -
>> either have a clean domain model and redundancy or a working solution
>> but scattered data.
>>
>> Another downside is that you can't easily use directmail with
>> personalization then unless you modify it to be able to fetch the
>> userdata from your custom table (that's also a issue I have to deal with
>> currently).
>
> Yeah that sound like a even worse solution.
>
> Thanks for the clarification.

Ok - just had a look at direct_mail and found a solution for the 
personalization stuff (can use a hook to inject the missing fields) and 
also have a idea how to pollute the TSFE->fe_user with data from my 
model, so that most stuff should work with this aproach (finally).

> Do you know if "multi table inheritance" is planned?  What are the
> proposed solutions for FLOW3 for this problem?

no sorry, I didn't follow FLOW3s development for quite some time.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list