本文整理汇总了PHP中PEAR_Config::setRegistry方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Config::setRegistry方法的具体用法?PHP PEAR_Config::setRegistry怎么用?PHP PEAR_Config::setRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Config
的用法示例。
在下文中一共展示了PEAR_Config::setRegistry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Private constructor to initialize the instance
* with the necessary data.
*
* @param string $baseDir The Magento base directory
* @return void
*/
public function __construct($baseDir)
{
// check if the passed Magento base directory exists
if (!is_dir($baseDir)) {
throw new Exception('Magento base directory ' . $baseDir . ' doesn\'t exists');
}
// load the PEAR directory for the Magento channel
$pearDir = $baseDir . DS . 'downloader' . DS . 'pearlib';
// check if the Magento PEAR directory exists
if (!is_dir($pearDir)) {
throw new Exception('Magento PEAR base directory ' . $pearDir . ' doesn\'t exists');
}
// load the registry
$this->_registry = new PEAR_Registry($pearDir . DS . 'php');
// initialize the configuration with the channels configuration file
$this->_config = PEAR_Config::singleton($pearDir . DS . 'pear.ini', '-');
// overwrite the configuration values
$this->_config->set('auto_discover', 1);
$this->_config->set('cache_ttl', 60);
$this->_config->set('preferred_state', 'alpha');
$this->_config->set('bin_dir', $pearDir);
$this->_config->set('php_dir', $pearDir . DS . 'php');
$this->_config->set('download_dir', $pearDir . DS . 'download');
$this->_config->set('temp_dir', $pearDir . DS . 'temp');
$this->_config->set('data_dir', $pearDir . DS . 'data');
$this->_config->set('cache_dir', $pearDir . DS . 'cache');
$this->_config->set('test_dir', $pearDir . DS . 'tests');
$this->_config->set('doc_dir', $pearDir . DS . 'docs');
// initialize the Magento specific settings
foreach ($this->_config->getKeys() as $key) {
if (!(substr($key, 0, 5) === 'mage_' && substr($key, -4) === '_dir')) {
continue;
}
$this->_config->set($key, preg_replace('#^\\.#', addslashes(Mage::getBaseDir()), $this->_config->get($key)));
}
// set the registry
$this->_config->setRegistry($this->_registry);
// initialize the dependeny database
PEAR_DependencyDB::singleton($this->_config, $pearDir . DS . 'php' . DS . '.depdb');
// register the commands, including the one for Magento
PEAR_Command::registerCommands(true, $pearDir . DS . 'php' . DS . 'PEAR' . DS . 'Command' . DS);
// initialize the PEAR frontend
PEAR_Frontend::setFrontendClass('Faett_Core_Frontend_PEAR');
$this->_ui = PEAR_Command::getFrontendObject();
$this->_ui->setConfig($this->_config);
// set the callback for rendering the messages
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this->_ui, "log"));
}
示例2: exit
function _initializeDepDB()
{
if (!isset($this->_dependencyDB)) {
static $initializing = false;
if (!$initializing) {
$initializing = true;
if (!$this->_config) {
// never used?
$file = OS_WINDOWS ? 'pear.ini' : '.pearrc';
$this->_config =& new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR . $file);
$this->_config->setRegistry($this);
$this->_config->set('php_dir', $this->install_dir);
}
$this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
// attempt to recover by removing the dep db
if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb')) {
@unlink($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb');
}
$this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
echo $this->_dependencyDB->getMessage();
echo 'Unrecoverable error';
exit(1);
}
}
$initializing = false;
}
}
}