[openads-Commits] r17954 - in branches/6.6.0-develop: . obj tests

0 views
Skip to first unread message

ejpri...@users.adullact.net

unread,
Jun 18, 2024, 2:53:18 AM (9 days ago) Jun 18
to openmairi...@googlegroups.com
Author: ejpritchard
Date: 2024-06-18 08:53:15 +0200 (Tue, 18 Jun 2024)
New Revision: 17954

Added:
branches/6.6.0-develop/deploy/
Modified:
branches/6.6.0-develop/
branches/6.6.0-develop/obj/
branches/6.6.0-develop/obj/module_manager.class.php
branches/6.6.0-develop/tests/
Log:
merge (branch) : 6.6.0-develop-10431-ScriptInstallationModules to 6.6.0-develop : Ajout des methodes d'installation des modules

Index: branches/6.6.0-develop
===================================================================
--- branches/6.6.0-develop 2024-06-18 06:45:14 UTC (rev 17953)
+++ branches/6.6.0-develop 2024-06-18 06:53:15 UTC (rev 17954)

Property changes on: branches/6.6.0-develop
___________________________________________________________________
Modified: svn:mergeinfo
## -719,6 +719,7 ##
/branches/6.6.0-develop-10424-AjoutHooksInstruction:17818-17859
/branches/6.6.0-develop-10427-AjoutGetObjectName:17878-17886
/branches/6.6.0-develop-10428-ModuleAnnexes:17883-17913
+/branches/6.6.0-develop-10431-ScriptInstallationModules:17909-17953
/branches/6.6.0-develop-bug-user-with-space:17809-17837
/branches/6.6.0-develop-documentation-document_type:17801-17845
/branches/6.6.0-develop-integration-type_documents:17635-17756
Index: branches/6.6.0-develop/obj
===================================================================
--- branches/6.6.0-develop/obj 2024-06-18 06:45:14 UTC (rev 17953)
+++ branches/6.6.0-develop/obj 2024-06-18 06:53:15 UTC (rev 17954)

Property changes on: branches/6.6.0-develop/obj
___________________________________________________________________
Modified: svn:mergeinfo
## -678,6 +678,7 ##
/branches/6.6.0-develop-10424-AjoutHooksInstruction/obj:17818-17859
/branches/6.6.0-develop-10427-AjoutGetObjectName/obj:17878-17886
/branches/6.6.0-develop-10428-ModuleAnnexes/obj:17883-17913
+/branches/6.6.0-develop-10431-ScriptInstallationModules/obj:17909-17953
/branches/6.6.0-develop-bug-user-with-space/obj:17809-17837
/branches/6.6.0-develop-documentation-document_type/obj:17801-17845
/branches/6.6.0-develop-integration-type_documents/obj:17635-17756
Modified: branches/6.6.0-develop/obj/module_manager.class.php
===================================================================
--- branches/6.6.0-develop/obj/module_manager.class.php 2024-06-18 06:45:14 UTC (rev 17953)
+++ branches/6.6.0-develop/obj/module_manager.class.php 2024-06-18 06:53:15 UTC (rev 17954)
@@ -97,6 +97,86 @@
}

/**
+ * Fonction incluant le fichier du module qu'il soit dans son propre sous dossier ou dans le dossier module
+ *
+ * @param string $module_name : nom du module à inclure
+ * @param string $module_dir : nom du dossier du module à inclure
+ *
+ */
+ protected function require_once_module($module_name, $module_dir) {
+ $module_script = "$module_dir/$module_name.php";
+ $module_folder_script = "$module_dir/$module_name/$module_name.php";
+ if (file_exists($module_script)) {
+ require_once $module_script;
+ } else if (file_exists($module_folder_script)) {
+ require_once $module_folder_script;
+ } else {
+ throw new RuntimeException("File named $module_name.php unfound ! ");
+ }
+ }
+
+ /**
+ * Fonction qui instancie le module nommée
+ *
+ * @param string $module_name : nom du module à instancier
+ * @param lien_module $wf_module_link Instance de lien module
+ * @param mixed $object Un objet métier à associer au module
+ *
+ * @return object : Instance du module
+ */
+ public function get_module_instance($module_name, lien_module $wf_module_link = null, $object = null) {
+ $module_dir = $this->get_modules_dir();
+ $this->require_once_module($module_name, $module_dir);
+ $module_name_camel = str_replace(' ', '', ucfirst(preg_replace('/[^a-zA-Z0-9]/', ' ', $module_name)));
+ $module_namespace = "Module\\$module_name_camel";
+ $module_class_path = $module_namespace.'\\'.$module_name;
+ $module_instance = new $module_class_path($module_dir, $this->framework, $wf_module_link, $object );
+ return $module_instance;
+ }
+
+ /**
+ * Fonction permettant de recuperer un module nommée et de lancer ses fonctions d'installations
+ *
+ * @param string $module_name : nom du module à instancier
+ *
+ * @return boolean : True ou False
+ */
+ public function install_modules($module_names) {
+ foreach ($module_names as $module_name){
+ try {
+ $module_instance = $this->get_module_instance($module_name);
+ $module_instance->install();
+ } catch (RuntimeException $re) {
+ $this->log(__METHOD__, " RuntimeException: $module_name => $re");
+ file_put_contents(STDERR, " RuntimeException: $module_name => $re", FILE_APPEND );
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Fonction permettant de recuperer un module nommée et de lancer ses fonctions d'installations
+ *
+ * @param string $module_name : nom du module à instancier
+ *
+ * @return boolean : True ou False
+ */
+ public function uninstall_modules($module_names) {
+ foreach ($module_names as $module_name){
+ try {
+ $module_instance = $this->get_module_instance($module_name);
+ $module_instance->uninstall();
+ } catch (RuntimeException $re) {
+ $this->log(__METHOD__, " RuntimeException: $module_name => $re");
+ file_put_contents(STDERR, " RuntimeException: $module_name => $re", FILE_APPEND );
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Charge la configuration dynamique des modules (si pas déjà fait), spécifiquement:
* - défini '$this->all_available_hooks' à partir de '$hooks'
* - défini '$this->enabled_for' à partir de '$modules_enabled_for'

Index: branches/6.6.0-develop/tests
===================================================================
--- branches/6.6.0-develop/tests 2024-06-18 06:45:14 UTC (rev 17953)
+++ branches/6.6.0-develop/tests 2024-06-18 06:53:15 UTC (rev 17954)

Property changes on: branches/6.6.0-develop/tests
___________________________________________________________________
Modified: svn:mergeinfo
## -671,6 +671,7 ##
/branches/6.6.0-develop-10420-ModuleCalculDeclencheur/tests:17803-17804
/branches/6.6.0-develop-10424-AjoutHooksInstruction/tests:17818-17859
/branches/6.6.0-develop-10428-ModuleAnnexes/tests:17883-17913
+/branches/6.6.0-develop-10431-ScriptInstallationModules/tests:17909-17953
/branches/6.6.0-develop-bug-user-with-space/tests:17809-17837
/branches/6.6.0-develop-documentation-document_type/tests:17801-17845
/branches/6.6.0-develop-integration-type_documents/tests:17635-17756
Reply all
Reply to author
Forward
0 new messages