本文整理汇总了PHP中yii\console\Controller::globalOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::globalOptions方法的具体用法?PHP Controller::globalOptions怎么用?PHP Controller::globalOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\console\Controller
的用法示例。
在下文中一共展示了Controller::globalOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: globalOptions
/**
* Returns the names of the global options for this command.
* @return array the names of the global options for this command.
*/
public function globalOptions()
{
return array_merge(parent::globalOptions(), ['migrationPath', 'migrationTable', 'db', 'templateFile', 'interactive', 'color']);
}
示例2: getOptionHelps
/**
* Returns the help information about the options available for a console controller.
* @param Controller $controller the console controller
* @return array the help information about the options
*/
protected function getOptionHelps($controller)
{
$optionNames = $controller->globalOptions();
if (empty($optionNames)) {
return [];
}
$class = new \ReflectionClass($controller);
$options = [];
foreach ($class->getProperties() as $property) {
$name = $property->getName();
if (!in_array($name, $optionNames, true)) {
continue;
}
$defaultValue = $property->getValue($controller);
$tags = $this->parseComment($property->getDocComment());
if (isset($tags['var']) || isset($tags['property'])) {
$doc = isset($tags['var']) ? $tags['var'] : $tags['property'];
if (is_array($doc)) {
$doc = reset($doc);
}
if (preg_match('/^([^\\s]+)(.*)/s', $doc, $matches)) {
$type = $matches[1];
$comment = $matches[2];
} else {
$type = null;
$comment = $doc;
}
$options[$name] = $this->formatOptionHelp($this->ansiFormat('--' . $name, Console::FG_RED), false, $type, $defaultValue, $comment);
} else {
$options[$name] = $this->formatOptionHelp($this->ansiFormat('--' . $name, Console::FG_RED), false, null, $defaultValue, '');
}
}
ksort($options);
return $options;
}
示例3: globalOptions
/**
* Returns the names of the global options for this command.
* @return array the names of the global options for this command.
*/
public function globalOptions()
{
return array_merge(parent::globalOptions(), ['db', 'fixturePath']);
}