Example #1
0
 /**
  * Saves config
  *
  * @param array $data
  * @param bool $override
  * @return void
  */
 public function saveConfig(array $data, $override = false)
 {
     $paths = $this->configFilePool->getPaths();
     foreach ($data as $fileKey => $config) {
         if (isset($paths[$fileKey])) {
             if ($this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->isExist($paths[$fileKey])) {
                 $currentData = $this->reader->load($fileKey);
                 if ($override) {
                     $config = array_merge($currentData, $config);
                 } else {
                     $config = array_replace_recursive($currentData, $config);
                 }
             }
             $contents = $this->formatter->format($config);
             try {
                 $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile($paths[$fileKey], $contents);
             } catch (FileSystemException $e) {
                 throw new FileSystemException(new Phrase('Deployment config file %1 is not writable.', [$paths[$fileKey]]));
             }
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($this->filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath($paths[$fileKey]));
             }
         }
     }
     $this->deploymentConfig->resetData();
 }
Example #2
0
 /**
  * Saves config
  *
  * @param array $data
  * @param bool $override
  * @return void
  */
 public function saveConfig(array $data, $override = false)
 {
     $paths = $this->configFilePool->getPaths();
     foreach ($data as $fileKey => $config) {
         if (isset($paths[$fileKey])) {
             if ($this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->isExist($paths[$fileKey])) {
                 $currentData = $this->reader->load($paths[$fileKey]);
                 if ($override) {
                     $config = array_merge($currentData, $config);
                 } else {
                     $config = array_replace_recursive($currentData, $config);
                 }
             }
             $contents = $this->formatter->format($config);
             $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile($paths[$fileKey], $contents);
         }
     }
     $this->deploymentConfig->resetData();
 }
Example #3
0
 /**
  * Persists the data into file
  *
  * @param array $data
  * @return void
  */
 private function write($data)
 {
     $contents = $this->formatter->format($data);
     $this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile($this->reader->getFile(), $contents);
 }