Files
yii2/framework/yii/base/InlineAction.php
Carsten Brandt b138199c59 implementation of Response tied to actions
Result of a discussion with @qiangxue
- there is not global Yii::$app->response anymore, every action has
  dedicated response class
- implementation allows using HMVC pattern now, nested actions do not
  interfer
2013-06-16 18:12:27 +02:00

50 lines
1.5 KiB
PHP

<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
/**
* InlineAction represents an action that is defined as a controller method.
*
* The name of the controller method is available via [[actionMethod]] which
* is set by the [[controller]] who creates this action.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class InlineAction extends Action
{
/**
* @var string the controller method that this inline action is associated with
*/
public $actionMethod;
/**
* @param string $id the ID of this action
* @param Controller $controller the controller that owns this action
* @param string $actionMethod the controller method that this inline action is associated with
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public function __construct($id, $controller, $actionMethod, $config = array())
{
$this->actionMethod = $actionMethod;
parent::__construct($id, $controller, $config);
}
/**
* Runs this action with the specified parameters.
* This method is mainly invoked by the controller.
* @param array $params action parameters
* @return mixed the result of the action
*/
public function runWithParams($params)
{
$args = $this->controller->bindActionParams($this, $params);
return call_user_func_array(array($this->controller, $this->actionMethod), $args);
}
}