Jacwright\RestServer\RestServer::sendData PHP Method

sendData() public method

public sendData ( $data )
    public function sendData($data)
    {
        header("Cache-Control: no-cache, must-revalidate");
        header("Expires: 0");
        header('Content-Type: ' . $this->format);
        if ($this->format == RestFormat::XML) {
            if (is_object($data) && method_exists($data, '__keepOut')) {
                $data = clone $data;
                foreach ($data->__keepOut() as $prop) {
                    unset($data->{$prop});
                }
            }
            $this->xml_encode($data);
        } else {
            if (is_object($data) && method_exists($data, '__keepOut')) {
                $data = clone $data;
                foreach ($data->__keepOut() as $prop) {
                    unset($data->{$prop});
                }
            }
            $options = 0;
            if ($this->mode == 'debug' && defined('JSON_PRETTY_PRINT')) {
                $options = JSON_PRETTY_PRINT;
            }
            if (defined('JSON_UNESCAPED_UNICODE')) {
                $options = $options | JSON_UNESCAPED_UNICODE;
            }
            echo json_encode($data, $options);
        }
    }