From 0304ec19ff878a46f97f13b544a19e16d797ac70 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Tue, 8 Jul 2003 10:32:23 +0000 Subject: [PATCH] Added checkPackageUninstall() --- pear/PEAR/Dependency.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php index b9c70ef318..c4c2760504 100644 --- a/pear/PEAR/Dependency.php +++ b/pear/PEAR/Dependency.php @@ -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 * -- 2.50.1