Yii2 Bootstrap 3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

13 years ago
<?php
/**
* InlineAction class file.
13 years ago
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2012 Yii Software LLC
13 years ago
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
13 years ago
/**
* InlineAction represents an action that is defined as a controller method.
13 years ago
*
13 years ago
* The name of the controller method should be in the format of `actionXyz`
* where `Xyz` stands for the action ID (e.g. `actionIndex`).
13 years ago
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
13 years ago
*/
class InlineAction extends Action
13 years ago
{
/**
13 years ago
* Runs this action with the specified parameters.
* This method is mainly invoked by the controller.
* @param array $params action parameters
* @return integer the exit status (0 means normal, non-zero means abnormal).
13 years ago
*/
13 years ago
public function runWithParams($params)
13 years ago
{
$method = new \ReflectionMethod($this->controller, 'action' . $this->id);
13 years ago
$params = \yii\util\ReflectionHelper::bindParams($method, $params);
if ($params === false) {
$this->controller->invalidActionParams($this);
return 1;
} else {
13 years ago
return (int)$method->invokeArgs($this, $params);
}
13 years ago
}
}