Example #1
0
 public function getPageContents($request)
 {
     $json = json_encode($request->parameters);
     $page = new Page();
     $jsonObj = json_decode($json);
     $jsonMessage = $page->validateJsonPageObj($jsonObj);
     if ($jsonMessage != Message::SUCCESS) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => $jsonMessage);
         $this->outputError($response);
         return;
     }
     if (!$page->setValuesFromJsonObj($jsonObj)) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_INVAID_REQUEST_BODY);
         $this->outputError($response);
         return;
     }
     if (trim($jsonObj->pageTitle == '')) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_PAGE_TITLE);
         $this->outputError($response);
         return;
     }
     $pageContents = $page->getPageContents($jsonObj->pageTitle);
     if (empty($pageContents)) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_PACKAGE_LOAD);
         $this->outputError($response);
         return;
     } else {
         $response = array("status" => "SUCCESS-BUSINESS", "status_code" => '200', 'pageContents' => $pageContents);
         $this->outputSuccess($response);
         return;
     }
 }