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

Zoran Zaric lists at zoranzaric.de
Thu Dec 23 10:31:38 CET 2010


On 23.12.2010 09:49, Franz Koch wrote:
> Hey Zoran,
> 
>>> you can only do this by extending the FrontentUser class and add the
>>> new fields in your own class and use this class throughout your
>>> extension. Mixins (which would be needed to merge additional fields in
>>> existing classes) are not supported yet.
>>>
>> This is exactly what i plan to do.  I'm not sure what to store in my
>> model's table though.
> 
> What do you mean? I suppose your model belongs to a fe_user and you're
> not sure how to set up everything to use your fe_user model instead of
> the default one?


I'm sorry if it wasn't clear.  I want to inherit from
Tx_Extbase_Domain_Model_FrontendUser so objects of my model can be used
as fe_users.

Also I want to add fields only to my model not to the fe_user in general.

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.


> I see two options here:
> 
> a) use single table inheritance by adding a new option to the
> tx_extbase_type field of the fe_users and make it default for all of
> your users. This only works as long as you don't have to extend the
> fe_users from a second extension also.


With this I'd change the fe_user, right?  I don't think this is what I want


> b) directly assign and use your extended fe_user model throughout your
> extension. To get this working all you have to do is to also create your
> own repository to fetch the user objects (probably extending the fe_user
> repository) and provide a mapping information via TS:
> 
> config.tx_extbase.persistence.classes {
>     // name of your own fe_user class name
>     Tx_YourExt_Domain_Model_User {
>         mapping {
>             tableName = fe_users
>             columns {
>                 lockToDomain.mapOnProperty = lockToDomain
>             }
>         }
>     }
> }


yeah this would map the whole table to the fe_users table.  In the
database I need a table for my model to save the model-specific data,
though.

Thanks,
Zoran


More information about the TYPO3-project-typo3v4mvc mailing list