@@ -1038,6 +1038,12 @@ the service is auto-registered and auto-tagged. But, you can also register it ma
1038
1038
App\Twig\AppExtension :
1039
1039
tags : [twig.extension]
1040
1040
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
+
1041
1047
.. code-block :: xml
1042
1048
1043
1049
<?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
1050
1056
<service id =" App\Twig\AppExtension" >
1051
1057
<tag name =" twig.extension" />
1052
1058
</service >
1059
+
1060
+ <service id =" App\Twig\AnotherExtension" >
1061
+ <tag name =" twig.extension" priority =" -100" />
1062
+ </service >
1053
1063
</services >
1054
1064
</container >
1055
1065
1056
1066
.. code-block :: php
1057
1067
1058
1068
use App\Twig\AppExtension;
1069
+ use App\Twig\AnotherExtension;
1059
1070
1060
1071
$container
1061
1072
->register(AppExtension::class)
1062
1073
->addTag('twig.extension')
1074
+
1075
+ ->register(AnotherExtension::class)
1076
+ ->addTag('twig.extension', array('priority' => -100))
1063
1077
;
1064
1078
1079
+ .. versionadded ::
1080
+ The ``priority `` attribute of the ``twig.extension `` tag was introduced in
1081
+ Symfony 4.1.
1082
+
1065
1083
For information on how to create the actual Twig Extension class, see
1066
1084
`Twig's documentation `_ on the topic or read the
1067
1085
:doc: `/templating/twig_extension ` article.
0 commit comments