Bläddra i källkod

N°781 Setup: New hook available after data load (ModuleInstaller::AfterDataLoad())

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4891 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 7 år sedan
förälder
incheckning
6b686556d1
2 ändrade filer med 35 tillägg och 11 borttagningar
  1. 15 0
      setup/applicationinstaller.class.inc.php
  2. 20 11
      setup/moduleinstaller.class.inc.php

+ 15 - 0
setup/applicationinstaller.class.inc.php

@@ -953,6 +953,21 @@ class ApplicationInstaller
 	
 	    $oDataLoader->EndSession();
 	    SetupPage::log_info("ending data load session");
+
+        // Perform after dbload 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::AfterDataLoad(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
+                // The validity of the sModuleInstallerClass has been established in BuildConfig()
+                $aCallSpec = array($sModuleInstallerClass, 'AfterDataLoad');
+                call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code']));
+            }
+        }
 	}
 	
 	/**

+ 20 - 11
setup/moduleinstaller.class.inc.php

@@ -1,5 +1,5 @@
 <?php
-// Copyright (C) 2010-2012 Combodo SARL
+// Copyright (C) 2010-2017 Combodo SARL
 //
 //   This file is part of iTop.
 //
@@ -54,15 +54,25 @@ 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)
-	{	
-	}
+    /**
+     * 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)
+    {
+    }
+
+    /**
+     * Handler called at the end of 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 AfterDataLoad(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
+    {
+    }
 	
 	/**
 	 * Helper to complete the renaming of a class
@@ -215,4 +225,3 @@ abstract class ModuleInstallerAPI
 	}
 
 }
-?>