コード例 #1
0
 /**
  * Helper method to authenticate this API call
  *
  * @param string $message
  * @param int $code
  *
  * @return null
  */
 private function error($message, $code = 500)
 {
     // Create a new error-object
     $error = new Zend_Json_Server_Error();
     $error->setCode($code);
     $error->setMessage($message);
     /** @var Zend_Json_Server_Response $response */
     $response = $this->server->getResponse();
     // Add the error to the current response
     $response->setError($error);
     // Set the response
     $this->server->setResponse($response);
     $this->server->handle();
     // Set the HTTP-header
     header('HTTP/1.1 ' . $code . ' ' . $message, true);
     header('Status: ' . $code . ' ' . $message, true);
     // Close the application
     $this->close();
 }
コード例 #2
0
 private function error($message, $code = '500')
 {
     // Create a new error-object
     $error = new Zend_Json_Server_Error();
     $error->setCode($code);
     $error->setMessage($message);
     // Add the error to the current response
     $response = $this->server->getResponse();
     $response->setError($error);
     // Set the response
     $this->server->setResponse($response);
     $this->server->handle();
     // Set the HTTP-header
     @header('HTTP/1.1 ' . $code . ' ' . $message);
     @header('Status: ' . $code . ' ' . $message);
     // Close the application
     $application = JFactory::getApplication();
     $application->close();
 }