/** * json response * you can pass an array of data wich will be converted to json * * @param array $data * @param int $status * @param bool $beautify should the json output be formatted? * @return CCResponse */ public static function json($data = array(), $status = 200, $beautify = true) { if (!is_array($data)) { throw new CCException("CCResponse::json - first argument has to be an array."); } $response = new static(CCJson::encode($data, $beautify), $status); $response->header('Content-Type', 'text/json'); return $response; }
/** * Get the object as json * When $modifiers is true, then the data will be passed trough the modifiers * * @param bool $modifiers * @param bool $beautify * @return string */ public function as_json($modifiers = true, $beautify = true) { return CCJson::encode($this->as_array($modifiers), $beautify); }
/** * Send the mail * * @param CCMail $mail The mail object. * @return void * * @throws Mail\Exception */ public function send(CCMail $mail) { $data = $mail->export_data(); $filename = 'mails/' . date('Y-m') . '/' . date('d') . '/' . date("H-i-s") . '-' . \CCStr::clean_url($data['subject']) . '.log'; \CCFile::append(\CCStorage::path($filename), \CCJson::encode($data, true)); }