Exemplo n.º 1
0
 /**
  * Method to write the configuration to a file.
  *
  * @param   object  $config  A Registry object containing all global config data.
  * @return  bool    True on success, false on failure.
  * @since   2.5.4
  */
 private function writeConfigFile($data)
 {
     if ($data instanceof \Hubzero\Config\Repository) {
         $data = $data->toArray();
     }
     // Attempt to write the configuration files
     $writer = new \Hubzero\Config\FileWriter('php', PATH_APP . DS . 'config');
     $client = null;
     foreach ($data as $group => $values) {
         if (!$writer->write($values, $group, $client)) {
             $this->setError(Lang::txt('COM_CONFIG_ERROR_WRITE_FAILED'));
             return false;
         }
     }
     $legacy = new \Hubzero\Config\Legacy();
     if ($legacy->exists()) {
         $legacy->reset();
         foreach ($data as $group => $values) {
             foreach ($values as $key => $val) {
                 $legacy->set($key, $val);
             }
         }
         $legacy->update();
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Split the config file into new format
  *
  * @param   string  $format
  * @param   string  $path
  * @return  void
  */
 public function split($format = null, $path = null)
 {
     $format = $format ?: 'php';
     $path = $path ?: PATH_APP . DS . 'config';
     $writer = new \Hubzero\Config\FileWriter($format, $path);
     foreach ($this->map as $group => $values) {
         $contents = array();
         foreach ($values as $key) {
             $contents[$key] = $this->get($group . '.' . $key);
         }
         $writer->write($contents, $group);
     }
 }