ObjectController: allow API access

This commit is contained in:
Thomas Gelf 2015-12-10 13:11:21 +01:00
parent 21d51decb2
commit 364d4a5d68
1 changed files with 8 additions and 9 deletions

View File

@ -9,8 +9,12 @@ abstract class ObjectController extends ActionController
{
protected $object;
protected $isApified = true;
public function init()
{
parent::init();
$type = $this->getType();
$params = array();
@ -54,10 +58,10 @@ abstract class ObjectController extends ActionController
public function indexAction()
{
if ($this->wantsJson()) {
header('Content: application/json');
echo $this->object->toJson($this->params->shift('resolved'));
exit;
if ($this->getRequest()->isApiRequest()) {
return $this->sendJson(
$this->object->toPlainObject($this->params->shift('resolved'))
);
}
return $this->editAction();
@ -217,9 +221,4 @@ abstract class ObjectController extends ActionController
return $this->object;
}
protected function wantsJson()
{
return $this->params->shift('json');
}
}