Since you must do this step every time a request is executed, you can save this technique, analyze and check the received request in Zend_Controller_Plugin, which will be executed every PreDispatch all controllers. (Only if your XML request is standardized) (if you use XMLRPC , REST or the standard way to create requests to your service, you can view these modules created in ZF)
Data validation (action-specific) can be performed in the controller method (which will then be called by the action (s) requiring it) (if your parameters are specific to one or many actions of this controller) or you can do this using Factory templates and Builder in case you have many common parameters between controllers / actions
// call to the factory $filteredRequest = My_Param_Factory::factory($controller, $action, $paramsArray) // call the right builder based on the action/controller combination // the actual Factory class My_Param_Factory { public static function factory($controller, $action, $params) { $builderClass = "My_Param_Builder_" . ucfirst($controller) . '_' . ucfirst($action); $builder = new $builderClass($params); return $builder->build(); } }
Then your builder will call certain parameters to check classes based on the needs of a particular builder (which will improve reuse)
In your controller, if all the necessary parameters are valid, you pass processing to the correct method of the correct model
$userModel->getUserInfo($id)
To remove all data processing operations from the controllers, which would have to check whether the input is normal, and then send accordingly.
Save the results (error or sequence) in a variable that will be sent to the view
Process the data (format and escape (replace <with & lt; if they should be included in the response, for example)), send the view to XML helper to the assistant, then print ( echo ) the data in the view (which will be the answer for your user).
public function getDetailsAction() { if ($areRequestParamsValid === true) { // process data } else { // Build specific error message (or call action helper or controller method if error is general) } $this->view->data = $result }