In a "common" application, the controller forwards the data in a ViewModel
object to the view. There it can be prepaired for the output, e.g.
`id` -> `/foo/bar/` . `$course->id` -> `link`
`firstname` and `lastname` -> `$course->name` -> `name`
`date` -> `AgeHelper(`$course->date`)` . ' years old.' -> `age`
etc. ...
Now I'm developing a RESTful application and missing this view level. It's currently working like this:
Controller
public function get($id)
{
$course = $this->getCourseTable()->findOnceByID($id)->current();
$viewModel = $this->acceptableViewModelSelector($this->acceptCriteria);
$viewModel->setVariables(array('data' => array(
'id' => $course->id,
'created_at' => $course->created_at,
'details' => $course->details,
)));
return $viewModel;
}
But it's only sufficient for shallow data structures. Where should the data be processed / prepaired for the ViewModel
?
- Controller? No, not in the controller.
- Model? Not in the model table or mapper class.
- View? would be nice, but there is no views.
So, where?
Thanks