From f32a33ae6d50eb69e674554b8677dbec87176b8b Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 23 Mar 2020 00:00:00 +0100 Subject: [PATCH] Updated Generic module. --- src/Generic/AbstractModule.php | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/Generic/AbstractModule.php b/src/Generic/AbstractModule.php index 4bbc939..414d2d4 100644 --- a/src/Generic/AbstractModule.php +++ b/src/Generic/AbstractModule.php @@ -62,7 +62,9 @@ public function install(ServiceLocatorInterface $serviceLocator) $this->preInstall(); $this->checkDependency(); $this->checkDependencies(); + $this->checkAllResourcesToInstall(); $this->execSqlFromFile($this->modulePath() . '/data/install/schema.sql'); + $this->installAllResources(); $this->manageConfig('install'); $this->manageMainSettings('install'); $this->manageSiteSettings('install'); @@ -92,6 +94,48 @@ public function upgrade($oldVersion, $newVersion, ServiceLocatorInterface $servi } } + /** + * @throws \Omeka\Module\Exception\ModuleCannotInstallException + */ + public function checkAllResourcesToInstall() + { + if (!class_exists(\Generic\InstallResources::class)) { + if (file_exists(dirname(dirname(dirname(__DIR__))) . '/Generic/InstallResources.php')) { + require_once dirname(dirname(dirname(__DIR__))) . '/Generic/InstallResources.php'; + } elseif (file_exists(__DIR__ . '/InstallResources.php')) { + require_once __DIR__ . '/InstallResources.php'; + } else { + // Nothing to install. + return true; + } + } + + $services = $this->getServiceLocator(); + $installResources = new \Generic\InstallResources($services); + $installResources->checkAllResources(static::NAMESPACE); + } + + /** + * @throws \Omeka\Module\Exception\ModuleCannotInstallException + */ + public function installAllResources() + { + if (!class_exists(\Generic\InstallResources::class)) { + if (file_exists(dirname(dirname(dirname(__DIR__))) . '/Generic/InstallResources.php')) { + require_once dirname(dirname(dirname(__DIR__))) . '/Generic/InstallResources.php'; + } elseif (file_exists(__DIR__ . '/InstallResources.php')) { + require_once __DIR__ . '/InstallResources.php'; + } else { + // Nothing to install. + return true; + } + } + + $services = $this->getServiceLocator(); + $installResources = new \Generic\InstallResources($services); + $installResources->createAllResources(static::NAMESPACE); + } + public function getConfigForm(PhpRenderer $renderer) { $services = $this->getServiceLocator();