From cd5ce8063a284c2211ffe06566ce7ba07f2b0b27 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 2 Dec 2015 03:32:42 +0100 Subject: [PATCH] ObjectController: rudimentary sample json support --- library/Director/Web/Controller/ObjectController.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php index 3b9c482b..7e3a3e19 100644 --- a/library/Director/Web/Controller/ObjectController.php +++ b/library/Director/Web/Controller/ObjectController.php @@ -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'); + } }