ObjectController: rudimentary sample json support

This commit is contained in:
Thomas Gelf 2015-12-02 03:32:42 +01:00
parent 8b7388cfe3
commit cd5ce8063a
1 changed files with 11 additions and 0 deletions

View File

@ -54,6 +54,12 @@ abstract class ObjectController extends ActionController
public function indexAction()
{
if ($this->wantsJson()) {
header('Content: application/json');
echo $this->object->toJson($this->params->shift('resolved'));
exit;
}
return $this->editAction();
}
@ -211,4 +217,9 @@ abstract class ObjectController extends ActionController
return $this->object;
}
protected function wantsJson()
{
return $this->params->shift('json');
}
}