resolveRecursively method

  1. @protected
String? resolveRecursively(
  1. PlaceholderPartResolutionContext resolutionContext,
  2. String key
)

Recursively resolves the placeholder identified by key using the provided resolutionContext.

This method performs the following:

  • Calls resolvePlaceholder(key) to get a value.
  • If a value exists, it flags the placeholder as visited.
  • It parses the resolved value into nested parts.
  • If those parts are not just plain text (i.e., contain other placeholders), it delegates resolution to PlaceholderParsedValue.resolve.
  • Finally, it removes the placeholder from the visited list to avoid circular references.

If no value is found, it returns null.

Throws PlaceholderResolutionException if circular reference is detected.

Implementation

@protected
String? resolveRecursively(PlaceholderPartResolutionContext resolutionContext, String key) {
  String? resolvedValue = resolutionContext.resolvePlaceholder(key);
  if (resolvedValue != null) {
    resolutionContext.flagPlaceholderAsVisited(key);

    List<PlaceholderPart> nestedParts = resolutionContext.parse(resolvedValue);
    String value = _toText(nestedParts);

    if (!_isTextOnly(nestedParts)) {
      value = PlaceholderParsedValue(resolvedValue, nestedParts).resolve(resolutionContext);
    }

    resolutionContext.removePlaceholder(key);
    return value;
  }

  return null;
}