diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:51:28 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:51:28 +0100 |
commit | 57efd9a7ae27b2f0bd98382a1f6b107064585f99 (patch) | |
tree | 32b8fb2f2e2c50a5d625698248e605862333267f /ratatoeskr/sys/models.php | |
parent | 32b8f4ae4243bc915fe38e28dd991a28c09b4331 (diff) | |
download | ratatoeskr-cms-57efd9a7ae27b2f0bd98382a1f6b107064585f99.tar.gz ratatoeskr-cms-57efd9a7ae27b2f0bd98382a1f6b107064585f99.tar.bz2 ratatoeskr-cms-57efd9a7ae27b2f0bd98382a1f6b107064585f99.zip |
Move delete_directory() into Plugin class
It was the only place it was used
Diffstat (limited to 'ratatoeskr/sys/models.php')
-rw-r--r-- | ratatoeskr/sys/models.php | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index 613334f..d2ed544 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -1590,6 +1590,29 @@ class Plugin ); } + /** + * Delete a directory and all of its content. + * @param string $dir + */ + private static function delete_directory(string $dir): void + { + $dir_content = scandir($dir); + foreach ($dir_content as $f) { + if (($f == "..") or ($f == ".")) { + continue; + } + + $f = "$dir/$f"; + + if (is_dir($f)) { + self::delete_directory($f); + } else { + unlink($f); + } + } + rmdir($dir); + } + public function delete(?Database $db = null): void { $db = $db ?? Env::getGlobal()->database(); @@ -1606,13 +1629,13 @@ class Plugin } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/private/" . $this->id); } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/plugin_extradata/public/" . $this->id); } if (is_dir(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id)) { - delete_directory(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id); + self::delete_directory(SITE_BASE_PATH . "/ratatoeskr/templates/src/plugintemplates/" . $this->id); } } } |