Fix #18083: Add Controller::$request and $response

This commit is contained in:
Brandon Kelly
2020-06-14 11:19:27 -07:00
committed by GitHub
parent d317e41b21
commit fc4f449e21
6 changed files with 45 additions and 19 deletions

View File

@ -8,6 +8,7 @@
namespace yii\base;
use Yii;
use yii\di\Instance;
/**
* Controller is the base class for classes containing controller logic.
@ -63,6 +64,16 @@ class Controller extends Component implements ViewContextInterface
* by [[run()]] when it is called by [[Application]] to run an action.
*/
public $action;
/**
* @var Request|array|string The request
* @since 2.0.36
*/
public $request = 'request';
/**
* @var Response|array|string
* @since 2.0.36
*/
public $response = 'response';
/**
* @var View the view object that can be used to render views or view files.
@ -86,6 +97,17 @@ class Controller extends Component implements ViewContextInterface
parent::__construct($config);
}
/**
* {@inheritdoc}
* @since 2.0.36
*/
public function init()
{
parent::init();
$this->request = Instance::ensure($this->request, Request::className());
$this->response = Instance::ensure($this->response, Response::className());
}
/**
* Declares external actions for the controller.
*