My issue: this is a simplified piece of code to demonstrate what I'm trying to do. I need some kind of interaction, a way to instruct the controller what to do when a model parameter is not valid. I'd like to have an automatic validation(before query execution) that the controller is not aware about, a method like
$myModel->validate();
inside the controller seems redundant.
class Controller_User extends Controller
{
public function __construct()
{
parent::__construct();
}
public function msg($text)
{
parent::display(array('message'=>$text));
}
.
.
.
}
class Model_User extends User
{
protected $_controller;
public function __construct($controller)
{
$this->_controller = $controller;
}
public function onParameterNotValid($name)
{
/* here you can have a call to user redirect, a retype of the wrong value, ... */
$this->_controller->msg('Parameter "' . $name . '" is not valid');
}
.
.
.
.
}