AbstractController.class.php
1.27 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* RPC/Abstract
* 推荐系统 RPC 抽象类
* @author Deepseath
* @version $Id$
*/
namespace Rpc\Controller;
use Com\Error;
use Think\Log;
abstract class AbstractController extends \Common\Controller\Rpc\AbstractController
{
/**
* 外部传入的参数
*/
protected $_params = [];
/**
* 执行前置动作
* {@inheritDoc}
* @see \Common\Controller\Rpc\AbstractController::before_action()
*/
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
$this->_params = $this->get_arguments();
return true;
}
/**
* 执行后置动作
* {@inheritDoc}
* @see \Common\Controller\Rpc\AbstractController::after_action()
*/
public function after_action($action = '')
{
if (!parent::after_action($action)) {
return false;
}
return true;
}
/**
* 设置输出错误信息
* @param mixed $message 错误信息
* @param int $code 错误号
* @return bool
*/
protected function _set_error($message, $code = 0)
{
Error::instance()->set_error($message, $code);
Log::record($message);
return $code ? false : true;
}
}