MVC best practice when adding functions to controller?
- by Patrick
Hi
I'm writing a function in my controller; this is supposed to take in a form, process it, register the user in DB, send a confirmation email etc etc.
to avoid this function to be too cluttered, I was thinking of calling some sub-functions (eg:
function registration()
{
//process form..
_insertInDb($formdata)
_send_mail($address);
//load confirmation view..
}
function _send_mail($to)
{
//code here
}
function _insertInDb($formdata)
{
//other code here...
}
I'm not sure whether writing all the functions in the controller would be best practice -maybe I should insert all 'supporting' function (eg send_mail and insertInDb in this example) in another file and then import them?
This would probably make the controller much more readable..
what's your view?