Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
78b4f912
Commit
78b4f912
authored
10 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
rollout base class: php8 only; added variable types; short array syntax
parent
adb605ca
Branches
Branches containing commit
No related tags found
1 merge request
!66
php8 only; added variable types; short array syntax; remove glyphicons
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/deployment/classes/build_base.class.php
+4
-1
4 additions, 1 deletion
public_html/deployment/classes/build_base.class.php
public_html/deployment/classes/rollout_base.class.php
+131
-76
131 additions, 76 deletions
public_html/deployment/classes/rollout_base.class.php
with
135 additions
and
77 deletions
public_html/deployment/classes/build_base.class.php
+
4
−
1
View file @
78b4f912
...
@@ -54,6 +54,7 @@ class build_base implements iBuildplugin
...
@@ -54,6 +54,7 @@ class build_base implements iBuildplugin
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
* Constructor
* Initialize build plugin
* Initialize build plugin
* @param array $aParams hash with those possible keys
* @param array $aParams hash with those possible keys
* lang string language, i.e. 'de'
* lang string language, i.e. 'de'
...
@@ -154,7 +155,9 @@ class build_base implements iBuildplugin
...
@@ -154,7 +155,9 @@ class build_base implements iBuildplugin
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
* Check requirements if the plugin could work
* Get an array with shell commands to check requirements if the plugin
* can work
*
* @return array
* @return array
*/
*/
public
function
checkRequirements
():
array
public
function
checkRequirements
():
array
...
...
This diff is collapsed.
Click to expand it.
public_html/deployment/classes/rollout_base.class.php
+
131
−
76
View file @
78b4f912
...
@@ -7,6 +7,9 @@ require_once __DIR__ . '/../../vendor/axelhahn/ahcache/cache.class.php';
...
@@ -7,6 +7,9 @@ require_once __DIR__ . '/../../vendor/axelhahn/ahcache/cache.class.php';
* see deployment/plugins/rollout/*
* see deployment/plugins/rollout/*
*
*
* @author axel
* @author axel
*
* Axel <axel.hahn@unibe.ch>
* 2024-08-29 Axel php8 only; added variable types; short array syntax
*/
*/
class
rollout_base
implements
iRolloutplugin
class
rollout_base
implements
iRolloutplugin
{
{
...
@@ -19,58 +22,64 @@ class rollout_base implements iRolloutplugin
...
@@ -19,58 +22,64 @@ class rollout_base implements iRolloutplugin
* settings in the config structore for global and project based config
* settings in the config structore for global and project based config
* @var string
* @var string
*/
*/
protected
$_sPluginId
=
'UNSET'
;
protected
string
$_sPluginId
=
'UNSET'
;
/**
/**
*
d
ata with plugin infos (read from info.json)
*
D
ata with plugin infos (read from info.json)
* @var array
* @var array
*/
*/
protected
$_aPlugininfos
=
false
;
protected
array
$_aPlugininfos
=
[]
;
/**
/**
*
a
rray with translation texts
*
A
rray with translation texts
* @var array
* @var array
*/
*/
protected
$_aLang
=
[];
protected
array
$_aLang
=
[];
/**
/**
* set language; 2 letter code, i.e. "de"; default language is "en" ; a
* set language; 2 letter code, i.e. "de"; default language is "en" ; a
* file "lang_en.json" is required in the plugin dir
* file "lang_en.json" is required in the plugin dir
* @var string
* @var string
*/
*/
protected
$_sFallbackLang
=
'en-en'
;
protected
string
$_sFallbackLang
=
'en-en'
;
/**
/**
* set language; 2 letter code, i.e. "de"; default language is "en" ; a
* set language; 2 letter code, i.e. "de"; default language is "en" ; a
* file "lang_en.json" is required in the plugin dir
* file "lang_en.json" is required in the plugin dir
* @var string
* @var string
*/
*/
protected
$_sLang
=
'en-en'
;
protected
string
$_sLang
=
'en-en'
;
/**
/**
* string with phase of project; one of preview|stage|live
* string with phase of project; one of preview|stage|live
* @var string
* @var string
*/
*/
protected
$_sPhase
=
false
;
protected
string
$_sPhase
=
''
;
/**
/**
* global configuration of the rollout plugin
* global configuration of the rollout plugin
* @var array
* @var array
*/
*/
protected
$_aCfgGlobal
=
false
;
protected
array
$_aCfgGlobal
=
[];
/**
/**
* configuration of the project
* configuration of the project
* @var array
* @var array
*/
*/
protected
$_aCfgProject
=
false
;
protected
array
$_aCfgProject
=
[]
;
protected
$_sNamePrefix4Project
=
false
;
// set in constructor
/*
protected
$_sNamePrefix4Phase
=
false
;
// set in constructor
UNUSED
protected string $_sNamePrefix4Project = ''; // set in constructor
protected string $_sNamePrefix4Phase = ''; // set in constructor
*/
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// CONSTRUCTOR
// CONSTRUCTOR
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
* Constructor
* initialize rollout plugin
* initialize rollout plugin
* @param array $aParams hash with those possible keys
* @param array $aParams hash with those possible keys
* lang string language, i.e. 'de'
* lang string language, i.e. 'de'
...
@@ -114,13 +123,13 @@ class rollout_base implements iRolloutplugin
...
@@ -114,13 +123,13 @@ class rollout_base implements iRolloutplugin
// ---------------------------------------------------------------
// ---------------------------------------------------------------
/**
/**
*
g
et a string for a prefix for name attribute in form vars.
*
G
et a string for a prefix for name attribute in form vars.
* It is important to store the value in the wanted structure.
* It is important to store the value in the wanted structure.
*
*
* @param string $sPhase
* @param string $sPhase
* @return string
* @return string
*/
*/
protected
function
_getNamePrefix
(
$sPhase
=
false
)
protected
function
_getNamePrefix
(
string
$sPhase
=
''
):
string
{
{
return
(
$sPhase
return
(
$sPhase
?
'phases['
.
$sPhase
.
'][plugins][rollout]['
.
$this
->
getId
()
.
']'
?
'phases['
.
$sPhase
.
'][plugins][rollout]['
.
$this
->
getId
()
.
']'
...
@@ -129,7 +138,7 @@ class rollout_base implements iRolloutplugin
...
@@ -129,7 +138,7 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
*
g
et Data from a callback function and store it in a cache
*
G
et Data from a callback function and store it in a cache
* The response type depends on the callback function
* The response type depends on the callback function
*
*
* @param string $sFunctionname name of the callback function
* @param string $sFunctionname name of the callback function
...
@@ -138,11 +147,11 @@ class rollout_base implements iRolloutplugin
...
@@ -138,11 +147,11 @@ class rollout_base implements iRolloutplugin
* @param integer $iTtlOnError ttl value = how many seconds to use cache if there was no response
* @param integer $iTtlOnError ttl value = how many seconds to use cache if there was no response
* @return mixed
* @return mixed
*/
*/
protected
function
_getCallback
(
$sFunctionname
,
$sKey
,
$iTtl
=
15
,
$iTtlOnError
=
10
)
protected
function
_getCallback
(
string
$sFunctionname
,
string
$sKey
,
int
$iTtl
=
15
,
int
$iTtlOnError
=
10
)
:
mixed
{
{
$oCache
=
new
AhCache
(
'rollout-'
.
$this
->
getId
(),
'callback-'
.
$sFunctionname
.
'-'
.
$sKey
);
$oCache
=
new
AhCache
(
'rollout-'
.
$this
->
getId
(),
'callback-'
.
$sFunctionname
.
'-'
.
$sKey
);
if
(
$oCache
->
isExpired
())
{
if
(
$oCache
->
isExpired
())
{
$aMydata
=
call_user_func
(
array
(
$this
,
$sFunctionname
)
);
$aMydata
=
call_user_func
(
[
$this
,
$sFunctionname
]
);
// echo "$sFunctionname fresh ".($aMydata ? "OK": "false")." - storing for $iTtl sec<br>";
// echo "$sFunctionname fresh ".($aMydata ? "OK": "false")." - storing for $iTtl sec<br>";
$oCache
->
write
(
$aMydata
,
(
$aMydata
?
$iTtl
:
$iTtlOnError
));
$oCache
->
write
(
$aMydata
,
(
$aMydata
?
$iTtl
:
$iTtlOnError
));
}
else
{
}
else
{
...
@@ -152,13 +161,15 @@ class rollout_base implements iRolloutplugin
...
@@ -152,13 +161,15 @@ class rollout_base implements iRolloutplugin
// echo '<pre>'.print_r($aMydata, 1).'</pre>'; die(__METHOD__);
// echo '<pre>'.print_r($aMydata, 1).'</pre>'; die(__METHOD__);
return
$aMydata
;
return
$aMydata
;
}
}
/**
/**
* render a form by given form elementes
* Get Html code for a form by given form elementes
*
* @param array $aFormdata array of form elements
* @param array $aFormdata array of form elements
* @param string $sKey part of the identifier used in id of the input field
* @param string $sKey part of the identifier used in id of the input field
* @return string
* @return string
*/
*/
protected
function
_renderForm
(
$aFormdata
,
$sKey
)
protected
function
_renderForm
(
array
$aFormdata
,
string
$sKey
):
string
{
{
static
$i
;
static
$i
;
if
(
!
isset
(
$i
))
{
if
(
!
isset
(
$i
))
{
...
@@ -177,12 +188,13 @@ class rollout_base implements iRolloutplugin
...
@@ -177,12 +188,13 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
* render form fields for global plugin variables
* Get Html code for form fields for global plugin variables
*
* @param string $sScope scope of vars ... one of global|project|phase
* @param string $sScope scope of vars ... one of global|project|phase
* @param string $sPhase optional: render global vars in a phase; if no phase was set it renders form fields for project based settings
* @param string $sPhase optional: render global vars in a phase; if no phase was set it renders form fields for project based settings
* @return string
* @return string
*/
*/
protected
function
_renderForm4Vars
(
$sScope
,
$sPhase
=
false
)
protected
function
_renderForm4Vars
(
string
$sScope
,
string
$sPhase
=
''
):
string
{
{
$sReturn
=
''
;
$sReturn
=
''
;
...
@@ -209,8 +221,8 @@ class rollout_base implements iRolloutplugin
...
@@ -209,8 +221,8 @@ class rollout_base implements iRolloutplugin
// create form fields
// create form fields
// $aFormdata[]=
array(
'type' => 'markup','value' => '<br>'.$this->_t('section-override-'.$sScope.'-vars').':'
)
;
// $aFormdata[]=
[
'type' => 'markup','value' => '<br>'.$this->_t('section-override-'.$sScope.'-vars').':'
]
;
$aFormdata
[]
=
array
(
'type'
=>
'markup'
,
'value'
=>
'<div style="style: clear: left;"></div><h4>'
.
$this
->
getId
()
.
' :: '
.
$sScope
.
'</h4>'
)
;
$aFormdata
[]
=
[
'type'
=>
'markup'
,
'value'
=>
'<div style="style: clear: left;"></div><h4>'
.
$this
->
getId
()
.
' :: '
.
$sScope
.
'</h4>'
]
;
$sMiss
=
''
;
$sMiss
=
''
;
foreach
(
$aInfos
[
'vars'
][
$sScope
]
as
$sVarname
=>
$aVarinfos
)
{
foreach
(
$aInfos
[
'vars'
][
$sScope
]
as
$sVarname
=>
$aVarinfos
)
{
...
@@ -243,7 +255,7 @@ class rollout_base implements iRolloutplugin
...
@@ -243,7 +255,7 @@ class rollout_base implements iRolloutplugin
$aCallbackData
[
$aEffectiveConfig
[
$sVarname
]][
'checked'
]
=
'checked'
;
$aCallbackData
[
$aEffectiveConfig
[
$sVarname
]][
'checked'
]
=
'checked'
;
$aCallbackData
[
$aEffectiveConfig
[
$sVarname
]][
'label'
]
.
=
' ««'
;
$aCallbackData
[
$aEffectiveConfig
[
$sVarname
]][
'label'
]
.
=
' ««'
;
}
elseif
(
$aVarinfos
[
'type'
]
===
'select'
)
{
}
elseif
(
$aVarinfos
[
'type'
]
===
'select'
)
{
$aCallbackData
=
array_merge
(
array
(
'NO_SELECTED_ITEM_YET'
=>
array
(
'value'
=>
''
,
'label'
=>
'...'
))
,
$aCallbackData
);
$aCallbackData
=
array_merge
(
[
'NO_SELECTED_ITEM_YET'
=>
[
'value'
=>
''
,
'label'
=>
'...'
]]
,
$aCallbackData
);
}
}
// wenn value = defaultvalue, dann value auf '' setzen (damit bei Default vom Scope
// wenn value = defaultvalue, dann value auf '' setzen (damit bei Default vom Scope
...
@@ -262,7 +274,7 @@ class rollout_base implements iRolloutplugin
...
@@ -262,7 +274,7 @@ class rollout_base implements iRolloutplugin
?
'******************************'
?
'******************************'
:
$sMyPlaceholder
:
$sMyPlaceholder
);
);
$aFormdata
[]
=
array
(
$aFormdata
[]
=
[
'type'
=>
$aVarinfos
[
'type'
],
'type'
=>
$aVarinfos
[
'type'
],
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
...
@@ -273,12 +285,12 @@ class rollout_base implements iRolloutplugin
...
@@ -273,12 +285,12 @@ class rollout_base implements iRolloutplugin
// 'size' => 25,
// 'size' => 25,
'placeholder'
=>
$sMyPlaceholder
,
'placeholder'
=>
$sMyPlaceholder
,
'autocomplete'
=>
'off'
,
'autocomplete'
=>
'off'
,
)
;
]
;
break
;
break
;
case
"select"
:
case
"select"
:
case
"radio"
:
case
"radio"
:
$aOptions
=
$aCallbackData
;
$aOptions
=
$aCallbackData
;
$aFormdata
[]
=
array
(
$aFormdata
[]
=
[
'type'
=>
$aVarinfos
[
'type'
],
'type'
=>
$aVarinfos
[
'type'
],
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
...
@@ -288,10 +300,10 @@ class rollout_base implements iRolloutplugin
...
@@ -288,10 +300,10 @@ class rollout_base implements iRolloutplugin
'options'
=>
$aOptions
,
'options'
=>
$aOptions
,
// 'placeholder' => $sMyPlaceholder
// 'placeholder' => $sMyPlaceholder
)
;
]
;
break
;
break
;
case
"text"
:
case
"text"
:
$aFormdata
[]
=
array
(
$aFormdata
[]
=
[
'type'
=>
$aVarinfos
[
'type'
],
'type'
=>
$aVarinfos
[
'type'
],
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'name'
=>
$sPrefixName
.
'['
.
$sVarname
.
']'
,
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
'label'
=>
$this
->
_t
(
$sVarname
.
'-label'
),
...
@@ -309,7 +321,7 @@ class rollout_base implements iRolloutplugin
...
@@ -309,7 +321,7 @@ class rollout_base implements iRolloutplugin
// 'size' => 25,
// 'size' => 25,
'placeholder'
=>
$sMyPlaceholder
,
'placeholder'
=>
$sMyPlaceholder
,
'autocomplete'
=>
'off'
,
'autocomplete'
=>
'off'
,
)
;
]
;
break
;
break
;
default
:
default
:
...
@@ -317,7 +329,7 @@ class rollout_base implements iRolloutplugin
...
@@ -317,7 +329,7 @@ class rollout_base implements iRolloutplugin
break
;
break
;
}
}
}
}
// $aFormdata[]=
array(
'type' => 'markup','value' => '<div style="style: clear: left;"></div><br><br>'
)
;
// $aFormdata[]=
[
'type' => 'markup','value' => '<div style="style: clear: left;"></div><br><br>'
]
;
return
$this
->
_renderForm
(
$aFormdata
,
$sKey
)
return
$this
->
_renderForm
(
$aFormdata
,
$sKey
)
.
(
$sMiss
.
(
$sMiss
?
'<pre>WARNINGS:<br>'
.
$sMiss
.
'</pre>'
.
(
$sScope
===
'global'
?
$this
->
renderCfgExample
()
:
''
)
?
'<pre>WARNINGS:<br>'
.
$sMiss
.
'</pre>'
.
(
$sScope
===
'global'
?
$this
->
renderCfgExample
()
:
''
)
...
@@ -327,14 +339,15 @@ class rollout_base implements iRolloutplugin
...
@@ -327,14 +339,15 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
*
g
et a translated text from lang_XX.json in plugin dir;
*
G
et a translated text from lang_XX.json in plugin dir;
* If the key is missed it returns "[KEY :: LANG]"
* If the key is missed it returns "[KEY :: LANG]"
*
*
* @see setLang()
* @see setLang()
*
* @param string $sKey key to find in lang file
* @param string $sKey key to find in lang file
* @return string
* @return string
*/
*/
protected
function
_t
(
$sKey
)
protected
function
_t
(
string
$sKey
):
string
{
{
return
(
isset
(
$this
->
_aLang
[
$sKey
])
&&
$this
->
_aLang
[
$sKey
])
return
(
isset
(
$this
->
_aLang
[
$sKey
])
&&
$this
->
_aLang
[
$sKey
])
?
$this
->
_aLang
[
$sKey
]
?
$this
->
_aLang
[
$sKey
]
...
@@ -352,10 +365,11 @@ class rollout_base implements iRolloutplugin
...
@@ -352,10 +365,11 @@ class rollout_base implements iRolloutplugin
* translated texts can be done with $this->_t("your_key")
* translated texts can be done with $this->_t("your_key")
*
*
* @see _t()
* @see _t()
*
* @param string $sLang language code, i.e. "de-de"
* @param string $sLang language code, i.e. "de-de"
* @return boolean
* @return boolean
*/
*/
public
function
setLang
(
$sLang
=
false
)
public
function
setLang
(
string
$sLang
=
''
):
bool
{
{
$this
->
_sLang
=
$sLang
?
$sLang
:
$this
->
_sLang
;
$this
->
_sLang
=
$sLang
?
$sLang
:
$this
->
_sLang
;
...
@@ -371,8 +385,11 @@ class rollout_base implements iRolloutplugin
...
@@ -371,8 +385,11 @@ class rollout_base implements iRolloutplugin
/**
/**
* set a phase for automatic use GETTER methods
* set a phase for automatic use GETTER methods
*
* @param string $sPhase name of the phase; one of preview|stage|live
* @return boolean
*/
*/
public
function
setPhase
(
$sPhase
)
public
function
setPhase
(
string
$sPhase
)
:
bool
{
{
$this
->
_sPhase
=
$sPhase
;
$this
->
_sPhase
=
$sPhase
;
return
true
;
return
true
;
...
@@ -384,7 +401,9 @@ class rollout_base implements iRolloutplugin
...
@@ -384,7 +401,9 @@ class rollout_base implements iRolloutplugin
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
* check requirements if the plugin could work
* Get an array with shell commands to check requirements if the plugin
* can work
*
* @return array
* @return array
*/
*/
public
function
checkRequirements
():
array
public
function
checkRequirements
():
array
...
@@ -394,34 +413,39 @@ class rollout_base implements iRolloutplugin
...
@@ -394,34 +413,39 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
* check access to a deploy target
* Get an array with shell commands to check access to a deploy target
*
* @return array
*/
*/
public
function
checkConnectionToTarget
()
public
function
checkConnectionToTarget
()
:
array
{
{
// do nothing ... always true
// do nothing ... always true
return
true
;
return
[]
;
}
}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// INTERFACE :: SETTER
// INTERFACE :: SETTER
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
* set Config ... by given global config of the current plugin
* Set Config ... by given global config of the current plugin
* @param array $aConfigArray
*
* @param array $aConfigArray complete array of all config data
* @return boolean
*/
*/
public
function
setGlobalConfig
(
$aConfigArray
)
public
function
setGlobalConfig
(
array
$aConfigArray
)
:
bool
{
{
return
$this
->
_aCfgGlobal
=
$aConfigArray
;
$this
->
_aCfgGlobal
=
$aConfigArray
;
return
true
;
}
}
/**
/**
* set Config ... by given project config
* Set Config ... by given project config
*
* @param array $aProjectConfigArray complete array of project config
* @return array
*/
*/
public
function
setProjectConfig
(
$aProjectConfigArray
)
public
function
setProjectConfig
(
array
$aProjectConfigArray
)
:
array
{
{
$this
->
_aCfgProject
=
$aProjectConfigArray
;
$this
->
_aCfgProject
=
$aProjectConfigArray
;
// echo '<pre>'.print_r($aProjectConfigArray, 1).'</pre>';
// echo '<pre>'.print_r($aProjectConfigArray, 1).'</pre>';
...
@@ -431,13 +455,13 @@ class rollout_base implements iRolloutplugin
...
@@ -431,13 +455,13 @@ class rollout_base implements iRolloutplugin
/*
/*
if (!isset($this->_aCfgProject['plugins']['rollout'])){
if (!isset($this->_aCfgProject['plugins']['rollout'])){
if (!isset($this->_aCfgProject['plugins'])){
if (!isset($this->_aCfgProject['plugins'])){
$this->_aCfgProject['plugins']=
array()
;
$this->_aCfgProject['plugins']=
[]
;
}
}
$this->_aCfgProject['plugins']['rollout']=
array()
;
$this->_aCfgProject['plugins']['rollout']=
[]
;
}
}
*
*
*/
*/
$this
->
_aCfgProject
[
'plugins'
][
'rollout'
][
$this
->
_sPluginId
]
=
array
(
'INFO'
=>
'created'
)
;
$this
->
_aCfgProject
[
'plugins'
][
'rollout'
][
$this
->
_sPluginId
]
=
[
'INFO'
=>
'created'
]
;
}
}
// unset empty project values to get global values
// unset empty project values to get global values
...
@@ -456,7 +480,7 @@ class rollout_base implements iRolloutplugin
...
@@ -456,7 +480,7 @@ class rollout_base implements iRolloutplugin
}
}
}
}
}
}
// TODO:
return
$this
->
_aCfgProject
;
return
$this
->
_aCfgProject
;
}
}
...
@@ -465,12 +489,13 @@ class rollout_base implements iRolloutplugin
...
@@ -465,12 +489,13 @@ class rollout_base implements iRolloutplugin
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
/**
* get configuration for the project .. or more specifi for a given phase
* Get configuration array for the project .. or more specific for a given phase
*
* @param string $sPhase
* @param string $sPhase
* @param boolean $bMask Flag for public output; if true then mask your secrets
* @param boolean $bMask Flag for public output; if true then mask your secrets
* @return array
* @return array
*/
*/
public
function
getConfig
(
$sPhase
=
false
,
$bMask
=
false
)
public
function
getConfig
(
string
$sPhase
=
''
,
bool
$bMask
=
false
)
:
array
{
{
$aReturn
=
array_merge
(
$this
->
_aCfgGlobal
,
$this
->
_aCfgProject
[
'plugins'
][
'rollout'
][
$this
->
getId
()]);
$aReturn
=
array_merge
(
$this
->
_aCfgGlobal
,
$this
->
_aCfgProject
[
'plugins'
][
'rollout'
][
$this
->
getId
()]);
...
@@ -490,12 +515,13 @@ class rollout_base implements iRolloutplugin
...
@@ -490,12 +515,13 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
* get an array with shell commands to execute
* Get an array with shell commands to execute for deployment of built file
*
* @param string $sPhase
* @param string $sPhase
* @param boolean $bMask Flag for public output; if true then mask your secrets
* @param boolean $bMask Flag for public output; if true then mask your secrets
* @return array
* @return array
*/
*/
public
function
getDeployCommands
(
$sPhase
,
$bMask
=
false
)
public
function
getDeployCommands
(
string
$sPhase
,
bool
$bMask
=
false
)
:
array
{
{
return
[
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
->
getId
()
.
']"'
,
...
@@ -504,36 +530,39 @@ class rollout_base implements iRolloutplugin
...
@@ -504,36 +530,39 @@ class rollout_base implements iRolloutplugin
}
}
/**
/**
* get string with current ID
* Get string with current plugin ID
*
* @return string
* @return string
*/
*/
public
function
getId
()
public
function
getId
()
:
string
{
{
return
$this
->
_sPluginId
;
return
$this
->
_sPluginId
;
}
}
/**
/**
* get string with plugin name (taken from plugin language file)
* Get name of plugin as string ... language specific
*
* @return string
* @return string
*/
*/
public
function
getName
()
public
function
getName
()
:
string
{
{
return
$this
->
_t
(
'plugin_name'
);
return
$this
->
_t
(
'plugin_name'
);
}
}
/**
/**
*
g
et
string with plugin description (taken from plugin
language
file)
*
G
et
description of plugin as string ...
language
specific
* @return string
* @return string
*/
*/
public
function
getDescription
()
public
function
getDescription
()
:
string
{
{
return
$this
->
_t
(
'description'
);
return
$this
->
_t
(
'description'
);
}
}
/**
/**
*
g
et array
read from
info.js
on
*
G
et array
of data in
info.js
* @return array
* @return array
*/
*/
public
function
getPluginInfos
()
public
function
getPluginInfos
()
:
array
{
{
if
(
$this
->
_aPlugininfos
)
{
if
(
$this
->
_aPlugininfos
)
{
...
@@ -544,7 +573,7 @@ class rollout_base implements iRolloutplugin
...
@@ -544,7 +573,7 @@ class rollout_base implements iRolloutplugin
$sFile
=
dirname
(
$oReflection
->
getFileName
())
.
'/info.json'
;
$sFile
=
dirname
(
$oReflection
->
getFileName
())
.
'/info.json'
;
$this
->
_aPlugininfos
=
(
file_exists
(
$sFile
))
$this
->
_aPlugininfos
=
(
file_exists
(
$sFile
))
?
json_decode
(
file_get_contents
(
$sFile
),
1
)
?
json_decode
(
file_get_contents
(
$sFile
),
1
)
:
array
(
'error'
=>
'unable to read info file ['
.
$sFile
.
'].'
)
:
[
'error'
=>
'unable to read info file ['
.
$sFile
.
'].'
]
;
;
return
$this
->
_aPlugininfos
;
return
$this
->
_aPlugininfos
;
}
}
...
@@ -552,21 +581,26 @@ class rollout_base implements iRolloutplugin
...
@@ -552,21 +581,26 @@ class rollout_base implements iRolloutplugin
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// INTERFACE :: RENDERER
// INTERFACE :: RENDERER
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
* Get HTML code for example configuration
* @return string
*/
public
function
renderCfgExample
()
public
function
renderCfgExample
()
{
{
$sReturn
=
''
;
$sReturn
=
''
;
$sPre
=
' '
;
$sPre
=
' '
;
$aInfos
=
$this
->
getPluginInfos
();
$aInfos
=
$this
->
getPluginInfos
();
$sReturn
.
=
'<pre>$aConfig =
array(
$sReturn
.
=
'<pre>$aConfig =
[
...
...
\'plugins\'=>
array(
\'plugins\'=>
[
...
...
// enabled rollout plugins
// enabled rollout plugins
\'rollout\'=>
array(
\'rollout\'=>
[
...
...
<strong>
<strong>
\''
.
$this
->
getId
()
.
'\'=>
array(
\''
.
$this
->
getId
()
.
'\'=>
[
// '
.
$this
->
getName
()
.
'
// '
.
$this
->
getName
()
.
'
// '
.
$this
->
getDescription
()
.
'
// '
.
$this
->
getDescription
()
.
'
'
.
PHP_EOL
;
'
.
PHP_EOL
;
...
@@ -583,16 +617,23 @@ class rollout_base implements iRolloutplugin
...
@@ -583,16 +617,23 @@ class rollout_base implements iRolloutplugin
}
}
$sReturn
.
=
'
$sReturn
.
=
'
)
,
]
,
</strong>
</strong>
...
...
)
,
]
,
...
...
)
,
]
,
)
;</pre>'
;
]
;</pre>'
;
return
$sReturn
;
return
$sReturn
;
}
}
protected
function
_renderMoreToggler
(
$sContent
)
/**
* Get html code for button [...] that shows and hides more information
*
* @param string $sContent
* @return string
*/
protected
function
_renderMoreToggler
(
string
$sContent
)
{
{
$sDivId
=
'rollout-more-toggler-'
.
$this
->
getId
()
.
'-'
.
md5
(
$sContent
);
$sDivId
=
'rollout-more-toggler-'
.
$this
->
getId
()
.
'-'
.
md5
(
$sContent
);
return
''
return
''
...
@@ -603,7 +644,14 @@ class rollout_base implements iRolloutplugin
...
@@ -603,7 +644,14 @@ class rollout_base implements iRolloutplugin
;
;
}
}
public
function
renderFormdata4Project
()
/**
* Override general form renderer: show
* - formvars for project
*
* @return string
*/
public
function
renderFormdata4Project
():
string
{
{
return
''
return
''
.
$this
->
_renderForm4Vars
(
'project'
,
false
)
.
$this
->
_renderForm4Vars
(
'project'
,
false
)
...
@@ -614,7 +662,14 @@ class rollout_base implements iRolloutplugin
...
@@ -614,7 +662,14 @@ class rollout_base implements iRolloutplugin
// .'<pre>DEBUG: $this->_aCfgProject ... plugin = '.print_r($this->_aCfgProject, 1).'</pre>'
// .'<pre>DEBUG: $this->_aCfgProject ... plugin = '.print_r($this->_aCfgProject, 1).'</pre>'
;
;
}
}
public
function
renderFormdata4Phase
(
$sPhase
)
/**
* override of form renderer: show configuration for a given phase
* @param string $sPhase phaese; one of preview|stage|live
* @return string
*/
public
function
renderFormdata4Phase
(
string
$sPhase
):
string
{
{
static
$iCounter
;
static
$iCounter
;
if
(
!
isset
(
$iCounter
))
{
if
(
!
isset
(
$iCounter
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment