【发布时间】:2015-07-06 21:09:55
【问题描述】:
我想扩展类 yii\web\Response。所以我在文件夹 components 中创建了一个新类 Response 并尝试覆盖 send 方法。
namespace app\components;
use Yii;
class Response extends \yii\web\Response{
public function init(){
parent::init();
}
/**
* Sends the response to the client.
*/
public function send()
{ ...
最后我尝试通过在配置中导入我的新响应类来导入它。
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'import' => [
'class' => 'app\components\Response',
],
为什么它不能像这样工作?
【问题讨论】:
标签: yii yii2 yii-components