Need some advice on MVC separation..

Posted by Zenph on Stack Overflow See other posts from Stack Overflow or by Zenph
Published on 2010-12-22T11:53:12Z Indexed on 2010/12/22 12:54 UTC
Read the original article Hit count: 189

Filed under:
|

I should note I am using Zend Framework. Although this shouldn't affect the concrete answer, it does mean there are several places I can implement my following method (action helper, controller etc).

The issue is I have buildOptions() and parseOptions() method which takes $_GET/$_POST variables based on a 'tag' and builds rules which are then used in a select query. An example would be ?modelSort=id&modelOrder=asc

The 'model' in the above obviously relates to the particular model, and it used as a 'tag' so that I can for example also have model2Sort and model2Order so there is no conflict between parameters.

However, the trouble I am having now is where should these methods go? They are generally dealing with request params. I have been reading a lot about fat model, thin controller. Should this be in an abstract model. My thinking was that if it were, I would do something like:

(note, I know I wouldn't call directly like this. Method would be used by child classes)

$abstractModel->buildOptions($params);

Where 'params' could be anything, like the request parameters $_GET or $_POST:

$abstractModel->buildOptions($_GET);

Now from what I can see the model is not inherintly dealing with request variables but rather parameters passed to the method.

Advice? Where does this method belong? Model, Controller?

Specifically on Zend, should it be an action helper, plugin, within an abstract model?

Appreciate any advice.

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-framework