I'm developing a RESTful application on Zend Framework 2 basis. Just implemented the get(...)
method of the controller:
class SeminarsController extends RestfulController
{
/**
* @var Zend\Db\TableGateway\TableGateway
*/
private $seminarTable;
...
public function get($id)
{
$seminarDetails = $this->getSeminarsTable()->findOnceByID($id)->current();
return new JsonModel(array('data' => array(
'id' => $seminarDetails->id,
'title' => $seminarDetails->title,
'details' => $seminarDetails->details
)));
}
...
}
Works fine. But now it's bound to a hard defined output format -- JSON. How can/should I make it more flexible, in order to enable the user/client to get the output in different formats?
EDIT
What I want to know is, what structure/architecture solution for such case(-s). I'm sure, there are best practices / standard solutions for this problem.