Esempio n. 1
0
 /**
  * Saves a configuration file.
  *
  * The configuration file is saved to the same path that it was read from.
  *
  * @param ConfigFile $configFile The configuration file to save.
  *
  * @throws StorageException If the file cannot be written.
  */
 public function saveConfigFile(ConfigFile $configFile)
 {
     $serialized = $this->serializer->serializeConfigFile($configFile);
     $this->storage->write($configFile->getPath(), $serialized);
     if ($this->factoryManager) {
         $this->factoryManager->autoGenerateFactoryClass();
     }
 }
Esempio n. 2
0
 private function saveFile($file, $path, array $options = array())
 {
     $className = get_class($file);
     try {
         $jsonData = $this->converterProvider->getJsonConverter($className)->toJson($file, $options);
     } catch (ConversionFailedException $e) {
         throw new InvalidConfigException(sprintf('The data written to %s could not be converted: %s', $path, $e->getMessage()), 0, $e);
     }
     $json = $this->encode($jsonData, $path);
     $this->storage->write($path, $json);
 }
Esempio n. 3
0
 /**
  * Saves a configuration file.
  *
  * The configuration file is saved to the same path that it was read from.
  *
  * @param ConfigFile $configFile The configuration file to save.
  *
  * @throws WriteException         If the file cannot be written.
  * @throws InvalidConfigException If the file contains invalid configuration.
  */
 public function saveConfigFile(ConfigFile $configFile)
 {
     try {
         $jsonData = $this->configFileConverter->toJson($configFile);
     } catch (ConversionFailedException $e) {
         throw new InvalidConfigException(sprintf('The data written to %s could not be converted: %s', $configFile->getPath(), $e->getMessage()), 0, $e);
     }
     $json = $this->encode($jsonData, $configFile->getPath());
     $this->storage->write($configFile->getPath(), $json);
     if ($this->factoryManager) {
         $this->factoryManager->autoGenerateFactoryClass();
     }
 }