writeConfigFile() public method

Writes data into a config layer from a file.
public writeConfigFile ( $file = null, $layer = 'user', $data = null ) : boolean
return boolean TRUE on success or a PEAR error on failure
コード例 #1
0
ファイル: Role.php プロジェクト: jubinpatel/horde
 /**
  * Run task after prompt.
  *
  * @param array $info   Parameter array.
  * @param string $name  Postinstall phase.
  */
 public function run($info, $phase)
 {
     if ($phase !== 'first') {
         return;
     }
     if (!$this->_config->set('horde_dir', $info['horde_dir'], 'user', 'pear.horde.org')) {
         print "Could not save horde_dir configuration value to PEAR config.\n";
         return;
     }
     $res = $this->_config->writeConfigFile();
     if ($res instanceof PEAR_Error) {
         print 'ERROR: ' . $res->getMessage() . "\n";
         exit;
     }
     print "Configuration successfully saved to PEAR config.\n";
 }
コード例 #2
0
ファイル: Config.php プロジェクト: HaldunA/phpwebsite
 function doConfigCreate($command, $options, $params)
 {
     if (count($params) != 2) {
         return PEAR::raiseError('config-create: must have 2 parameters, root path and ' . 'filename to save as');
     }
     $root = $params[0];
     // Clean up the DIRECTORY_SEPARATOR mess
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     $root = preg_replace(array('!\\\\+!', '!/+!', "!{$ds2}+!"), array('/', '/', '/'), $root);
     if ($root[0] != '/') {
         if (!isset($options['windows'])) {
             return PEAR::raiseError('Root directory must be an absolute path beginning ' . 'with "/", was: "' . $root . '"');
         }
         if (!preg_match('/^[A-Za-z]:/', $root)) {
             return PEAR::raiseError('Root directory must be an absolute path beginning ' . 'with "\\" or "C:\\", was: "' . $root . '"');
         }
     }
     $windows = isset($options['windows']);
     if ($windows) {
         $root = str_replace('/', '\\', $root);
     }
     if (!file_exists($params[1]) && !@touch($params[1])) {
         return PEAR::raiseError('Could not create "' . $params[1] . '"');
     }
     $params[1] = realpath($params[1]);
     $config = new PEAR_Config($params[1], '#no#system#config#', false, false);
     if ($root[strlen($root) - 1] == '/') {
         $root = substr($root, 0, strlen($root) - 1);
     }
     $config->noRegistry();
     $config->set('php_dir', $windows ? "{$root}\\pear\\php" : "{$root}/pear/php", 'user');
     $config->set('data_dir', $windows ? "{$root}\\pear\\data" : "{$root}/pear/data");
     $config->set('www_dir', $windows ? "{$root}\\pear\\www" : "{$root}/pear/www");
     $config->set('cfg_dir', $windows ? "{$root}\\pear\\cfg" : "{$root}/pear/cfg");
     $config->set('ext_dir', $windows ? "{$root}\\pear\\ext" : "{$root}/pear/ext");
     $config->set('doc_dir', $windows ? "{$root}\\pear\\docs" : "{$root}/pear/docs");
     $config->set('test_dir', $windows ? "{$root}\\pear\\tests" : "{$root}/pear/tests");
     $config->set('cache_dir', $windows ? "{$root}\\pear\\cache" : "{$root}/pear/cache");
     $config->set('download_dir', $windows ? "{$root}\\pear\\download" : "{$root}/pear/download");
     $config->set('temp_dir', $windows ? "{$root}\\pear\\temp" : "{$root}/pear/temp");
     $config->set('bin_dir', $windows ? "{$root}\\pear" : "{$root}/pear");
     $config->writeConfigFile();
     $this->_showConfig($config);
     $this->ui->outputData('Successfully created default configuration file "' . $params[1] . '"', $command);
 }
コード例 #3
0
ファイル: ProjectRunner.php プロジェクト: pago/pantr
 private function createConfig($root, $pearConfDir)
 {
     $old = error_reporting(0);
     $windows = $this->isWindows();
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     $root = preg_replace(array('!\\\\+!', '!/+!', "!{$ds2}+!"), array('/', '/', '/'), $root);
     if ($root[0] != '/') {
         if ($windows) {
             throw new Exception('Root directory must be an absolute path beginning ' . 'with "/", was: "' . $root . '"');
         }
         if (!preg_match('/^[A-Za-z]:/', $root)) {
             throw new Exception('Root directory must be an absolute path beginning ' . 'with "\\" or "C:\\", was: "' . $root . '"');
         }
     }
     if ($windows) {
         $root = str_replace('/', '\\', $root);
     }
     if (!file_exists($pearConfDir) && !@touch($pearConfDir)) {
         throw new Exception('Could not create "' . $pearConfDir . '"');
     }
     $config = new PEAR_Config($pearConfDir, '#no#system#config#', false, false);
     if ($root[strlen($root) - 1] == '/') {
         $root = substr($root, 0, strlen($root) - 1);
     }
     $config->noRegistry();
     $config->set('php_dir', $windows ? "{$root}" : "{$root}", 'user');
     $config->set('data_dir', $windows ? "{$root}\\pear\\data" : "{$root}/data");
     $config->set('www_dir', $windows ? "{$root}\\pear\\www" : "{$root}/pear/www");
     $config->set('cfg_dir', $windows ? "{$root}\\pear\\cfg" : "{$root}/pear/cfg");
     $config->set('ext_dir', $windows ? "{$root}\\pear\\ext" : "{$root}/pear/ext");
     $config->set('doc_dir', $windows ? "{$root}\\pear\\docs" : "{$root}/pear/docs");
     $config->set('test_dir', $windows ? "{$root}\\pear\\tests" : "{$root}/pear/tests");
     $config->set('cache_dir', $windows ? "{$root}\\pear\\cache" : "{$root}/pear/cache");
     $config->set('download_dir', $windows ? "{$root}\\pear\\download" : "{$root}/pear/download");
     $config->set('temp_dir', $windows ? "{$root}\\pear\\temp" : "{$root}/pear/temp");
     $config->set('bin_dir', $windows ? "{$root}\\" : "{$root}/");
     $config->writeConfigFile();
     error_reporting($old);
     return $config;
 }
