/** * setup PEAR_Config and so on. * * @param string $target whether 'master' or 'local' * @param string|null $app_dir local application directory. * @param string|null $channel channel for the package repository. * @return true|Ethna_Error */ public function init($target, $app_dir = null, $channel = null) { $true = true; if ($target == 'master') { $this->target = 'master'; } else { // default target is 'local'. $this->target = 'local'; } // setup PEAR_Frontend PEAR_Command::setFrontendType('CLI'); $this->ui = PEAR_Command::getFrontendObject(); // set PEAR's error handling // TODO: if PEAR/Command/Install.php is newer than 1.117, displayError goes well. PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this->ui, 'displayFatalError')); // set channel $master_setting = Ethna_Handle::getMasterSetting('repositry'); if ($channel !== null) { $this->channel = $channel; } else { if (isset($master_setting["channel_{$target}"])) { $this->channel = $master_setting["channel_{$target}"]; } else { $this->channel = 'pear.ethna.jp'; } } // set target controller if ($target == 'master') { $this->target_ctl = Ethna_Handle::getEthnaController(); } else { $this->target_ctl = Ethna_Handle::getAppController($app_dir); } if (Ethna::isError($this->target_ctl)) { return $this->target_ctl; } // setup PEAR_Config if ($target == 'master') { $ret = $this->_setMasterConfig(); } else { $ret = $this->_setLocalConfig(); } if (Ethna::isError($ret)) { return $ret; } $this->ui->setConfig($this->config); // setup PEAR_Registry $this->registry = $this->config->getRegistry(); return $true; }