@@ -1038,6 +1038,12 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
10381038 App\Twig\AppExtension :
10391039 tags : [twig.extension]
10401040
1041+ # optionally you can define the priority of the extension (default = 0).
1042+ # Extensions with higher priorities are registered earlier. This is mostly
1043+ # useful to register late extensions that override other extensions.
1044+ App\Twig\AnotherExtension :
1045+ tags : [{ name: twig.extension, priority: -100 }]
1046+
10411047 .. code-block :: xml
10421048
10431049 <?xml version =" 1.0" encoding =" UTF-8" ?>
@@ -1050,18 +1056,30 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
10501056 <service id =" App\Twig\AppExtension" >
10511057 <tag name =" twig.extension" />
10521058 </service >
1059+
1060+ <service id =" App\Twig\AnotherExtension" >
1061+ <tag name =" twig.extension" priority =" -100" />
1062+ </service >
10531063 </services >
10541064 </container >
10551065
10561066 .. code-block :: php
10571067
10581068 use App\Twig\AppExtension;
1069+ use App\Twig\AnotherExtension;
10591070
10601071 $container
10611072 ->register(AppExtension::class)
10621073 ->addTag('twig.extension')
1074+
1075+ ->register(AnotherExtension::class)
1076+ ->addTag('twig.extension', array('priority' => -100))
10631077 ;
10641078
1079+ .. versionadded ::
1080+ The ``priority `` attribute of the ``twig.extension `` tag was introduced in
1081+ Symfony 4.1.
1082+
10651083For information on how to create the actual Twig Extension class, see
10661084`Twig's documentation `_ on the topic or read the
10671085:doc: `/templating/twig_extension ` article.
0 commit comments