[TYPO3-mvc] How to extend a model class from within another extension?

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Sat Jan 16 23:35:47 CET 2010


Thanks - I tried this, but it didn't change anything.

I'm wondering if it is even possible to extend a model from within
another extension, which (the model) is called via the model repository.

If I extend the model with a new model class, the repository of the
'old' model, should return the new model - which it doesn't.

For better understanding I want to get more into detail.

Let's call extension 1 'ext_old' and extension 2 'ext_new'.
ExtOld holds a 'Product' model and a 'Product' repository.

Now this model has getters and setters for the properties,
which are defined as fields in the SQL file and the TCA.

Now I create ExtNew, which extends the 'Product' model of ExtOld:

Tx_ExtNew_Domain_Model_Product extends Tx_ExtOld_Domain_Model_Product{}

Inside the NewExt 'Product' model I declare new setters and getters
for new fields, which have also been added to the database and the TCA,
inside the extension ExtNew.

So inside the extension ExtNew I have extended the old Product database
table, the TCA of the 'old' Product table and, of course also the model,
as already described.

Inside ExtOld, there is the ProductController, which displays the
data of the Product model, with help of Fluid.

Now to fetch products inside this 'old' controller, I use a singleton
Repository, let's call it the 'old' Product repository:

$this->productRepository = 
t3lib_div::makeInstance('Tx_ExtOld_Domain_Repository_ProductRepository');

And in my oppinion, this repository SHOULD return the NEW model objects
of which the class is defined in ExtNew (Tx_ExtNew_Domain_Model_Product),
which is NOT the case - it will always return the 'old' model.

So, I'm wondering if it is possible to tell Extbase to take the new class?!

Note: This is a DIFFERENT approach, than extending the Extbase FeUser
model with a new class, and then instantiating this NEW class 
explicitly, which is - indeed - working well!

So, I think extending an existing model and getting Extbase to 
automatically return the new model, using the 'old' repository,
won't really work - or do I miss something here?

I don't think there is an appropriate mapping definition,
I could use, using TypoScript - or am I wrong?

Any ideas about this?

Thanks a lot,
Thomas


Franz Koch schrieb:
> Hi,
> 
>> The mapping for the new object class looks like this:
>>
>> config.tx_extbase {
>>   persistence {
>>     classes {
>>       Tx_Ext_Domain_Model_Object {
> 
> Try plugin.ext_name.persistence.classes...
> 


More information about the TYPO3-project-typo3v4mvc mailing list