I am using zend framework and this is the skeleton of my model and controller methods
Model Class methods :
_validateRegisterForm($postData)
{
//validating data using Zend_Filter_Input
//Returns instance of Zend_Filter_Input
}
//Return true/false
protected _isNumberAlreadyExists()
{
// I dnt want to perform above validation using zend_validate_db_recordexists
//since i dnt want to mix my dblogic with in buisness logic
}
register($postData)
{
$input=$this->_validateRegisterForm($postData);
if(!$input->isValid())
{
//What should it return to controller
}
if(!$this->_isNumberAlreadyExists($input->number))
{
//What should it return to controller
}
}
controller class api
$this->_model->register($postData)
I want given below condition to return error in same format to controller class
if(!$input->isValid())
{
//What should it return to controller
}
if(!$this->_isNumberAlreadyExists($input->number))
{
//What should it return to controller
}
I can simply return false from model class but for that i have to save zend_filter_Input instance or error message(if number already exists).Thus in that case i have to create another error handler object which can convert error messages into common format and let controller to fetch those error
To me it does not look like a proper way of doing things in zend framework. Would somoneone like to help me about passing error from model to controller in zend framework or suggest some other method to handle errors in zend framework