Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     $path = isset($options['path']) ? $options['path'] : null;
     $baseConfig = isset($options['baseConfig']) ? $options['baseConfig'] : null;
     Assert::isInstanceOf($jsonData, 'stdClass');
     Assert::nullOrString($path, 'The "path" option should be null or a string. Got: %s');
     Assert::nullOrIsInstanceOf($baseConfig, 'Puli\\Manager\\Api\\Config\\Config', 'The "baseConfig" option should be null or an instance of %2$s. Got: %s');
     $moduleFile = new RootModuleFile(null, $path, $baseConfig);
     $moduleFile->setVersion($this->versioner->parseVersion($jsonData));
     $this->addJsonToModuleFile($jsonData, $moduleFile);
     $this->addJsonToRootModuleFile($jsonData, $moduleFile);
     return $moduleFile;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function migrate($targetVersion)
 {
     $previousVersion = $this->rootModuleFile->getVersion();
     if ($previousVersion === $targetVersion) {
         return;
     }
     $this->rootModuleFile->setVersion($targetVersion);
     try {
         $this->jsonStorage->saveRootModuleFile($this->rootModuleFile);
     } catch (Exception $e) {
         $this->rootModuleFile->setVersion($previousVersion);
         throw $e;
     }
 }