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