[TYPO3-mvc] Where to implement the business logic?

Jochen Rau jochen.rau at typoplanet.de
Wed Nov 4 09:36:59 CET 2009


Hi.

Joerg Schoppet wrote:
> Helmut Hummel schrieb:
>>
>> Can anyone give me a hint where to generally put the business logic in
>> case of an extbase extension.
> the webservices I implemented within my extensions worked the following
> way:
> - controller: holds the "business logic", meaning, that the controller
> knows, what to fetch depending on the given request-parameters.

I disagree in one point. The controller does normally not hold any 
business logic. This will lead you to a so called "fat controller" and 
IMO bad design. Keep the controller as slim as possible.

> - view: created the xml-representation of the output (I used the
> "format"-parameter -xml-, so that I used a "simple" fluid-file to create
> the xml, but it is also possible to create a php-view, which creates a
> dom- or simplexml objects and return the generated xml.
> - model(s): rather simple, that it only returns the data I need, no real
> logic for output or something like that

The model can be rather simple. But if there are business rules, it has 
to be implemented here. Lets have an Invoice as Domain Model. All the 
logic how to process Items and aggregate them is inside this Domain 
Model. In some cases it is useful to put the business logic at a 
different place. The logic how to build an Invoice Object can be 
delegated to an InvoiceFactory to keep the Invoice slim ;-). Or, if 
there has to be generated a Serial with complex rules, this can be done 
by a Domain Service like InvoiceNumberService residing in the Folder 
myext/Classes/Domain/Service/.

Regards
Jochen


-- 
Every nit picked is a bug fixed



More information about the TYPO3-project-typo3v4mvc mailing list