Updates the version of a JSON object.
public updateVersion ( stdClass $jsonData, string $version ) | ||
$jsonData | stdClass | The JSON object |
$version | string | The version to set |
private function down($data, $sourceVersion, $targetVersion) { while (version_compare($sourceVersion, $targetVersion, '>')) { if (!isset($this->migrationsByTargetVersion[$sourceVersion])) { throw new MigrationFailedException(sprintf('No migration found to downgrade from version %s to %s.', $sourceVersion, $targetVersion)); } $migration = $this->migrationsByTargetVersion[$sourceVersion]; // Final version too low if (version_compare($migration->getSourceVersion(), $targetVersion, '<')) { throw new MigrationFailedException(sprintf('No migration found to downgrade from version %s to %s.', $sourceVersion, $targetVersion)); } $migration->down($data); $this->versioner->updateVersion($data, $migration->getSourceVersion()); $sourceVersion = $migration->getSourceVersion(); } }