[TYPO3-mvc] [!!!] FYI: Implemented first version of single table inheritance.

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Wed Apr 21 15:12:18 CEST 2010


Thanks for your reply. This may be a temporary tweak but for the future 
- when there will be more and more product models - it will take too 
much effort to update the controllers again and again. (The update of 
the code would effect a lot of places so.)

Regards,
Thomas

Am 21.04.2010 14:43, schrieb Felix Oertel:
> Hi,
>
> Am 21.04.10 14:11, schrieb Thomas "Thasmo" Deinhamer:
>> When now the action 'product' is called with the product object,
>> it doesn't know which product type (Book, Furniture, Tv) will be
>> passed as argument, so therefor I just can check for the parent:
>>
>> public action product(Tx_MyExt_Domain_Model_Product $product){};
>>
>> If I write it this way...
>> public action product(Tx_MyExt_Domain_Model_BookProduct $book){};
>> Extbase will complain if a TvProduct or FurnitureProduct gets passed.
>>
>> But imho I would like to get an instance of either
>> Tx_MyExt_Domain_Model_BookProduct OR
>> Tx_MyExt_Domain_Model_FurnitureProduct OR
>> Tx_MyExt_Domain_Model_TvProduct.
>
> You could write
>
> procduct(Tx_..._BookProduct $book, Tx_..._FurnitureProduct $furniture,
> Tx_..._TvProduct $tv) {}
>
> and check, which object is given. IMHO this is kind of bad design ...
> either you just need the shared properties of all objects (then
> Tx_..._Product should be fine) or you want to work with properties not
> shared among all models then dedicated methods would fit your needs.
>
> I've got the same task ... list some photos by photographer, location,
> event. i decided to use indexByPhotographer($photographer),
> indexByLocation($location) instead of using index($photographer,
> $location, ...). Template will be different for each type in most cases
> (you would not header your TvProduct with "wonderfull book: {title}", so
> it's easier to work with sole methods, templates and share partials
> amongst them.
>
> regards, foertel


More information about the TYPO3-project-typo3v4mvc mailing list