Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(Helpers): Remove JsonHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Mar 8, 2019
1 parent ae2a7b7 commit df5d57e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 98 deletions.
12 changes: 0 additions & 12 deletions apps/config/http_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@
'class' => Rid\Http\Response::class,
// 默认输出格式
'defaultFormat' => Rid\Http\Response::FORMAT_HTML,
// json
'json' => [
// 类路径
'class' => Rid\Http\Json::class,
],
// jsonp
'jsonp' => [
// 类路径
'class' => Rid\Http\Jsonp::class,
// callback键名
'name' => 'callback',
],
// xml
'xml' => [
// 类路径
Expand Down
23 changes: 0 additions & 23 deletions framework/Helpers/JsonHelper.php

This file was deleted.

20 changes: 7 additions & 13 deletions framework/Http/BaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ class BaseResponse extends Component
// 默认输出格式
public $defaultFormat = self::FORMAT_HTML;

/**
* @var \Rid\Http\Json
*/
public $json;

/**
* @var \Rid\Http\Jsonp
*/
public $jsonp;

/**
* @var \Rid\Http\Xml
*/
Expand Down Expand Up @@ -92,11 +82,15 @@ protected function prepare()
if (is_array($content) || is_object($content)) {
switch ($this->format) {
case self::FORMAT_JSON:
$content = $this->json->encode($content);
$content = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
break;
case self::FORMAT_JSONP:
$content = $this->jsonp->encode($content);
break;
{
$callback_key = app()->request->get('callback', 'callback');
$content = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$content = $callback_key . '(' . $content . ')';
break;
}
case self::FORMAT_XML:
$content = $this->xml->encode($content);
break;
Expand Down
21 changes: 0 additions & 21 deletions framework/Http/Json.php

This file was deleted.

29 changes: 0 additions & 29 deletions framework/Http/Jsonp.php

This file was deleted.

0 comments on commit df5d57e

Please sign in to comment.