console\controllers\MigrateController::beforeAction PHP Method

beforeAction() public method

This method is invoked right before an action is to be executed (after all possible filters.) It checks the existence of the [[migrationPath]].
public beforeAction ( Action $action ) : boolean
$action yii\base\Action the action to be executed.
return boolean whether the action should continue to be executed.
    public function beforeAction($action)
    {
        if (parent::beforeAction($action)) {
            $path = Yii::getAlias($this->migrationPath);
            if ($action->id !== 'create') {
                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.");
                }
            } else {
                if (!is_dir($path)) {
                    echo "\n{$path} does not exist, creating...";
                    FileHelper::createDirectory($path);
                }
            }
            $version = Yii::getVersion();
            echo "Yii Migration Tool (based on Yii v{$version})\n\n";
            if (isset($this->db->dsn)) {
                echo "Database Connection: " . $this->db->dsn . "\n";
            }
            return true;
        } else {
            return false;
        }
    }