コード例 #4
0
ファイル: sfPakePlugins.php プロジェクト: taryono/school
function _pear_init()
{
    // Remove E_STRICT from error_reporting
    error_reporting(error_reporting() & ~E_STRICT);
    require_once 'PEAR.php';
    require_once 'PEAR/Frontend.php';
    require_once 'PEAR/Config.php';
    require_once 'PEAR/Registry.php';
    require_once 'PEAR/Command.php';
    require_once 'PEAR/Remote.php';
    // current symfony release
    $sf_version = preg_replace('/\\-\\w+$/', '', file_get_contents(sfConfig::get('sf_symfony_lib_dir') . '/VERSION'));
    // PEAR
    PEAR_Command::setFrontendType('CLI');
    $ui =& PEAR_Command::getFrontendObject();
    // read user/system configuration (don't use the singleton)
    $config = new PEAR_Config();
    $config_file = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '.pearrc';
    // change the configuration for symfony use
    $config->set('php_dir', sfConfig::get('sf_plugins_dir'));
    $config->set('data_dir', sfConfig::get('sf_plugins_dir'));
    $config->set('test_dir', sfConfig::get('sf_plugins_dir'));
    $config->set('doc_dir', sfConfig::get('sf_plugins_dir'));
    $config->set('bin_dir', sfConfig::get('sf_plugins_dir'));
    // change the PEAR temp dir
    $config->set('cache_dir', sfConfig::get('sf_cache_dir'));
    $config->set('download_dir', sfConfig::get('sf_cache_dir'));
    $config->set('tmp_dir', sfConfig::get('sf_cache_dir'));
    // save out configuration file
    $config->writeConfigFile($config_file, 'user');
    // use our configuration file
    $config =& PEAR_Config::singleton($config_file);
    $config->set('verbose', 1);
    $ui->setConfig($config);
    date_default_timezone_set('UTC');
    // register our channel
    $symfony_channel = array('attribs' => array('version' => '1.0', 'xmlns' => 'http://pear.php.net/channel-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://pear.php.net/dtd/channel-1.0 http://pear.php.net/dtd/channel-1.0.xsd'), 'name' => 'pear.symfony-project.com', 'summary' => 'symfony project PEAR channel', 'suggestedalias' => 'symfony', 'servers' => array('primary' => array('rest' => array('baseurl' => array(array('attribs' => array('type' => 'REST1.0'), '_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/'), array('attribs' => array('type' => 'REST1.1'), '_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/'))))), '_lastmodified' => array('ETag' => "113845-297-dc93f000", 'Last-Modified' => date('r')));
    pake_mkdirs(sfConfig::get('sf_plugins_dir') . '/.channels/.alias');
    file_put_contents(sfConfig::get('sf_plugins_dir') . '/.channels/pear.symfony-project.com.reg', serialize($symfony_channel));
    file_put_contents(sfConfig::get('sf_plugins_dir') . '/.channels/.alias/symfony.txt', 'pear.symfony-project.com');
    // register symfony for dependencies
    $symfony = array('name' => 'symfony', 'channel' => 'pear.symfony-project.com', 'date' => date('Y-m-d'), 'time' => date('H:i:s'), 'version' => array('release' => $sf_version, 'api' => '1.0.0'), 'stability' => array('release' => 'stable', 'api' => 'stable'), 'xsdversion' => '2.0', '_lastmodified' => time(), 'old' => array('version' => $sf_version, 'release_state' => 'stable'));
    $dir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '.registry' . DIRECTORY_SEPARATOR . '.channel.pear.symfony-project.com';
    pake_mkdirs($dir);
    file_put_contents($dir . DIRECTORY_SEPARATOR . 'symfony.reg', serialize($symfony));
    return $config;
}
コード例 #5
0
ファイル: Repository.php プロジェクト: pago/pantr
 public function create()
 {
     $old = error_reporting(0);
     $root = $this->root;
     $configFile = $root . '/.pearrc';
     $config = new \PEAR_Config($configFile, '#no#system#config#', false, false);
     $config->noRegistry();
     $config->set('php_dir', $root, 'user');
     $config->set('data_dir', "{$root}/pear/data");
     $config->set('www_dir', "{$root}/pear/www");
     $config->set('cfg_dir', "{$root}/pear/cfg");
     $config->set('ext_dir', "{$root}/pear/ext");
     $config->set('doc_dir', "{$root}/pear/docs");
     $config->set('test_dir', "{$root}/pear/tests");
     $config->set('cache_dir', "{$root}/pear/cache");
     $config->set('download_dir', "{$root}/pear/download");
     $config->set('temp_dir', "{$root}/pear/temp");
     $config->set('bin_dir', "{$root}/");
     $config->writeConfigFile();
     error_reporting($old);
     $this->prepare();
 }