Skip to content

Commit

Permalink
[DependencyInjection][Config] Use several placeholder unique prefixes…
Browse files Browse the repository at this point in the history
… for dynamic placeholder values
  • Loading branch information
fancyweb committed Jul 15, 2020
1 parent 06ae0de commit b1d8f0d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Definition/BaseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class BaseNode implements NodeInterface
{
const DEFAULT_PATH_SEPARATOR = '.';

private static $placeholderUniquePrefix;
private static $placeholderUniquePrefixes = [];
private static $placeholders = [];

protected $name;
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

/**
Expand All @@ -93,7 +93,7 @@ public static function setPlaceholderUniquePrefix(string $prefix): void
*/
public static function resetPlaceholders(): void
{
self::$placeholderUniquePrefix = null;
self::$placeholderUniquePrefixes = [];
self::$placeholders = [];
}

Expand Down Expand Up @@ -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 [];
}
}
}

Expand Down

0 comments on commit b1d8f0d

Please sign in to comment.