Multiple Twig_Extension in Symfony2

I want to register my custom Twig filters in a separate bundle (so I don't have one huge file).

I have Yaml configurations in each kit:

# services.yml
services:
    twig.extension.[BundleName]:
        class: Kuba\[BundleName]\Twig\AppExtension
        public: false
        tags:
            - { name: twig.extension }

      

However, all the time the last (lexicographic) extension overrides the previous one.

How can I register more than one extension, and if that is not possible, what would be the best practice to split the code?

+3


source to share


1 answer


Twig extensions are identified by the string returned by the method getName()

. Is there a reason why you should return the same string across all extensions on your branch?



+6


source







All Articles