Horde_Config::generatePHPConfig PHP Method

generatePHPConfig() public method

Generates the content of the application's configuration file.
public generatePHPConfig ( Horde_Variables $formvars, array $custom_conf = null ) : string
$formvars Horde_Variables The processed configuration form data.
$custom_conf array Any settings that shall be included in the generated configuration.
return string The content of the generated configuration file.
    public function generatePHPConfig($formvars, $custom_conf = null)
    {
        $this->readXMLConfig($custom_conf);
        $this->getPHPConfig();
        $this->_phpConfig = "<?php\n" . $this->_preConfig . $this->_configBegin;
        if (!empty($this->_versionTag)) {
            $this->_phpConfig .= '// ' . $this->_versionTag;
        }
        $this->_generatePHPConfig($this->_xmlConfigTree, '', $formvars);
        $this->_phpConfig .= $this->_configEnd . $this->_postConfig;
        return $this->_phpConfig;
    }

Usage Example

コード例 #1
0
ファイル: Bundle.php プロジェクト: raz0rsdge/horde
 /**
  * Writes the current configuration to the conf.php file.
  *
  * @throws Horde_Exception
  */
 public function writeConfig(Horde_Variables $vars)
 {
     $this->_cli->writeln();
     echo 'Writing main configuration file...';
     $php_config = $this->_config->generatePHPConfig($vars, $GLOBALS['conf']);
     $configFile = $this->_config->configFile();
     $fp = fopen($configFile, 'w');
     if (!$fp) {
         throw new Horde_Exception('Cannot write configuration file ' . Horde_Util::realPath($configFile));
     }
     fwrite($fp, $php_config);
     fclose($fp);
     // Reload configuration.
     include $configFile;
     $GLOBALS['conf'] = $conf;
     $this->_cli->writeln($this->_cli->green(' done.'));
 }