/** * @covers think\Response::tramsform * @todo Implement testTramsform(). */ public function testTramsform() { Response::tramsform(function () { return "callbackreturndata"; }); $dataArr = []; $result = Response::send($dataArr, "", true); $this->assertEquals("callbackreturndata", $result); Response::tramsform(null); }
/** * 输出异常信息 * @param \Exception $exception * @param Array $vars 异常信息 * @return void */ public static function output($exception, array $vars) { http_response_code($exception instanceof Exception ? $exception->getHttpStatus() : 500); $type = Config::get('default_return_type'); if (IS_API && 'html' != $type) { // 异常信息输出监听 APP_HOOK && Hook::listen('error_output', $data); // 输出异常内容 Response::send($data, $type, Config::get('response_return')); } else { //ob_end_clean(); extract($vars); include Config::get('exception_tmpl'); } }
/** * 输出异常信息 * @param \Exception $exception * @param Array $vars 异常信息 * @return null */ public static function output(\Exception $exception, array $vars) { if ($exception instanceof Exception) { http_response_code($exception->getHttpStatus()); } else { http_response_code(500); } // header('Content-Type: application/json'); // echo json_encode($vars);exit; $type = Config::get('default_return_type'); if (IS_API && 'html' != $type) { // 异常信息输出监听 APP_HOOK && Hook::listen('error_output', $data); // 输出异常内容 Response::send($data, $type, Config::get('response_return')); } else { ob_end_clean(); extract($vars); include Config::get('exception_tmpl'); } }