_result = $value; } public function setStatusCode($value) { header('HTTP/1.1 ' . $value); } /** * Sends the response to the client. */ public function send() { if ($this->isSent) { return; } $this->prepare(); $this->sendContent(); $this->isSent = true; } protected function prepare() { if ($this->format === static::FORMAT_JSON) { header('Content-type: application/json; charset=utf-8'); $this->_result = \CJSON::encode($this->_result); } if ($this->format === static::FORMAT_XML) { header('Content-type: application/xml; charset=utf-8'); } if ($this->format === static::FORMAT_RAW) { header('Content-type: text/plain; charset=utf-8'); } foreach ($this->filters as $filter) { if ($filter instanceof ResponseFilterInterface) { $this->_result = $filter->process($this->_result); } } } protected function sendContent() { echo trim($this->_result); } }