Skip to content

[Twig-Bridge] [RFC] Allow to declare twig extensions via config ? #53403

Closed
@VincentLanglet

Description

@VincentLanglet

Description

Maybe I misunderstood some things about TwigRuntime but when I create one I have to do:

  • One runtime, with some services injections and a method doThings.
  • One twigExtension with the code:
new TwigFunction('doThings', [MyRuntime::class, 'doThings']),

This create duplicate classes.

Eventually, one thing I can do is to have multiple runtimes, but one single twigExtension calling all of them.

new TwigFunction('doThings', [MyRuntime::class, 'doThings']),
new TwigFunction('doOtherThings', [MyOtherRuntime::class, 'doOtherThings']),

But I was wondering the purpose of this twigExtension in such case and if this couldn't be generated by some config directly:

framework:
    twig:
        functions:
        filters:
        tests:

What do you think about such feature ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)StalledTwigBridgeTwigBundle

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions