RainLab\Builder\Classes\MigrationModel::insertOrUpdateVersion PHP Method

insertOrUpdateVersion() protected method

protected insertOrUpdateVersion ( )
    protected function insertOrUpdateVersion()
    {
        $versionFilePath = $this->getPluginUpdatesPath('version.yaml');
        $versionInformation = $this->getPluginVersionInformation();
        if (!$versionInformation) {
            $versionInformation = [];
        }
        $originalFileContents = File::get($versionFilePath);
        if (!$originalFileContents) {
            throw new SystemException(sprintf('Error loading file %s', $versionFilePath));
        }
        $versionInformation[$this->version] = [$this->description];
        if (strlen($this->scriptFileName)) {
            $versionInformation[$this->version][] = $this->scriptFileName . '.php';
        }
        if (!$this->isNewModel() && $this->version != $this->originalVersion) {
            if (array_key_exists($this->originalVersion, $versionInformation)) {
                unset($versionInformation[$this->originalVersion]);
            }
        }
        $yamlData = Yaml::render($versionInformation);
        if (!File::put($versionFilePath, $yamlData)) {
            throw new SystemException(sprintf('Error saving file %s', $versionFilePath));
        }
        @File::chmod($versionFilePath);
        return $originalFileContents;
    }