public function beforeAction($action) { if (parent::beforeAction($action)) { if ($action->id !== 'create') { $this->db = Instance::ensure($this->db, Connection::className()); } return true; } else { return false; } }
public function beforeAction($action) { $oldPath = $this->migrationPath; $this->migrationPath = $this->defaultMigrationPath; if (parent::beforeAction($action)) { $this->stdout('Migration files will be searched in folders: ' . PHP_EOL); $this->migrationPath = $oldPath; if ($this->moduleId) { $this->migrationPath = $this->getMigrationPath($this->moduleId); } if ($this->migrationPath) { $this->migrationPaths[] = $this->migrationPath; } else { $this->migrationPaths[] = $this->defaultMigrationPath; foreach (Yii::$app->modules as $name => $module) { $this->migrationPaths[] = $this->getMigrationPath($name); } } $this->migrationPaths = array_unique($this->migrationPaths); for ($i = 0; $i < count($this->migrationPaths); $i++) { $this->migrationPaths[$i] = Yii::getAlias($this->migrationPaths[$i]); $this->stdout(' - ' . $this->migrationPaths[$i] . PHP_EOL); } $this->stdout(PHP_EOL); return true; } else { return false; } }