From fcdae77b6b085d614fa4a42b0cb2fa0d47f0e0e9 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 3 Dec 2024 09:56:24 +0100
Subject: [PATCH] rollout plugins: handle name and id

---
 .../deployment/classes/rollout_base.class.php     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/public_html/deployment/classes/rollout_base.class.php b/public_html/deployment/classes/rollout_base.class.php
index fde10537..f9369b8b 100644
--- a/public_html/deployment/classes/rollout_base.class.php
+++ b/public_html/deployment/classes/rollout_base.class.php
@@ -17,6 +17,13 @@ class rollout_base implements iRolloutplugin
     // ---------------------------------------------------------------
     // VARIABLES
     // ---------------------------------------------------------------
+
+    /**
+     * Plugin name
+     * @var string
+     */
+    protected string $_sPluginName = 'UNSET';
+
     /**
      * identifier for current plugin; it us used to find the current plugin
      * settings in the config structore for global and project based config
@@ -82,6 +89,7 @@ class rollout_base implements iRolloutplugin
      * Constructor
      * initialize rollout plugin
      * @param array $aParams  hash with those possible keys
+     *                  id           string   rollout plugin id in project config
      *                  lang         string   language, i.e. 'de'
      *                  phase        string   name of phase in a project
      *                  globalcfg    array    given global config $aConfig
@@ -94,7 +102,8 @@ class rollout_base implements iRolloutplugin
 
         // set current plugin id - taken from plugin directory name above
         $oReflection = new ReflectionClass($this);
-        $this->_sPluginId = basename(dirname($oReflection->getFileName()));
+        $this->_sPluginName = basename(dirname($oReflection->getFileName()));
+        $this->_sPluginId = $aParams['id'] ?? 'UNSET';
 
         // ----- init language
         if (isset($aParams['lang'])) {
@@ -244,7 +253,7 @@ class rollout_base implements iRolloutplugin
                     (isset($aVarinfos['ttl']) ? $aVarinfos['ttl'] : 60)
                 );
                 if (!$aCallbackData) {
-                    $aVarinfos['type'] = 'text';
+                    $aVarinfos['type'] = $aVarinfos['type'] ?? 'text';
                 } else {
                     $aEffectiveConfig = $this->getConfig($sPhase);
                     // echo $sKey.' ... '; print_r($aEffectiveConfig[$sVarname]); echo '<br>';
@@ -524,7 +533,7 @@ class rollout_base implements iRolloutplugin
     public function getDeployCommands(string $sPhase, bool $bMask = false): array
     {
         return [
-            'echo "ERROR: The method getDeployCommamds($sPhase) was not implemented in the rollout plugin [' . $this->getId() . ']"',
+            'echo "ERROR: The method getDeployCommamds($sPhase) was not implemented in the rollout plugin [' . $this->_sPluginName . ']"',
             'exit 1'
         ];
     }
-- 
GitLab