From: Tomas V.V.Cox Date: Thu, 21 Mar 2002 11:10:17 +0000 (+0000) Subject: - The config object is stored by the factory method X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~1166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47c71bcaa1340e1c6360bede32a75c4363352ecf;p=php - The config object is stored by the factory method - Make install/unistall/package work again (didn't work for me) --- diff --git a/pear/PEAR/Command.php b/pear/PEAR/Command.php index d7944c6777..46c3d23299 100644 --- a/pear/PEAR/Command.php +++ b/pear/PEAR/Command.php @@ -88,14 +88,14 @@ class PEAR_Command * * @access public */ - function factory($command) + function factory($command, &$config) { if (empty($GLOBALS['_PEAR_Command_commandlist'])) { PEAR_Command::registerCommands(); } if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) { $class = $GLOBALS['_PEAR_Command_commandlist'][$command]; - $obj = &new $class(PEAR_Command::getUIObject()); + $obj = &new $class(PEAR_Command::getUIObject(), $config); return $obj; } return PEAR::raiseError("unknown command `$command'"); diff --git a/pear/PEAR/Command/Common.php b/pear/PEAR/Command/Common.php index 0fc50f4aaf..8883b5eb57 100644 --- a/pear/PEAR/Command/Common.php +++ b/pear/PEAR/Command/Common.php @@ -42,10 +42,10 @@ class PEAR_Command_Common extends PEAR * * @access public */ - function PEAR_Command_Common(&$ui) + function PEAR_Command_Common(&$ui, &$config) { parent::PEAR(); - $this->config = &PEAR_Config::singleton(); + $this->config =& $config; $this->ui = $ui; } diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index 658f4a7b29..a2131ebce3 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -29,17 +29,6 @@ require_once "PEAR/Installer.php"; class PEAR_Command_Install extends PEAR_Command_Common { // {{{ properties - - /** Stack of executing commands, to make run() re-entrant - * @var array - */ - var $command_stack; // XXX UNUSED to make run() re-entrant - - /** Currently executing command. - * @var string - */ - var $command; // XXX UNUSED - // }}} // {{{ constructor @@ -49,9 +38,9 @@ class PEAR_Command_Install extends PEAR_Command_Common * * @access public */ - function PEAR_Command_Install($ui) + function PEAR_Command_Install(&$ui, &$config) { - parent::PEAR_Command_Common($ui); + parent::PEAR_Command_Common($ui, $config); } // }}} @@ -71,19 +60,21 @@ class PEAR_Command_Install extends PEAR_Command_Common // }}} // {{{ run() - function run($command, $options, $params) + function run($command, $params) { - $installer =& new PEAR_Installer($options['php_dir'], - $options['ext_dir'], - $options['doc_dir']); - $installer->debug = @$options['verbose']; + $installer =& new PEAR_Installer($this->config->get('php_dir'), + $this->config->get('ext_dir'), + $this->config->get('doc_dir')); + $installer->debug = $this->config->get('verbose'); $failmsg = ''; + $options = array(); switch ($command) { case 'install': case 'upgrade': { if ($command == 'upgrade') { $options['upgrade'] = true; } + // The ['force'] and ['nodeps'] options are still missing if ($installer->install($params[0], $options, $this->config)) { $this->ui->displayLine("install ok"); } else { @@ -92,13 +83,13 @@ class PEAR_Command_Install extends PEAR_Command_Common break; } case 'uninstall': { - if ($installer->uninstall($params[0], $uninstall_options)) { + if ($installer->uninstall($params[0], $options)) { $this->ui->displayLine("uninstall ok"); } else { $failmsg = "uninstall failed"; } break; - } + } default: { return false; } diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php index f7a400f2bc..03b118c5e4 100644 --- a/pear/PEAR/Command/Package.php +++ b/pear/PEAR/Command/Package.php @@ -12,9 +12,9 @@ class PEAR_Command_Package extends PEAR_Command_Common * * @access public */ - function PEAR_Command_Package(&$ui) + function PEAR_Command_Package(&$ui, &$config) { - parent::PEAR_Command_Common($ui); + parent::PEAR_Command_Common($ui, $config); } // }}} @@ -48,7 +48,7 @@ class PEAR_Command_Package extends PEAR_Command_Common * * @access public */ - function run($command, $options, $params) + function run($command, $params) { $failmsg = ''; switch ($command) {