mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fixed kebab-name console command parameters
This commit is contained in:
@ -113,7 +113,8 @@ class Controller extends \yii\base\Controller
|
|||||||
foreach ($params as $name => $value) {
|
foreach ($params as $name => $value) {
|
||||||
// Allow camelCase options to be entered in kebab-case
|
// Allow camelCase options to be entered in kebab-case
|
||||||
if (!in_array($name, $options, true) && strpos($name, '-') !== false) {
|
if (!in_array($name, $options, true) && strpos($name, '-') !== false) {
|
||||||
$altName = lcfirst(Inflector::id2camel($name));
|
$kebabName = $name;
|
||||||
|
$altName = lcfirst(Inflector::id2camel($kebabName));
|
||||||
if (in_array($altName, $options, true)) {
|
if (in_array($altName, $options, true)) {
|
||||||
$name = $altName;
|
$name = $altName;
|
||||||
}
|
}
|
||||||
@ -131,6 +132,9 @@ class Controller extends \yii\base\Controller
|
|||||||
}
|
}
|
||||||
$this->_passedOptions[] = $name;
|
$this->_passedOptions[] = $name;
|
||||||
unset($params[$name]);
|
unset($params[$name]);
|
||||||
|
if (isset($kebabName)) {
|
||||||
|
unset($params[$kebabName]);
|
||||||
|
}
|
||||||
} elseif (!is_int($name)) {
|
} elseif (!is_int($name)) {
|
||||||
throw new Exception(Yii::t('yii', 'Unknown option: --{name}', ['name' => $name]));
|
throw new Exception(Yii::t('yii', 'Unknown option: --{name}', ['name' => $name]));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user