Skip to content

Commit

Permalink
Updated Generic module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Jul 24, 2023
1 parent bf14347 commit 5265736
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/Generic/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ public function uninstall(ServiceLocatorInterface $services): void
$this->preUninstall();
$this->execSqlFromFile($this->modulePath() . '/data/install/uninstall.sql');
$this
->manageConfig('uninstall')
->manageMainSettings('uninstall')
->manageSiteSettings('uninstall')
// Don't uninstall user settings, they don't belong to admin.
// ->manageUserSettings('uninstall')
->manageSiteSettings('uninstall')
->manageMainSettings('uninstall')
->manageConfig('uninstall')
// ->uninstallAllResources()
->postUninstall();
}

Expand Down Expand Up @@ -186,6 +187,22 @@ public function installAllResources(): AbstractModule
return $this;
}

/**
* @return self
*/
public function uninstallAllResources(): AbstractModule
{
$installResources = $this->getInstallResources();
if (!$installResources
|| !method_exists($installResources, 'deleteAllResources')
) {
// Nothing to install.
return $this;
}
$installResources->deleteAllResources(static::NAMESPACE);
return $this;
}

public function checkAddonVersions(Event $event): void
{
global $globalCheckAddonVersions;
Expand Down Expand Up @@ -307,6 +324,12 @@ protected function preInstall(): void

protected function postInstall(): void
{
$services = $this->getServiceLocator();
$filepath = $this->modulePath() . '/data/scripts/install.php';
if (file_exists($filepath) && filesize($filepath) && is_readable($filepath)) {
$this->setServiceLocator($services);
require_once $filepath;
}
}

protected function preUninstall(): void
Expand All @@ -315,6 +338,12 @@ protected function preUninstall(): void

protected function postUninstall(): void
{
$services = $this->getServiceLocator();
$filepath = $this->modulePath() . '/data/scripts/uninstall.php';
if (file_exists($filepath) && filesize($filepath) && is_readable($filepath)) {
$this->setServiceLocator($services);
require_once $filepath;
}
}

/**
Expand Down

0 comments on commit 5265736

Please sign in to comment.