Clean up directory on module uninstall
This commit is contained in:
@@ -3334,6 +3334,9 @@ abstract class ModuleCore
|
||||
|
||||
if (!isset($toDelete) || $toDelete) {
|
||||
unlink($overrideClassFilePath);
|
||||
if ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE_CONTROLLER) {
|
||||
$this->cleanModulesOverrideDir($overrideClassFilePath);
|
||||
}
|
||||
} else {
|
||||
file_put_contents($overrideClassFilePath, $code);
|
||||
}
|
||||
@@ -3344,6 +3347,21 @@ abstract class ModuleCore
|
||||
return true;
|
||||
}
|
||||
|
||||
private function cleanModulesOverrideDir($dir)
|
||||
{
|
||||
if (rtrim($dir, '/') == _PS_ROOT_DIR_.'/override/modules') {
|
||||
return;
|
||||
}
|
||||
|
||||
$files = Tools::scandir($dir, '');
|
||||
$diffResult = array_diff($files, array('.', '..', 'index.php'));
|
||||
|
||||
if (!count($diffResult)) {
|
||||
Tools::deleteDirectory($dir);
|
||||
$this->cleanModulesOverrideDir(dirname($dir));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hooks list where this module can be hooked.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user