本文整理汇总了PHP中yii\base\Controller::runAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::runAction方法的具体用法?PHP Controller::runAction怎么用?PHP Controller::runAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Controller
的用法示例。
在下文中一共展示了Controller::runAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runAction
public function runAction($id, $params = [])
{
// Skip \yii\console\Controller::runAction impl.
// Don't care about options and arguments. Just pass the call through
// to Doctrine's ConsoleRunner and let it handle everything.
return \yii\base\Controller::runAction($id, $params);
}
示例2: runAction
/**
* Runs an action with the specified action ID and parameters.
* If the action ID is empty, the method will use [[defaultAction]].
* @param string $id the ID of the action to be executed.
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @return integer the status of the action execution. 0 means normal, other values mean abnormal.
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @see createAction
*/
public function runAction($id, $params = [])
{
if (!empty($params)) {
$options = $this->globalOptions();
foreach ($params as $name => $value) {
if (in_array($name, $options, true)) {
$this->{$name} = $value;
unset($params[$name]);
}
}
}
return parent::runAction($id, $params);
}
示例3: runAction
/** @inheritdoc */
public function runAction($id, $consoleParams = [], $params = [])
{
if (!empty($consoleParams)) {
$options = $this->options($id);
foreach ($consoleParams as $name => $value) {
if (in_array($name, $options, true)) {
$default = $this->{$name};
$this->{$name} = is_array($default) ? preg_split('/\\s*,\\s*/', $value) : $value;
unset($consoleParams[$name]);
} elseif (!is_int($name)) {
throw new Exception(Yii::t('yii', 'Unknown option: --{name}', ['name' => $name]));
}
}
}
return BaseController::runAction($id, $params);
}
示例4: runAction
/**
* Runs an action with the specified action ID and parameters.
* If the action ID is empty, the method will use [[defaultAction]].
* @param string $id the ID of the action to be executed.
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @return integer the status of the action execution. 0 means normal, other values mean abnormal.
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @throws Exception if there are unknown options or missing arguments
* @see createAction
*/
public function runAction($id, $params = [])
{
if (!empty($params)) {
// populate options here so that they are available in beforeAction().
$options = $this->options($id);
foreach ($params as $name => $value) {
if (in_array($name, $options, true)) {
$default = $this->{$name};
$this->{$name} = is_array($default) ? preg_split('/\\s*,\\s*/', $value) : $value;
unset($params[$name]);
} elseif (!is_int($name)) {
throw new Exception(Yii::t('yii', 'Unknown option: --{name}', ['name' => $name]));
}
}
}
return parent::runAction($id, $params);
}
示例5: runAction
/**
* Runs an action with the specified action ID and parameters.
* If the action ID is empty, the method will use [[defaultAction]].
* @param string $id the ID of the action to be executed.
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @return integer the status of the action execution. 0 means normal, other values mean abnormal.
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @throws Exception if there are unknown options or missing arguments
* @see createAction
*/
public function runAction($id, $params = [])
{
if (!empty($params)) {
// populate options here so that they are available in beforeAction().
$options = $this->options($id === '' ? $this->defaultAction : $id);
if (isset($params['_aliases'])) {
$optionAliases = $this->optionAliases();
foreach ($params['_aliases'] as $name => $value) {
if (array_key_exists($name, $optionAliases)) {
$params[$optionAliases[$name]] = $value;
} else {
throw new Exception(Yii::t('yii', 'Unknown alias: -{name}', ['name' => $name]));
}
}
unset($params['_aliases']);
}
foreach ($params as $name => $value) {
if (in_array($name, $options, true)) {
$default = $this->{$name};
if (is_array($default)) {
$this->{$name} = preg_split('/(?!\\(\\d+)\\s*,\\s*(?!\\d+\\))/', $value);
} elseif ($default !== null) {
settype($value, gettype($default));
$this->{$name} = $value;
} else {
$this->{$name} = $value;
}
$this->_passedOptions[] = $name;
unset($params[$name]);
} elseif (!is_int($name)) {
throw new Exception(Yii::t('yii', 'Unknown option: --{name}', ['name' => $name]));
}
}
}
return parent::runAction($id, $params);
}
示例6: runAction
public function runAction($id, $params = array())
{
$params = array_merge($_POST, $params);
return parent::runAction($id, $params);
}