I have some pretty heavy functions that I've placed in my model class because I need them to be accessible through many interfaces on the site. But how can I call these functions from my controller class? Here's the best thing I can come up with:
public function myFunction()
{
$model_class = str_replace(get_class($this), "_Controller", "");
return DataObject::get_by_id($model_class,$this->ID)->myFunction($arg1, $arg2);
}
Ordinarily, I'd just call the function normally from the template, but the controller is used to parse data out of the url first, and then pass it to the model with $arg1, $arg2...
Does it have to be that ugly?