diff --git a/.gitignore b/.gitignore index 12f83193e4..058acb17b6 100644 --- a/.gitignore +++ b/.gitignore @@ -35,8 +35,9 @@ Icon? Thumbs.db *.swp -# phpstorm +# IDE related .idea/* +.vscode/* # testing stuff tests/_output/* diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index cd5116383f..7e023979dc 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -327,9 +327,9 @@ public static function sophisticatedInstall($source_path, $install_path, $ignore } /** - * Uninstalls one or more given package + * Uninstalls one or more given packages * - * @param string $path The slug of the package(s) + * @param string $path The path of the package(s) * @param array $options Options to use for uninstalling * * @return bool True if everything went fine, False otherwise. @@ -337,8 +337,8 @@ public static function sophisticatedInstall($source_path, $install_path, $ignore public static function uninstall($path, $options = []) { $options = array_merge(self::$options, $options); - if (!self::isValidDestination($path, $options['exclude_checks']) - ) { + $config_folder_paths = false; + if (!self::isValidDestination($path, $options['exclude_checks'])) { return false; } @@ -358,7 +358,29 @@ public static function uninstall($path, $options = []) } } - $result = Folder::delete($path); + // Find corresponding config yaml file for the package. + $slug = end(explode(DS, $path)); + $grav = Grav::instance(); + $gpm = new GPM(); + $locator = Grav::instance()['locator']; + $package = $gpm->findPackage($slug); + + if ($package){ + $package_type = $package->package_type; + $config_folder_paths = $locator->findResource('config://' . $package_type . '/' . $slug . '.yaml'); + } + + if (false !== $config_folder_paths) { + $config_result = unlink($config_folder_paths); + } else { + $config_result = true; + } + + + // Delete package folder. + $folder_result = Folder::delete($path); + + $result = ($folder_result && $config_result); self::$message = ''; if ($result && $installer && method_exists($installer, 'postUninstall')) {