basename = "AttributeController"; } public function processAction() { $this->strErrorDesc = ''; $this->strErrorHeader = ''; $this->strErrorMessage = ''; try { $this->requestMethod = $this->getServerRequestMethod(); $this->attributeModel = new AttributeModel(); switch($this->action) { case "select": $response = $this->selectAction(); break; case "insert": $response = $this->insertAttribute(); break; case "update": $response = $this->updateAttribute(); break; case "delete": $response = $this->deleteAttribute(); break; default: $response = $this->unprocessableRequestResponse("processAction"); break; } $responseData = json_encode($response); } catch (Error $e) { $this->internalErrorResponse($e); } // send output if (!$this->strErrorDesc) { $this->sendOutput( $responseData, array('Content-Type: application/json', 'HTTP/1.1 200 OK') ); } else { $this->sendOutput(json_encode( array('error' => $this->strErrorDesc, 'message' => $this->strErrorMessage, 'controller' => $this->basename)), array('Content-Type: application/json', $this->strErrorHeader) ); } } private function selectAction(){ if ($this->checkRequestType('GET') == 'false') { $response = $this->unprocessableRequestResponse("selectAction"); return $response; } $this->arrQueryStringParams = $this->getQueryStringParams(); if (isset($this->arrQueryStringParams['loyalty_member_id'])) { $response = $this->selectByMemberIdAction(); } else { $response = $this->attributeModel->findAllAttributes(); } return $response; } private function selectByMemberIdAction(){ if (isset($this->arrQueryStringParams['loyalty_member_id'])) { $this->attributeModel->memberId = $this->arrQueryStringParams['loyalty_member_id']; $response = $this->attributeModel->findAttributesByMemberId(); unset($this->attributeModel->memberId); } else { $response = $this->notFoundResponse("selectByMemberIdAction"); } return $response; } }