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

Breadcrumb

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

function MergeExtensionConfigurationContainerBuilder::resolveEnvPlaceholders

Overrides ContainerBuilder::resolveEnvPlaceholders

File

vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php, line 186

Class

MergeExtensionConfigurationContainerBuilder
A container builder preventing using methods that wouldn't have any effect from extensions.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function resolveEnvPlaceholders(mixed $value, string|bool|null $format = null, ?array &$usedEnvs = null) : mixed {
    if (true !== $format || !\is_string($value)) {
        return parent::resolveEnvPlaceholders($value, $format, $usedEnvs);
    }
    $bag = $this->getParameterBag();
    $value = $bag->resolveValue($value);
    if (!$bag instanceof EnvPlaceholderParameterBag) {
        return parent::resolveEnvPlaceholders($value, true, $usedEnvs);
    }
    foreach ($bag->getEnvPlaceholders() as $env => $placeholders) {
        if (!str_contains($env, ':')) {
            continue;
        }
        foreach ($placeholders as $placeholder) {
            if (false !== stripos($value, $placeholder)) {
                throw new RuntimeException(\sprintf('Using a cast in "env(%s)" is incompatible with resolution at compile time in "%s". The logic in the extension should be moved to a compiler pass, or an env parameter with no cast should be used instead.', $env, $this->extensionClass));
            }
        }
    }
    return parent::resolveEnvPlaceholders($value, true, $usedEnvs);
}
RSS feed
Powered by Drupal