當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Controller::getHelp方法代碼示例

本文整理匯總了PHP中yii\console\Controller::getHelp方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::getHelp方法的具體用法?PHP Controller::getHelp怎麽用?PHP Controller::getHelp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\console\Controller的用法示例。


在下文中一共展示了Controller::getHelp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCommandHelp

 /**
  * Displays the overall information of the command.
  * @param Controller $controller the controller instance
  */
 protected function getCommandHelp($controller)
 {
     $controller->color = $this->color;
     $this->stdout("\nDESCRIPTION\n", Console::BOLD);
     $comment = $controller->getHelp();
     if ($comment !== '') {
         $this->stdout("\n{$comment}\n\n");
     }
     $actions = $this->getActions($controller);
     if (!empty($actions)) {
         $this->stdout("\nSUB-COMMANDS\n\n", Console::BOLD);
         $prefix = $controller->getUniqueId();
         $maxlen = 5;
         foreach ($actions as $action) {
             $len = strlen($prefix . '/' . $action) + 2 + ($action === $controller->defaultAction ? 10 : 0);
             if ($maxlen < $len) {
                 $maxlen = $len;
             }
         }
         foreach ($actions as $action) {
             $this->stdout('- ' . $this->ansiFormat($prefix . '/' . $action, Console::FG_YELLOW));
             $len = strlen($prefix . '/' . $action) + 2;
             if ($action === $controller->defaultAction) {
                 $this->stdout(' (default)', Console::FG_GREEN);
                 $len += 10;
             }
             $summary = $controller->getActionHelpSummary($controller->createAction($action));
             if ($summary !== '') {
                 $this->stdout(str_repeat(' ', $maxlen - $len + 2) . Console::wrapText($summary, $maxlen + 2));
             }
             $this->stdout("\n");
         }
         $scriptName = $this->getScriptName();
         $this->stdout("\nTo see the detailed information about individual sub-commands, enter:\n");
         $this->stdout("\n  {$scriptName} " . $this->ansiFormat('help', Console::FG_YELLOW) . ' ' . $this->ansiFormat('<sub-command>', Console::FG_CYAN) . "\n\n");
     }
 }
開發者ID:drodata,項目名稱:yii2,代碼行數:41,代碼來源:HelpController.php

示例2: getCommandHelp

 /**
  * Displays the overall information of the command.
  * @param Controller $controller the controller instance
  */
 protected function getCommandHelp($controller)
 {
     $controller->color = $this->color;
     $this->stdout("\nDESCRIPTION\n", Console::BOLD);
     $comment = $controller->getHelp();
     if ($comment !== '') {
         $this->stdout("\n{$comment}\n\n");
     }
     $actions = $this->getActions($controller);
     if (!empty($actions)) {
         $this->stdout("\nSUB-COMMANDS\n\n", Console::BOLD);
         $prefix = $controller->getUniqueId();
         foreach ($actions as $action) {
             echo '- ' . $this->ansiFormat($prefix . '/' . $action, Console::FG_YELLOW);
             if ($action === $controller->defaultAction) {
                 $this->stdout(' (default)', Console::FG_GREEN);
             }
             $summary = $controller->getActionHelpSummary($controller->createAction($action));
             if ($summary !== '') {
                 echo ': ' . $summary;
             }
             echo "\n";
         }
         $scriptName = $this->getScriptName();
         echo "\nTo see the detailed information about individual sub-commands, enter:\n";
         echo "\n  {$scriptName} " . $this->ansiFormat('help', Console::FG_YELLOW) . ' ' . $this->ansiFormat('<sub-command>', Console::FG_CYAN) . "\n\n";
     }
 }
開發者ID:bigpower,項目名稱:yii2,代碼行數:32,代碼來源:HelpController.php


注:本文中的yii\console\Controller::getHelp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。