From d419cc327d5b927597bd5f143f734e1dd11974fe Mon Sep 17 00:00:00 2001 From: bison Date: Wed, 17 Aug 2016 12:10:16 +0200 Subject: [PATCH] - Added method getGemeindeByPlz to controller Gemeinde --- .../controllers/api/v1/codex/Gemeinde.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/application/controllers/api/v1/codex/Gemeinde.php b/application/controllers/api/v1/codex/Gemeinde.php index 64aa6a179..b7ac27653 100644 --- a/application/controllers/api/v1/codex/Gemeinde.php +++ b/application/controllers/api/v1/codex/Gemeinde.php @@ -31,9 +31,9 @@ class Gemeinde extends APIv1_Controller */ public function getGemeinde() { - $gemeindeID = $this->get('gemeinde_id'); + $gemeindeID = $this->get("gemeinde_id"); - $this->GemeindeModel->addOrder('plz'); + $this->GemeindeModel->addOrder("plz"); if (isset($gemeindeID)) { $result = $this->GemeindeModel->load($gemeindeID); @@ -42,8 +42,28 @@ class Gemeinde extends APIv1_Controller { $result = $this->GemeindeModel->load(); } + $this->response($result, REST_Controller::HTTP_OK); } + + /** + * @return void + */ + public function getGemeindeByPlz() + { + $plz = $this->get("plz"); + + if (is_numeric($plz)) + { + $result = $this->GemeindeModel->loadWhere(array('plz' => $plz)); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } /** * @return void