php yii-console-Controller类(方法)实例源码

下面列出了php yii-console-Controller 类(方法)源码代码实例,从而了解它的用法。

作者:aoye    项目:yii2-daemo   
/**
  * Init function
  */
 public function init()
 {
     parent::init();
     //set PCNTL signal handlers
     pcntl_signal(SIGTERM, ['vyants\\daemon\\DaemonController', 'signalHandler']);
     pcntl_signal(SIGHUP, ['vyants\\daemon\\DaemonController', 'signalHandler']);
     pcntl_signal(SIGUSR1, ['vyants\\daemon\\DaemonController', 'signalHandler']);
     pcntl_signal(SIGCHLD, ['vyants\\daemon\\DaemonController', 'signalHandler']);
     $this->shortName = $this->shortClassName();
 }

作者:yiisoft-contri    项目:github-bo   
public function init()
 {
     parent::init();
     if (empty(Yii::$app->params['hook_secret'])) {
         throw new Exception('Config param "hook_secret" is not configured!');
     }
 }

作者:aldegtyare    项目:fantas   
/**
  * @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;
 }

作者:netis-p    项目:yii2-fs   
public function confirm($message, $default = false)
 {
     if (!$this->interactive) {
         return true;
     }
     return parent::confirm($message, $default);
 }

作者:KKRainbo    项目:ngpt_see   
public function beforeAction($action)
 {
     $this->fdb = Yii::$app->mysql;
     $this->db = Yii::$app->db;
     return parent::beforeAction($action);
     // TODO: Change the autogenerated stub
 }

作者:hzted12    项目:yii2-amq   
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
 }

作者:Abbas-Hashemia    项目:yii   
/**
  * 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;
     }
 }

作者:johnitv    项目:mg075hynlo5793r5g   
public function beforeAction($action)
 {
     if (!parent::beforeAction($action) || !substr(gethostname(), strlen(gethostname()) - 6) == ".local") {
         return false;
     }
     return true;
 }

作者:Olw    项目:pm2   
public function init()
 {
     parent::init();
     $this->token = (require __DIR__ . '/token.php');
     $this->datePath = __DIR__ . "/dateLastQuery.txt";
     $this->dateLastQuery = $this->getDateLastQuery();
 }

作者:fils    项目:yii2-geoname   
public function beforeAction($action)
 {
     if (false === parent::beforeAction($action)) {
         return false;
     }
     return $this->module->has('importer');
 }

作者:uaole    项目:vvkp.in.u   
/**
  * Init
  */
 public function init()
 {
     parent::init();
     // Support cyrillic on windows
     if ($this->isWindows()) {
         system("chcp 65001");
     }
 }

作者:wayhoo    项目:yii2-asynctas   
/**
  * 选项
  * @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);
     }
 }

作者:ufrgs-hyma    项目:proxy-ag   
public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         return Yii::$app->id == "mqg-proxy-agg-console";
     } else {
         return false;
     }
 }

作者:jamban    项目:yii2-schemadum   
/**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->db = Instance::ensure($this->db, Connection::className());
         return true;
     }
     return false;
 }

作者:anawato    项目:secon   
/**
  * @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();
 }

作者:shakur    项目:yii2-gearma   
public function options($id)
 {
     $options = [];
     if (in_array($id, ['start', 'restart'])) {
         $options = ['fork'];
     }
     return array_merge(parent::options($id), $options);
 }

作者:denisdd    项目:steale   
public function options($id)
 {
     $options = parent::options($id);
     $options[] = 'fake_steal';
     $options[] = 'file_report';
     $options[] = 'continue';
     return $options;
 }

作者:didwjdgk    项目:yii2-ebid-e   
public function init()
 {
     parent::init();
     $this->gman_worker = new \GearmanWorker();
     $this->gman_worker->addServers($this->module->gman_server);
     $this->gman_client = new \GearmanClient();
     $this->gman_client->addServers($this->module->gman_server);
 }

作者:dmst    项目:yii2-yaml-converter-comman   
/**
  * 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;
     }
 }

作者:jeremylt    项目:yii2-schedule   
public function beforeAction($action)
 {
     if (strtolower($this->verbose) === "false" || $this->verbose === "0") {
         $this->verbose = false;
     } else {
         $this->verbose = true;
     }
     return parent::beforeAction($action);
 }


问题


面经


文章

微信
公众号

扫码关注公众号