ObjectsController: rudimentary API support

This commit is contained in:
Thomas Gelf 2016-02-17 19:35:29 +01:00
parent a58978099b
commit 520644a67a
1 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,8 @@ abstract class ObjectsController extends ActionController
{ {
protected $dummy; protected $dummy;
protected $isApified = true;
protected $globalTypes = array( protected $globalTypes = array(
'ApiUser', 'ApiUser',
'Zone', 'Zone',
@ -106,6 +108,15 @@ abstract class ObjectsController extends ActionController
$this->view->title = $this->translate('Icinga ' . ucfirst($ltype)); $this->view->title = $this->translate('Icinga ' . ucfirst($ltype));
$table = $this->loadTable($table)->setConnection($this->db()); $table = $this->loadTable($table)->setConnection($this->db());
$this->view->filterEditor = $table->getFilterEditor($this->getRequest()); $this->view->filterEditor = $table->getFilterEditor($this->getRequest());
if ($this->getRequest()->isApiRequest()) {
$objects = $this->db()->getDbAdapter()->fetchAll(
$table->getBaseQuery()->columns(array('object_name', 'object_type', 'disabled'))
);
return $this->sendJson((object) array('objects' => $objects));
}
$this->view->table = $this->applyPaginationLimits($table); $this->view->table = $this->applyPaginationLimits($table);
$this->render('objects/table', null, true); $this->render('objects/table', null, true);