From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Resolver/OverrideHelper.php | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 library/Director/Resolver/OverrideHelper.php (limited to 'library/Director/Resolver/OverrideHelper.php') diff --git a/library/Director/Resolver/OverrideHelper.php b/library/Director/Resolver/OverrideHelper.php new file mode 100644 index 0000000..f911a4f --- /dev/null +++ b/library/Director/Resolver/OverrideHelper.php @@ -0,0 +1,38 @@ +getOverriddenServiceVars($serviceName); + foreach ($properties as $key => $value) { + if ($key === 'vars') { + foreach ($value as $k => $v) { + $current->$k = $v; + } + } else { + $current->{substr($key, 5)} = $value; + } + } + $host->overrideServiceVars($serviceName, $current); + } + + public static function assertVarsForOverrides($properties) + { + if (empty($properties)) { + return; + } + + foreach ($properties as $key => $value) { + if ($key !== 'vars' && substr($key, 0, 5) !== 'vars.') { + throw new InvalidArgumentException("Only Custom Variables can be set based on Variable Overrides"); + } + } + } +} -- cgit v1.2.3