I have an application the is loaded with forms in every view. I've become rather familiar with CakePHP's array syntax and I use the $this->data parameter a lot.
I fell in love with skinny controllers and fat models, so I put as much code in my models as is possible. Unless I'm doing something complex, most of my controller methods look like this:
function some_action() {
$this->set('data', $this->Model->some_action($this->data));
}
Then, in my Model, I have a method that takes one parameter:
function some_action($this_data = NULL) {
// do some stuff, manipulate the data etc.
$this->create();
if ($this->save($this_data)) {
// return success message here
}
}
I've oversimplified, but you get the idea.
My question: I always send $this->data to my model and catch it with a variable, $this_data. However, I was wondering if this is one step too many? Does the Model inherit $this->data? If so, could I change the above controller method to this:
function some_action() {
$this->set('data', $this->Model->some_action());
}
And then manipulate $this->data in my model instead of the $this_data variable I've been using? What would be the best practice?