mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Initial work to remove config when plugin/ theme is uninstalled
This commit is contained in:
parent
feeee9ef86
commit
b3e188e3de
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -35,8 +35,9 @@ Icon?
|
|||
Thumbs.db
|
||||
*.swp
|
||||
|
||||
# phpstorm
|
||||
# IDE related
|
||||
.idea/*
|
||||
.vscode/*
|
||||
|
||||
# testing stuff
|
||||
tests/_output/*
|
||||
|
|
|
|||
|
|
@ -327,9 +327,9 @@ class Installer
|
|||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class Installer
|
|||
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 @@ class Installer
|
|||
}
|
||||
}
|
||||
|
||||
$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')) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user