/** * Send the response back to the client. */ public function send() { if (is_array($this->_body) || $this->_body instanceof JsonSerializable) { // Convert the response to JSON. $this->contentType = array('application/json', 'charset' => 'utf-8'); $this->_body = JSONUtil::encode($this->_body); } echo $this->_body; // Stop doing things once the response was sent. exit; }