Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ParameterBag.php

function ParameterBag::resolveValue

Replaces parameter placeholders (%name%) by their values.

@template TValue of array<array|scalar>|scalar

@psalm-return (TValue is scalar ? array|scalar : array<array|scalar>)

Parameters

TValue $value:

array $resolving An array of keys that are being resolved (used internally to detect circular references):

Throws

ParameterNotFoundException if a placeholder references a parameter that does not exist

ParameterCircularReferenceException if a circular reference if detected

RuntimeException when a given parameter has a type problem

Overrides ParameterBagInterface::resolveValue

2 calls to ParameterBag::resolveValue()
ParameterBag::resolve in vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
Replaces parameter placeholders (%name%) by their values for all parameters.
ParameterBag::resolveString in vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
Resolves parameters inside a string.

File

vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php, line 187

Class

ParameterBag
Holds parameters.

Namespace

Symfony\Component\DependencyInjection\ParameterBag

Code

public function resolveValue(mixed $value, array $resolving = []) : mixed {
    if (\is_array($value)) {
        $args = [];
        foreach ($value as $key => $v) {
            $resolvedKey = \is_string($key) ? $this->resolveValue($key, $resolving) : $key;
            if (!\is_scalar($resolvedKey) && !$resolvedKey instanceof \Stringable) {
                throw new RuntimeException(\sprintf('Array keys must be a scalar-value, but found key "%s" to resolve to type "%s".', $key, get_debug_type($resolvedKey)));
            }
            $args[$resolvedKey] = $this->resolveValue($v, $resolving);
        }
        return $args;
    }
    if (!\is_string($value) || '' === $value || !str_contains($value, '%')) {
        return $value;
    }
    return $this->resolveString($value, $resolving);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal