/** * Loads a configuration file from a path. * * If the path does not exist, an empty configuration file is returned. * * @param string $path The path to the configuration file. * @param Config|null $baseConfig The configuration that the loaded * configuration will inherit its values * from. * * @return ConfigFile The loaded configuration file. * * @throws FileNotFoundException If the file does not exist. * @throws ReadException If the file cannot be read. * @throws InvalidConfigException If the file contains invalid configuration. */ public function loadConfigFile($path, Config $baseConfig = null) { $json = $this->storage->read($path); $jsonData = $this->decode($json, $path); try { return $this->configFileConverter->fromJson($jsonData, array('path' => $path, 'baseConfig' => $baseConfig)); } catch (ConversionFailedException $e) { throw new InvalidConfigException(sprintf('The JSON in %s could not be converted: %s', $path, $e->getMessage()), 0, $e); } }
/** * {@inheritdoc} */ public function fromJson($jsonData, array $options = array()) { $this->assertObject($jsonData); $this->assertVersionIsset($jsonData); $this->assertVersionSupported($jsonData->version); if ($jsonData->version !== $this->currentVersion) { $this->migrationManager->migrate($jsonData, $this->currentVersion); } return $this->innerConverter->fromJson($jsonData, $options); }
/** * {@inheritdoc} */ public function fromJson($jsonData, array $options = array()) { $this->validate($jsonData); return $this->innerConverter->fromJson($jsonData, $options); }