draft idea of action based responses

This commit is contained in:
Carsten Brandt
2013-06-16 17:04:28 +02:00
parent 4ef19b2e79
commit 82c978f86a
6 changed files with 34 additions and 23 deletions

View File

@ -7,6 +7,8 @@
namespace yii\base;
use Yii;
/**
* Action is the base class for all controller action classes.
*
@ -40,6 +42,21 @@ class Action extends Component
*/
public $controller;
private $_response;
public function getResponse()
{
if ($this->_response === null) {
$this->_response = Yii::$app->createResponse();
}
return $this->_response;
}
public function setResponse($response)
{
$this->_response = $response;
}
/**
* Constructor.
* @param string $id the ID of this action
@ -75,6 +92,8 @@ class Action extends Component
throw new InvalidConfigException(get_class($this) . ' must define a "run()" method.');
}
$args = $this->controller->bindActionParams($this, $params);
return call_user_func_array(array($this, 'run'), $args);
$response = $this->getResponse();
$response->result = call_user_func_array(array($this, 'run'), $args);
return $response;
}
}