Example #1
0
 /**
  * @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;
 }
 public function beforeAction($action)
 {
     $this->fdb = Yii::$app->mysql;
     $this->db = Yii::$app->db;
     return parent::beforeAction($action);
     // TODO: Change the autogenerated stub
 }
 /**
  * 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;
     }
 }
 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
 }
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action) || !substr(gethostname(), strlen(gethostname()) - 6) == ".local") {
         return false;
     }
     return true;
 }
 public function beforeAction($action)
 {
     if (false === parent::beforeAction($action)) {
         return false;
     }
     return $this->module->has('importer');
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->db = Instance::ensure($this->db, Connection::className());
         return true;
     }
     return false;
 }
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         return Yii::$app->id == "mqg-proxy-agg-console";
     } else {
         return false;
     }
 }
 /**
  * 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;
     }
 }
Example #10
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (empty($this->path)) {
             throw new InvalidConfigException('`path` should be specified');
         }
     }
     return true;
 }
 public function beforeAction($action)
 {
     if (strtolower($this->verbose) === "false" || $this->verbose === "0") {
         $this->verbose = false;
     } else {
         $this->verbose = true;
     }
     return parent::beforeAction($action);
 }
 /**
  * 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;
     }
 }
Example #13
0
 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;
 }
Example #14
0
 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);
 }
 /**
  * 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;
     }
 }
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (is_file($this->filename)) {
             $this->_savedCommands = Json::decode(file_get_contents($this->filename));
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $this->module->controllerMap['migrate'] = ['class' => MigrateController::className(), 'interactive' => $this->interactive];
         $this->module->controllerMap['fixture'] = ['class' => FixtureController::className(), 'interactive' => $this->interactive, 'language' => $this->language];
         $this->stdout("Yii2 SimpleChat Demo\n\n", Console::BOLD);
         return true;
     } else {
         return false;
     }
 }
Example #18
0
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the authManager components.
  * @param \yii\base\Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     try {
         if (parent::beforeAction($action)) {
             $this->authManager = Instance::ensure($this->authManager, DbManager::className());
             return true;
         }
     } catch (Exception $e) {
         $this->stderr("ERROR: " . $e->getMessage() . "\n");
     }
     return false;
 }
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (in_array($action->id, ['numbers', 'documents']) && !is_dir($this->documentsPath)) {
             $this->stdout("Путь к каталогу документов неверный или не указан.\nЧтобы задать путь, нужно установить опцию: --documentsPath=dir_name\n");
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
Example #20
0
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the db and mailer components.
  * @param \yii\base\Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     try {
         if (parent::beforeAction($action)) {
             $this->db = Instance::ensure($this->db, Connection::className());
             $this->mailer = Instance::ensure($this->mailer, BaseMailer::className());
             return true;
         }
     } catch (Exception $e) {
         Log::error($e->getMessage(), null, __METHOD__);
     }
     return false;
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (!strcmp($action->id, 'start') || !strcmp($action->id, 'stop')) {
             $this->module->initDemo();
             $this->module->controllerMap['migrate'] = ['class' => 'bubasuma\\simplechat\\console\\MigrateController', 'migrationPath' => $this->migrationPath];
         }
         $this->stdout("Yii2 SimpleChat Demo\n\n", Console::BOLD);
         return true;
     } else {
         return false;
     }
 }
Example #22
0
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * It checks the existence of the db and mailer components.
  * @param \yii\base\Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     try {
         if (parent::beforeAction($action)) {
             $this->db = Instance::ensure($this->db, Connection::className());
             $this->mailer = Instance::ensure($this->mailer, BaseMailer::className());
             return true;
         }
     } catch (Exception $e) {
         $this->stderr("ERROR: " . $e->getMessage() . "\n");
     }
     return false;
 }
Example #23
0
 /**
  * Before action event
  *
  * @param \yii\base\Action $action
  *
  * @return bool
  */
 public function beforeAction($action)
 {
     $this->command = $action->controller->id . '/' . $action->id;
     if ($this->isDisabledAction($action->id)) {
         $this->stdout("Command '{$this->command}' is disabled.\n", Console::FG_RED);
         return false;
     }
     if (!parent::beforeAction($action)) {
         return false;
     }
     $this->stdout("Running the command `{$this->command}` at the " . Yii::$app->formatter->asDatetime(time()) . "\n", Console::FG_GREEN);
     return true;
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (is_string($this->db)) {
             $this->db = Yii::$app->get($this->db);
         }
         if (!$this->db instanceof Connection) {
             throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
         }
         return true;
     }
     return false;
 }
Example #25
0
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     $connection = Yii::$app->get($this->name);
     $driverName = Driver::driverName($connection);
     if (!isset($this->drivers[$driverName])) {
         throw new Exception(Yii::t('yii', 'Unknown database driver: {name}', ['name' => $driverName]));
     }
     $this->driver = Yii::createObject($this->drivers[$driverName], [$connection]);
     return true;
 }
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (getenv('QUEUE_TIMEOUT')) {
         $this->timeout = (int) getenv('QUEUE_TIMEOUT') + time();
     }
     if (getenv('QUEUE_SLEEP')) {
         $this->sleep = (int) getenv('QUEUE_SLEEP');
     }
     return true;
 }
 /**
  * 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 Exception if db component isn't configured
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $path = Yii::getAlias($this->migrationPath);
         if (!is_dir($path)) {
             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;
     }
 }
Example #28
0
 /**
  * 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.
  * @return boolean whether the action should continue to be executed.
  * @throws Exception if the migration directory does not exist.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (is_string($this->db)) {
             $this->db = Yii::$app->get($this->db);
         }
         if (!$this->db instanceof Connection) {
             throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
         }
         $version = Yii::getVersion();
         echo "Yii Seed Tool (based on Yii v{$version})\n";
         return true;
     } else {
         return false;
     }
 }
 /**
  * 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 db component isn't configured
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if (is_string($this->db)) {
             $this->db = Yii::$app->get($this->db);
         }
         if (!$this->db instanceof Connection) {
             throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
         }
         echo "Yee CMS Root User Init Tool\n";
         if (isset($this->db->dsn)) {
             echo "Database Connection: " . $this->db->dsn . "\n\n";
         }
         return true;
     } else {
         return false;
     }
 }
Example #30
0
 /**
  * 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 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)) {
         $path = Yii::getAlias($this->migrationPath);
         if (!is_dir($path)) {
             if ($action->id !== 'create') {
                 throw new Exception("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;
     }
 }