Add API function: return a monitor's zones

This commit is contained in:
Kyle Johnson 2015-02-24 11:13:10 -05:00
parent b655883345
commit d56e0762f4
1 changed files with 17 additions and 0 deletions

View File

@ -49,6 +49,23 @@ class ZonesController extends AppController {
));
}
// Find all zones which belong to a MonitorId
public function forMonitor($id = null) {
$this->loadModel('Monitor');
if (!$this->Monitor->exists($id)) {
throw new NotFoundException(__('Invalid monitor'));
}
$this->Zone->recursive = -1;
$zones = $this->Zone->find('all', array(
'conditions' => array('MonitorId' => $id)
));
$this->set(array(
'zones' => $zones,
'_serialize' => array('zones')
));
}
/**
* add method
*