Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Autowiring a parameter with double percent signs not working with twig GlobalsInterface #58970

Open
@kriskoch

Description

@kriskoch

Symfony version(s) affected

7.1.8

Description

I am trying to add a parameter to the config yaml like this

parameters:
        string_format: my friend %%s has %%d dogs

However, when I try to autowire it to a class that implements Twig\Extension\GlobalsInterface; I receive the following error

You have requested a non-existent parameter "s has ".

How to reproduce

I set this parameter in yaml

parameters:
        string_format: my friend %%s has %%d dogs

I autowire it in a constructor for a class implementing Twig\Extension\GlobalsInterface;
public function __construct( #[Autowire('%string_format%')] private readonly string $stringFormat]{}

Stack trace is pointing to

App_KernelDevDebugContainer.php

 $instance->addExtension(new \App\Twig\TwigExtension('my friend '.$container->getParameter('s has ').'d dogs'));

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions