public function onAfterDelete()
{
parent::onAfterDelete();
$environments = $this->Environments();
if ($environments && $environments->exists()) {
foreach ($environments as $env) {
$env->delete();
}
}
$fetches = $this->Fetches();
if ($fetches && $fetches->exists()) {
foreach ($fetches as $fetch) {
$fetch->delete();
}
}
// Delete local repository
if (file_exists($this->getLocalCVSPath())) {
Filesystem::removeFolder($this->getLocalCVSPath());
}
// Delete project template
if (file_exists($this->getProjectFolderPath()) && Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
Filesystem::removeFolder($this->getProjectFolderPath());
}
// Delete the deploy key
if (file_exists($this->getKeyDir())) {
Filesystem::removeFolder($this->getKeyDir());
}
}