@@ 108-125 (lines=18) @@ | ||
105 | * @throws ReadException If the file cannot be read. |
|
106 | * @throws InvalidConfigException If the file contains invalid configuration. |
|
107 | */ |
|
108 | public function loadConfigFile($path, Config $baseConfig = null) |
|
109 | { |
|
110 | $json = $this->storage->read($path); |
|
111 | $jsonData = $this->decode($json, $path); |
|
112 | ||
113 | try { |
|
114 | return $this->configFileConverter->fromJson($jsonData, array( |
|
115 | 'path' => $path, |
|
116 | 'baseConfig' => $baseConfig, |
|
117 | )); |
|
118 | } catch (ConversionFailedException $e) { |
|
119 | throw new InvalidConfigException(sprintf( |
|
120 | 'The JSON in %s could not be converted: %s', |
|
121 | $path, |
|
122 | $e->getMessage() |
|
123 | ), 0, $e); |
|
124 | } |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * Saves a configuration file. |
@@ 119-135 (lines=17) @@ | ||
116 | * @throws ReadException If the file cannot be read. |
|
117 | * @throws InvalidConfigException If the file contains invalid configuration. |
|
118 | */ |
|
119 | public function loadModuleFile($path) |
|
120 | { |
|
121 | $json = $this->storage->read($path); |
|
122 | $jsonData = $this->decode($json, $path); |
|
123 | ||
124 | try { |
|
125 | return $this->moduleFileConverter->fromJson($jsonData, array( |
|
126 | 'path' => $path, |
|
127 | )); |
|
128 | } catch (ConversionFailedException $e) { |
|
129 | throw new InvalidConfigException(sprintf( |
|
130 | 'The JSON in %s could not be converted: %s', |
|
131 | $path, |
|
132 | $e->getMessage() |
|
133 | ), 0, $e); |
|
134 | } |
|
135 | } |
|
136 | ||
137 | /** |
|
138 | * Saves a module file. |
|
@@ 181-198 (lines=18) @@ | ||
178 | * @throws ReadException If the file cannot be read. |
|
179 | * @throws InvalidConfigException If the file contains invalid configuration. |
|
180 | */ |
|
181 | public function loadRootModuleFile($path, Config $baseConfig) |
|
182 | { |
|
183 | $json = $this->storage->read($path); |
|
184 | $jsonData = $this->decode($json, $path); |
|
185 | ||
186 | try { |
|
187 | return $this->rootModuleFileConverter->fromJson($jsonData, array( |
|
188 | 'path' => $path, |
|
189 | 'baseConfig' => $baseConfig, |
|
190 | )); |
|
191 | } catch (ConversionFailedException $e) { |
|
192 | throw new InvalidConfigException(sprintf( |
|
193 | 'The JSON in %s could not be converted: %s', |
|
194 | $path, |
|
195 | $e->getMessage() |
|
196 | ), 0, $e); |
|
197 | } |
|
198 | } |
|
199 | ||
200 | /** |
|
201 | * Saves a root module file. |