diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 7041ec9..9948050 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 dce8b8f..4e6b5e2 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 .= '