diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 7041ec93..9948050c 100644 --- a/CREATE_BRIDGE.md +++ b/CREATE_BRIDGE.md @@ -59,6 +59,8 @@ The array can be a key-based array, but it is not necessary. The following synta $this->parameters[] = ... $this->parameters['First usage of my bridge'] = ... ``` +It is worth mentionning that you can also define a set of parameters that will be applied to every possible utilisation of your bridge. +To do this, just create a parameter array with the `global` key. ### Format specifications diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index dce8b8f0..4e6b5e24 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -56,8 +56,28 @@ CARD; } + $hasGlobalParameter = array_key_exists("global", $bridgeElement->parameters); + if($hasGlobalParameter) { + $globalParameters = json_decode($bridgeElement->parameters['global'], true); + } + foreach($bridgeElement->parameters as $parameterName => $parameter) { + + $parameter = json_decode($parameter, true); + + if(!is_numeric($parameterName) && $parameterName == "global") { + + continue; + + } + + if($hasGlobalParameter) { + + $parameter = array_merge($parameter, $globalParameters); + + } + if(!is_numeric($parameterName)) { $card .= '
'.$parameterName.'
' . PHP_EOL; } @@ -65,7 +85,6 @@ CARD; ' . PHP_EOL; - $parameter = json_decode($parameter, true); foreach($parameter as $inputEntry) {