RainLab\Builder\Classes\MigrationModel::initVersion PHP 메소드

initVersion() 공개 메소드

public initVersion ( $versionType )
    public function initVersion($versionType)
    {
        $versionTypes = ['migration', 'seeder', 'custom'];
        if (!in_array($versionType, $versionTypes)) {
            throw new SystemException('Unknown version type.');
        }
        $this->version = $this->getNextVersion();
        if ($versionType == 'custom') {
            $this->scriptFileName = null;
            return;
        }
        $templateFiles = ['migration' => 'migration.php.tpl', 'seeder' => 'seeder.php.tpl'];
        $templatePath = '$/rainlab/builder/classes/migrationmodel/templates/' . $templateFiles[$versionType];
        $templatePath = File::symbolizePath($templatePath);
        $fileContents = File::get($templatePath);
        $scriptFileName = $versionType . str_replace('.', '-', $this->version);
        $pluginCodeObj = $this->getPluginCodeObj();
        $this->code = TextParser::parse($fileContents, ['className' => Str::studly($scriptFileName), 'namespace' => $pluginCodeObj->toUpdatesNamespace(), 'tableNamePrefix' => $pluginCodeObj->toDatabasePrefix()]);
        $this->scriptFileName = $scriptFileName;
    }