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


PHP Controller::beforeAction方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: beforeAction

 public function beforeAction($action)
 {
     if (false === parent::beforeAction($action)) {
         return false;
     }
     return $this->module->has('importer');
 }
開發者ID:filsh,項目名稱:yii2-geonames,代碼行數:7,代碼來源:TranslateController.php

示例7: 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

示例8: 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

示例9: beforeAction

 /**
  * Checks for write permissions in outputDirectory
  * @throws Exception
  */
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     if (!is_writable(\Yii::getAlias($this->outputDirectory))) {
         throw new Exception("Invalid outputDirectory: '{$this->outputDirectory}' is not writable");
     } else {
         return true;
     }
 }
開發者ID:dmstr,項目名稱:yii2-yaml-converter-command,代碼行數:13,代碼來源:BaseYamlConverterController.php

示例10: beforeAction

 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (empty($this->path)) {
             throw new InvalidConfigException('`path` should be specified');
         }
     }
     return true;
 }
開發者ID:rkit,項目名稱:bootstrap-yii2,代碼行數:9,代碼來源:RbacController.php

示例11: beforeAction

 public function beforeAction($action)
 {
     if (strtolower($this->verbose) === "false" || $this->verbose === "0") {
         $this->verbose = false;
     } else {
         $this->verbose = true;
     }
     return parent::beforeAction($action);
 }
開發者ID:jeremyltn,項目名稱:yii2-scheduler,代碼行數:9,代碼來源:ScheduleController.php

示例12: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * @param \yii\base\Action $action the action to be executed.
  * @throws Exception 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)) {
         $version = Yii::getVersion();
         $this->stdout("Yii PubSub Tool (based on Yii v{$version})\n\n");
         return true;
     } else {
         return false;
     }
 }
開發者ID:highestgoodlikewater,項目名稱:yii2-queue,代碼行數:16,代碼來源:BaseQueueController.php

示例13: beforeAction

 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (Yii::$app instanceof \yii\web\Application) {
         throw new ForbiddenHttpException('You are not allowed to access this page.');
     }
     return true;
 }
開發者ID:ufrgs-hyman,項目名稱:meican,代碼行數:10,代碼來源:ServiceController.php

示例14: beforeAction

 public function beforeAction($action)
 {
     $path = Yii::getAlias($this->migrationPath);
     if ($path === false || !is_dir($path)) {
         echo 'Error: The migration directory does not exist: ' . $this->migrationPath . "\n";
         exit(1);
     }
     $this->migrationPath = $path;
     return parent::beforeAction($action);
 }
開發者ID:netis-pl,項目名稱:yii2-fsm,代碼行數:10,代碼來源:FsmController.php

示例15: beforeAction

 /**
  * extending parent
  * @access public
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if ($this->db === null) {
             $this->db = Yii::$app->db;
         }
         return 1;
     } else {
         return 0;
     }
 }
開發者ID:mirkhamidov,項目名稱:yii2-console-dbextend,代碼行數:15,代碼來源:DbexController.php


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