[TYPO3-mvc] How to design/structure complex find operations?

Nikolas Hagelstein lists at shr.cc
Mon Jan 24 15:33:32 CET 2011


Hi,

let's assume i got a controller action which is supposed to find and 
output a list of records. The find conditions, orderings, query settings 
and limits should vary on lets say:
- controller::settings (e.g. defined by the pluginsflexform)
- controller::arguements.

The easy straight forward way would be to create a repository find 
function taking tons of arguments and ending up with an action 
consisting of thousand of nested conditions ;).

The above solution would be very hard to read and even harder to test. 
Therefore i am looking for a cleaner approach in terms of readability 
and testability.

I am currently thinking of something like this:

Controller uses findConfigurationFactory to create a findConfiguration 
object from given settings and arguments.

Controller passes findConfiguration to Repostitory::findByFindConfiguration

Repository::findByFindConfiguration creates query, constraints, 
orderings and limits from findConfiguration, executes the query and 
returns the result.

That would enable me to seperatly test:
- The creation of the findCondition
- The creation of constraints, limits and orderings.

Though this solution seems more clean to me it still feels a little 
"smelly" and incomplete.

Furthermore i don't like the name "findConfiguration".

What do you think?

Cheers,
Nikolas











More information about the TYPO3-project-typo3v4mvc mailing list