]> granicus.if.org Git - php/commitdiff
Added checkPackageUninstall()
authorTomas V.V.Cox <cox@php.net>
Tue, 8 Jul 2003 10:32:23 +0000 (10:32 +0000)
committerTomas V.V.Cox <cox@php.net>
Tue, 8 Jul 2003 10:32:23 +0000 (10:32 +0000)
pear/PEAR/Dependency.php

index b9c70ef3189e5a72199e0a1269ad33ef0232ae96..c4c27605043107e984f58dd3cdb8b782ebdde7f5 100644 (file)
@@ -146,6 +146,35 @@ class PEAR_Dependency
         return PEAR_DEPENDENCY_BAD_DEPENDENCY;
     }
 
+    /**
+     * Check package dependencies on uninstall
+     *
+     * @param string $error     The resultant error string
+     * @param string $name      Name of the package to test
+     *
+     * @return bool true if there were errors
+     */
+    function checkPackageUninstall(&$error, $package)
+    {
+        $error = null;
+        $packages = $this->registry->listPackages();
+        foreach ($packages as $pkg) {
+            if ($pkg == $package) {
+                continue;
+            }
+            $deps = $this->registry->packageInfo($pkg, 'release_deps');
+            if (empty($deps)) {
+                continue;
+            }
+            foreach ($deps as $dep) {
+                if ($dep['type'] == 'pkg' && strcasecmp($dep['name'], $package) == 0) {
+                    $error .= "Package '$pkg' depends on '$package'\n";
+                }
+            }
+        }
+        return ($error) ? true : false;
+    }
+
     /**
      * Extension dependencies check method
      *