]> granicus.if.org Git - php/commitdiff
- The config object is stored by the factory method
authorTomas V.V.Cox <cox@php.net>
Thu, 21 Mar 2002 11:10:17 +0000 (11:10 +0000)
committerTomas V.V.Cox <cox@php.net>
Thu, 21 Mar 2002 11:10:17 +0000 (11:10 +0000)
- Make install/unistall/package work again (didn't work for me)

pear/PEAR/Command.php
pear/PEAR/Command/Common.php
pear/PEAR/Command/Install.php
pear/PEAR/Command/Package.php

index d7944c677708421ad0f4a6bad1352b19dbce1109..46c3d232995d25e76e98f0d9dd786477afaa9e36 100644 (file)
@@ -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'");
index 0fc50f4aaf6da3ae04b23eb735767fb5d6c58de6..8883b5eb5736c42dc34fb2abdf63a5855e9492c4 100644 (file)
@@ -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;
     }
 
index 658f4a7b29838ec83935426d810b34db712c70d9..a2131ebce3784877d1c8827fad0bfb5213743d4f 100644 (file)
@@ -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;
             }
index f7a400f2bc405a60b47bbda1754b44d93222dc70..03b118c5e4c111cec65912fc2fb69b23a832db18 100644 (file)
@@ -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) {