luya\console\commands\MigrateController::createMigration PHP Method

createMigration() protected method

Create a migration based on its class name.
See also: yii\console\controllers\MigrateController::createMigration()
protected createMigration ( $class )
    protected function createMigration($class)
    {
        $orig = $this->migrationPath . DIRECTORY_SEPARATOR . $class . '.php';
        if (file_exists($orig)) {
            require_once $orig;
            return new $class();
        } else {
            if (isset($this->migrationFileDirs[$class])) {
                $file = $this->migrationFileDirs[$class] . DIRECTORY_SEPARATOR . $class . '.php';
                if (file_exists($file)) {
                    require_once $file;
                    return new $class();
                }
            }
        }
        $module = $this->prompt("Could not find migration class. Please enter the module name who belongs to '{$class}.':");
        $dir = $this->getModuleMigrationDirectorie($module);
        $file = $dir . DIRECTORY_SEPARATOR . $class . '.php';
        if (file_exists($file)) {
            require_once $file;
            return new $class();
        }
        throw new Exception("Unable to find migration for provided module {$file}.");
    }