/**
  * {@inheritdoc}
  */
 public function migrate($targetVersion)
 {
     $previousVersion = $this->rootPackageFile->getVersion();
     if ($previousVersion === $targetVersion) {
         return;
     }
     $this->rootPackageFile->setVersion($targetVersion);
     try {
         $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
     } catch (Exception $e) {
         $this->rootPackageFile->setVersion($previousVersion);
         throw $e;
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function unserializeRootPackageFile($serialized, $path = null, Config $baseConfig = null)
 {
     $packageFile = new RootPackageFile(null, $path, $baseConfig);
     $jsonData = $this->decode($serialized, $path);
     // Remember original version of the package file
     $packageFile->setVersion($jsonData->version);
     // Migrate to the expected version
     $this->migrationManager->migrate($jsonData, $this->targetVersion);
     $this->jsonToPackageFile($jsonData, $packageFile);
     $this->jsonToRootPackageFile($jsonData, $packageFile);
     return $packageFile;
 }