[TYPO3-mvc] Where to integrate logic for dependencies among objects - model or repository?

Franz Koch typo3.RemoveForMessage at elements-net.de
Tue Dec 22 15:25:39 CET 2009


Hi,

me again. I've got another question about the correct "extBase" way of 
doing things. As I wrote in my other question "How to implement a 
selectfield/SPLobjectArray containing different object types?" I'm 
currently working on my first extBase extension. The extension is about 
displaying articles from a catalog, in a way comparable to a webshop, 
but without basket and checkout.

And here's my second problem/question:

The very same article can be part of different catalogs and can have 
different prices in each of the catalogs. The price can also vary based 
on the country the visitor comes from. So one article will have several 
prices assigned, but only one price is about to be displayed, based on 
the conditions that get matched (currently selected catalog, country of 
visitor). My question is now, where to put this logic and how to build 
up the models correctly for this.


Currently I have this:

Tx_..._article (entity, aggregate root)
   $title (@var string)
   $articlenumber (@var string)
   $xselling (@var 
Tx_Extbase_Persistence_ObjectStorage<Tx_..._Domain_Model_article>


Tx_..._price (valueObject)
   $value (@var float)
   $article (@var Tx_..._Domain_Model_article)
   $country (@var string) #ISO-code and related to static_info_tables



I created the models using the extbase_kickstarter, but the result looks 
wrong to me - I think I messed up the relations. My article objects 
somehow needs a price property I think, containing the correct price 
object. But where does it come from and at which stage does it have to 
be fetched?

I assume that extbase automatically would fetch all price objects and 
assign it to the article if I built the dependency the other way around, 
but how would I tell extbase then to take the proper conditions into 
account?
If I would fetch the prices by hand, which repository would I have to 
use: a) extend the articleRepository or b) create a priceRepository? And 
how would I hand the values for the conditions over to the repository? I 
could write a method "findPriceByCategoryAndCountry" and hand the 
parameters over to it, but what if another condition comes into place 
(actually I simplified it and have two more conditions, so 4 in total)? 
I can't rewrite all the code only because one condition got added.

Please point me to the right direction - all this DDD stuff new to me.
-- 
kind regards,
Franz Koch

---------------------------------------------------
PayPal-Account: 'paypal _at_ elements-net _dot_ de'
---------------------------------------------------


More information about the TYPO3-project-typo3v4mvc mailing list