API: Zones use Crud for Index and View actions
This commit is contained in:
parent
80b1a61a12
commit
8af8ecb6f1
|
@ -4,51 +4,9 @@ App::uses('AppController', 'Controller');
|
|||
* Zones Controller
|
||||
*
|
||||
* @property Zone $Zone
|
||||
* @property PaginatorComponent $Paginator
|
||||
*/
|
||||
class ZonesController extends AppController {
|
||||
|
||||
/**
|
||||
* Components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('Paginator', 'RequestHandler');
|
||||
|
||||
/**
|
||||
* index method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index() {
|
||||
$this->Zone->recursive = -1;
|
||||
$zones = $this->Zone->find('all');
|
||||
$this->set(array(
|
||||
'zones' => $zones,
|
||||
'_serialize' => array('zones')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* view method
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function view($id = null) {
|
||||
$this->Zone->recursive = -1;
|
||||
if (!$this->Zone->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid zone'));
|
||||
}
|
||||
$options = array('conditions' => array('Zone.' . $this->Zone->primaryKey => $id));
|
||||
$zone = $this->Zone->find('first', $options);
|
||||
$this->set(array(
|
||||
'zone' => $zone,
|
||||
'_serialize' => array('zone')
|
||||
));
|
||||
}
|
||||
|
||||
// Find all zones which belong to a MonitorId
|
||||
public function forMonitor($id = null) {
|
||||
$this->loadModel('Monitor');
|
||||
|
|
|
@ -28,6 +28,7 @@ class Zone extends AppModel {
|
|||
*/
|
||||
public $displayField = 'Name';
|
||||
|
||||
public $recursive = -1;
|
||||
|
||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
echo json_encode($zones);
|
|
@ -1 +0,0 @@
|
|||
echo json_encode($zone);
|
|
@ -1,2 +0,0 @@
|
|||
$xml = Xml::fromArray(array('response' => $zones));
|
||||
echo $xml->asXML();
|
|
@ -1,2 +0,0 @@
|
|||
$xml = Xml::fromArray(array('response' => $zone));
|
||||
echo $xml->asXML();
|
Loading…
Reference in New Issue