Blame view

app-wx/controllers/AppController.php 722 Bytes
62d73041   xu   app-wx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace app\wx\controllers;

use Yii;
use yii\web\Controller;

/**
 * 该基类的主要作用是,提供一个便利的方法集成。
 */
class AppController extends Controller
{
    /** @var \yii\web\request **/
    public $request;
    /** @var \yii\web\response **/
    public $response;

    /**
     * @throws yii\web\HttpException
     */
    public function init()
    {
        parent::init();
        $this->request = Yii::$app->getRequest();
        $this->response = Yii::$app->getResponse();
    }

    /**
     * 渲染 JSON 数据结果
     * @param $data
     * @return string
     */
    public function renderJson($data)
    {
        return json_encode($data, JSON_UNESCAPED_UNICODE);
    }
}