From b1d8f0d9341ea1d378b8b043ba90739f37c49d36 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Tue, 7 Jul 2020 10:23:41 +0200 Subject: [PATCH] [DependencyInjection][Config] Use several placeholder unique prefixes for dynamic placeholder values --- Definition/BaseNode.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Definition/BaseNode.php b/Definition/BaseNode.php index f3ae891ba..3d7fd8560 100644 --- a/Definition/BaseNode.php +++ b/Definition/BaseNode.php @@ -26,7 +26,7 @@ abstract class BaseNode implements NodeInterface { const DEFAULT_PATH_SEPARATOR = '.'; - private static $placeholderUniquePrefix; + private static $placeholderUniquePrefixes = []; private static $placeholders = []; protected $name; @@ -74,7 +74,7 @@ public static function setPlaceholder(string $placeholder, array $values): void } /** - * Sets a common prefix for dynamic placeholder values. + * Adds a common prefix for dynamic placeholder values. * * Matching configuration values will be skipped from being processed and are returned as is, thus preserving the * placeholder. An exact match provided by {@see setPlaceholder()} might take precedence. @@ -83,7 +83,7 @@ public static function setPlaceholder(string $placeholder, array $values): void */ public static function setPlaceholderUniquePrefix(string $prefix): void { - self::$placeholderUniquePrefix = $prefix; + self::$placeholderUniquePrefixes[] = $prefix; } /** @@ -93,7 +93,7 @@ public static function setPlaceholderUniquePrefix(string $prefix): void */ public static function resetPlaceholders(): void { - self::$placeholderUniquePrefix = null; + self::$placeholderUniquePrefixes = []; self::$placeholders = []; } @@ -513,8 +513,10 @@ private static function resolvePlaceholderValue($value) return self::$placeholders[$value]; } - if (self::$placeholderUniquePrefix && 0 === strpos($value, self::$placeholderUniquePrefix)) { - return []; + foreach (self::$placeholderUniquePrefixes as $placeholderUniquePrefix) { + if (0 === strpos($value, $placeholderUniquePrefix)) { + return []; + } } }