Skip to content

Commit

Permalink
Updated Generic module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Mar 22, 2020
1 parent 622e466 commit f32a33a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Generic/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f32a33a

Please sign in to comment.