/** * Return data from handler in JSON format. * @param array $data * @return string */ private function toJSON($data = array()) { if ($this->success) { $this->message = $this->resource->getOnSuccessMessageFor($this->serviceName); } $ret = array('success' => $this->success, 'message' => $this->message, 'code' => $this->code, 'resource' => get_class($this->resource), 'service' => $this->serviceName, $this->responseKey => $data); if (LudoDB::isLoggingEnabled()) { $ret['log'] = array('time' => LudoDB::getElapsed(), 'queries' => LudoDB::getQueryCount()); } return json_encode($ret); }