I need to send a relationship status between two users (which can has values like 'friends', 'undefined', 'ignore') from a Model into a View.
Inside a template I need to create a links and labels for each case, something like:
switch ($status) {
case 'friends': 'label' = 'Unfriend', 'link' = 'user_controller/unfriend/'.$id;
case 'undefined': 'label' = 'Add to friends', 'link' = 'user_controller/addfriend/'.$id;
...
}
So where should I do this switch - inside a Model and then return array with labels and links, or just return a string and make stuff inside a View. Which way is better?
Yes, I would go for the Model Layer and leave the View just as Template (since using MVP, MVC-inspired). Quoting a great article:
In proper MVC adaptation, the M contains all the domain business logic and the Model Layer is mostly made from three types of - Domain Objects (business logic), Data Mappers (storage) and Services (the bridge communication between other parts)