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


PHP console\Controller类代码示例

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


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

示例1: init

 public function init()
 {
     parent::init();
     if (empty(Yii::$app->params['hook_secret'])) {
         throw new Exception('Config param "hook_secret" is not configured!');
     }
 }
开发者ID:yiisoft-contrib,项目名称:github-bot,代码行数:7,代码来源:GithubController.php

示例2: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     $this->apiKey = trim($this->apiKey);
     $this->apiLanguage = strtolower(trim($this->apiLanguage));
     $this->apiFormat = strtoupper(trim($this->apiFormat));
     $this->verbose = !!$this->verbose;
     // check API key
     if (empty($this->apiKey)) {
         throw new Exception('Operation failed. Steam API key is empty.');
     }
     // check language
     if (strlen(utf8_decode($this->apiLanguage)) !== 5 || strpos($this->apiLanguage, '_') === false) {
         $this->apiLanguage = self::DEFAULT_API_LANG;
         if ($this->verbose) {
             $this->stderr('Language is invalid. Default language "' . $this->apiLanguage . '" is used.' . PHP_EOL, Console::FG_YELLOW);
         }
     }
     // check format
     if (!in_array($this->apiFormat, self::$_apiFormats)) {
         $this->apiFormat = self::DEFAULT_API_FORMAT;
         if ($this->verbose) {
             $this->stderr('Format is invalid. Default format "' . $this->apiFormat . '" is used.' . PHP_EOL, Console::FG_YELLOW);
         }
     }
     // check result type
     if (empty($this->resultType)) {
         $this->stderr('Result type is empty.' . PHP_EOL, Console::FG_RED);
         return self::EXIT_CODE_ERROR;
     }
     $this->apiUrlSuffix = '/?key=' . $this->apiKey . '&language=' . $this->apiLanguage . '&format=' . $this->apiFormat;
     return true;
 }
开发者ID:aldegtyarev,项目名称:fantasy,代码行数:38,代码来源:MainController.php

示例3: confirm

 public function confirm($message, $default = false)
 {
     if (!$this->interactive) {
         return true;
     }
     return parent::confirm($message, $default);
 }
开发者ID:netis-pl,项目名称:yii2-fsm,代码行数:7,代码来源:FsmController.php

示例4: beforeAction

 public function beforeAction($action)
 {
     $this->fdb = Yii::$app->mysql;
     $this->db = Yii::$app->db;
     return parent::beforeAction($action);
     // TODO: Change the autogenerated stub
 }
开发者ID:KKRainbow,项目名称:ngpt_seed,代码行数:7,代码来源:TransferController.php

示例5: beforeAction

 public function beforeAction($action)
 {
     $this->interpreterPath = Yii::$app->controllerMap['cron']['interpreterPath'];
     $this->bootstrapScript = Yii::$app->controllerMap['cron']['bootstrapScript'];
     return parent::beforeAction($action);
     // TODO: Change the autogenerated stub
 }
开发者ID:hzted123,项目名称:yii2-amqp,代码行数:7,代码来源:ListenerManageController.php

示例6: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the [[migrationPath]].
  * @param \yii\base\Action $action the action to be executed.
  * @throws InvalidConfigException if directory specified in migrationPath doesn't exist and action isn't "create".
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (empty($this->migrationNamespaces) && empty($this->migrationPath)) {
             throw new InvalidConfigException('At least one of `migrationPath` or `migrationNamespaces` should be specified.');
         }
         foreach ($this->migrationNamespaces as $key => $value) {
             $this->migrationNamespaces[$key] = trim($value, '\\');
         }
         if ($this->migrationPath !== null) {
             $path = Yii::getAlias($this->migrationPath);
             if (!is_dir($path)) {
                 if ($action->id !== 'create') {
                     throw new InvalidConfigException("Migration failed. Directory specified in migrationPath doesn't exist: {$this->migrationPath}");
                 }
                 FileHelper::createDirectory($path);
             }
             $this->migrationPath = $path;
         }
         $version = Yii::getVersion();
         $this->stdout("Yii Migration Tool (based on Yii v{$version})\n\n");
         return true;
     } else {
         return false;
     }
 }
开发者ID:Abbas-Hashemian,项目名称:yii2,代码行数:33,代码来源:BaseMigrateController.php

示例7: beforeAction

 public function beforeAction($action)
 {
     if (!parent::beforeAction($action) || !substr(gethostname(), strlen(gethostname()) - 6) == ".local") {
         return false;
     }
     return true;
 }
开发者ID:johnitvn,项目名称:mg075hynlo5793r5gt,代码行数:7,代码来源:SeedController.php

示例8: init

 public function init()
 {
     parent::init();
     $this->token = (require __DIR__ . '/token.php');
     $this->datePath = __DIR__ . "/dateLastQuery.txt";
     $this->dateLastQuery = $this->getDateLastQuery();
 }
开发者ID:Olwn,项目名称:pm25,代码行数:7,代码来源:AirQualityController.php

示例9: beforeAction

 public function beforeAction($action)
 {
     if (false === parent::beforeAction($action)) {
         return false;
     }
     return $this->module->has('importer');
 }
开发者ID:filsh,项目名称:yii2-geonames,代码行数:7,代码来源:TranslateController.php

示例10: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     // Support cyrillic on windows
     if ($this->isWindows()) {
         system("chcp 65001");
     }
 }
开发者ID:uaoleg,项目名称:vvkp.in.ua,代码行数:11,代码来源:BaseController.php

示例11: options

 /**
  * 选项
  * @param string $actionID
  * @return array
  */
 public function options($actionID)
 {
     if ($actionID == 'index') {
         return array_merge(parent::options($actionID), ['phpEnv', 'processMaxNum']);
     } else {
         return parent::options($actionID);
     }
 }
开发者ID:wayhood,项目名称:yii2-asynctask,代码行数:13,代码来源:AsyncTaskController.php

示例12: beforeAction

 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         return Yii::$app->id == "mqg-proxy-agg-console";
     } else {
         return false;
     }
 }
开发者ID:ufrgs-hyman,项目名称:proxy-agg,代码行数:8,代码来源:CrontabController.php

示例13: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->db = Instance::ensure($this->db, Connection::className());
         return true;
     }
     return false;
 }
开发者ID:jamband,项目名称:yii2-schemadump,代码行数:11,代码来源:SchemaDumpController.php

示例14: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     // allow console requests only
     if (!Yii::$app->request->isConsoleRequest) {
         throw new HttpException(404, 'The requested page does not exist.');
     }
     parent::init();
 }
开发者ID:anawatom,项目名称:second,代码行数:11,代码来源:CopyController.php

示例15: options

 public function options($id)
 {
     $options = [];
     if (in_array($id, ['start', 'restart'])) {
         $options = ['fork'];
     }
     return array_merge(parent::options($id), $options);
 }
开发者ID:shakura,项目名称:yii2-gearman,代码行数:8,代码来源:GearmanController.php


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