From 5ed91c222373aa6a4c7dd64fdfbf2ff8894bc13d Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 14 Aug 2013 07:34:07 +0000 Subject: [PATCH] New verb "AfterDatabaseSetup" for performing installation tasks after the completion of the DB creation (+predefined objects & admin account) SVN:trunk[2820] --- setup/applicationinstaller.class.inc.php | 15 +++++++++++++++ setup/moduleinstaller.class.inc.php | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index 1af6a3ebe..c471a558a 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -697,6 +697,21 @@ class ApplicationInstaller SetupPage::log_info("Administrator account '$sAdminUser' created."); } } + + // Perform final setup tasks here + // + foreach($aAvailableModules as $sModuleId => $aModule) + { + if (($sModuleId != ROOT_MODULE) && in_array($sModuleId, $aSelectedModules) && + isset($aAvailableModules[$sModuleId]['installer']) ) + { + $sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer']; + SetupPage::log_info("Calling Module Handler: $sModuleInstallerClass::AfterDatabaseSetup(oConfig, {$aModule['version_db']}, {$aModule['version_code']})"); + // The validity of the sModuleInstallerClass has been established in BuildConfig() + $aCallSpec = array($sModuleInstallerClass, 'AfterDatabaseSetup'); + call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code'])); + } + } } /** diff --git a/setup/moduleinstaller.class.inc.php b/setup/moduleinstaller.class.inc.php index 94c5100d0..b18f7937b 100644 --- a/setup/moduleinstaller.class.inc.php +++ b/setup/moduleinstaller.class.inc.php @@ -54,6 +54,16 @@ abstract class ModuleInstallerAPI { } + /** + * Handler called at the end of the setup of the database (profiles and admin accounts created), but before the data load + * @param $oConfiguration Config The new configuration of the application + * @param $sPreviousVersion string PRevious version number of the module (empty string in case of first install) + * @param $sCurrentVersion string Current version number of the module + */ + public static function AfterDatabaseSetup(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion) + { + } + /** * Helper to complete the renaming of a class * The renaming is made in the datamodel definition, but the name has to be changed in the DB as well