From 8af8ecb6f11993ba198f302959668e26da3e6425 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 25 Feb 2015 10:33:55 -0500 Subject: [PATCH] API: Zones use Crud for Index and View actions --- web/api/app/Controller/ZonesController.php | 42 ---------------------- web/api/app/Model/Zone.php | 1 + web/api/app/View/Zones/json/index.ctp | 1 - web/api/app/View/Zones/json/view.ctp | 1 - web/api/app/View/Zones/xml/index.ctp | 2 -- web/api/app/View/Zones/xml/view.ctp | 2 -- 6 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 web/api/app/View/Zones/json/index.ctp delete mode 100644 web/api/app/View/Zones/json/view.ctp delete mode 100644 web/api/app/View/Zones/xml/index.ctp delete mode 100644 web/api/app/View/Zones/xml/view.ctp diff --git a/web/api/app/Controller/ZonesController.php b/web/api/app/Controller/ZonesController.php index f5888a1be..be80c57fc 100644 --- a/web/api/app/Controller/ZonesController.php +++ b/web/api/app/Controller/ZonesController.php @@ -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'); diff --git a/web/api/app/Model/Zone.php b/web/api/app/Model/Zone.php index 52041a90e..8cdc8131b 100644 --- a/web/api/app/Model/Zone.php +++ b/web/api/app/Model/Zone.php @@ -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 diff --git a/web/api/app/View/Zones/json/index.ctp b/web/api/app/View/Zones/json/index.ctp deleted file mode 100644 index e7a01e733..000000000 --- a/web/api/app/View/Zones/json/index.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($zones); diff --git a/web/api/app/View/Zones/json/view.ctp b/web/api/app/View/Zones/json/view.ctp deleted file mode 100644 index f8ba3dcd8..000000000 --- a/web/api/app/View/Zones/json/view.ctp +++ /dev/null @@ -1 +0,0 @@ -echo json_encode($zone); diff --git a/web/api/app/View/Zones/xml/index.ctp b/web/api/app/View/Zones/xml/index.ctp deleted file mode 100644 index 56fd4d0d4..000000000 --- a/web/api/app/View/Zones/xml/index.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $zones)); -echo $xml->asXML(); diff --git a/web/api/app/View/Zones/xml/view.ctp b/web/api/app/View/Zones/xml/view.ctp deleted file mode 100644 index 08c9771b3..000000000 --- a/web/api/app/View/Zones/xml/view.ctp +++ /dev/null @@ -1,2 +0,0 @@ -$xml = Xml::fromArray(array('response' => $zone)); -echo $xml->asXML();