当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::getActionHelp方法代码示例

本文整理汇总了PHP中yii\console\Controller::getActionHelp方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::getActionHelp方法的具体用法?PHP Controller::getActionHelp怎么用?PHP Controller::getActionHelp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\console\Controller的用法示例。


在下文中一共展示了Controller::getActionHelp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSubCommandHelp

 /**
  * Displays the detailed information of a command action.
  * @param Controller $controller the controller instance
  * @param string $actionID action ID
  * @throws Exception if the action does not exist
  */
 protected function getSubCommandHelp($controller, $actionID)
 {
     $action = $controller->createAction($actionID);
     if ($action === null) {
         $name = $this->ansiFormat(rtrim($controller->getUniqueId() . '/' . $actionID, '/'), Console::FG_YELLOW);
         throw new Exception("No help for unknown sub-command \"{$name}\".");
     }
     $description = $controller->getActionHelp($action);
     if ($description !== '') {
         $this->stdout("\nDESCRIPTION\n", Console::BOLD);
         $this->stdout("\n{$description}\n\n");
     }
     $this->stdout("\nUSAGE\n\n", Console::BOLD);
     $scriptName = $this->getScriptName();
     if ($action->id === $controller->defaultAction) {
         $this->stdout($scriptName . ' ' . $this->ansiFormat($controller->getUniqueId(), Console::FG_YELLOW));
     } else {
         $this->stdout($scriptName . ' ' . $this->ansiFormat($action->getUniqueId(), Console::FG_YELLOW));
     }
     $args = $controller->getActionArgsHelp($action);
     foreach ($args as $name => $arg) {
         if ($arg['required']) {
             $this->stdout(' <' . $name . '>', Console::FG_CYAN);
         } else {
             $this->stdout(' [' . $name . ']', Console::FG_CYAN);
         }
     }
     $options = $controller->getActionOptionsHelp($action);
     $options[\yii\console\Application::OPTION_APPCONFIG] = ['type' => 'string', 'default' => null, 'comment' => "custom application configuration file path.\nIf not set, default application configuration is used."];
     ksort($options);
     if (!empty($options)) {
         $this->stdout(' [...options...]', Console::FG_RED);
     }
     $this->stdout("\n\n");
     if (!empty($args)) {
         foreach ($args as $name => $arg) {
             $this->stdout($this->formatOptionHelp('- ' . $this->ansiFormat($name, Console::FG_CYAN), $arg['required'], $arg['type'], $arg['default'], $arg['comment']) . "\n\n");
         }
     }
     if (!empty($options)) {
         $this->stdout("\nOPTIONS\n\n", Console::BOLD);
         foreach ($options as $name => $option) {
             $this->stdout($this->formatOptionHelp($this->ansiFormat('--' . $name, Console::FG_RED, empty($option['required']) ? Console::FG_RED : Console::BOLD), !empty($option['required']), $option['type'], $option['default'], $option['comment']) . "\n\n");
         }
     }
 }
开发者ID:drodata,项目名称:yii2,代码行数:52,代码来源:HelpController.php

示例2: getActionHelp

 /**
  * @inheritdoc
  */
 public function getActionHelp($action)
 {
     if ($action instanceof InlineAction) {
         return parent::getActionHelp($action);
     } else {
         /** @var $action GenerateAction */
         $description = $action->generator->getDescription();
         return wordwrap(preg_replace('/\\s+/', ' ', $description));
     }
 }
开发者ID:yangguanghui,项目名称:yii2-extension-final,代码行数:13,代码来源:GenerateController.php


注:本文中的yii\console\Controller::getActionHelp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。