diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 05288a1baf3..b84e5168b67 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -1038,6 +1038,12 @@ the service is auto-registered and auto-tagged. But, you can also register it ma App\Twig\AppExtension: tags: [twig.extension] + # optionally you can define the priority of the extension (default = 0). + # Extensions with higher priorities are registered earlier. This is mostly + # useful to register late extensions that override other extensions. + App\Twig\AnotherExtension: + tags: [{ name: twig.extension, priority: -100 }] + .. code-block:: xml @@ -1050,18 +1056,30 @@ the service is auto-registered and auto-tagged. But, you can also register it ma + + + + .. code-block:: php use App\Twig\AppExtension; + use App\Twig\AnotherExtension; $container ->register(AppExtension::class) ->addTag('twig.extension') + + ->register(AnotherExtension::class) + ->addTag('twig.extension', array('priority' => -100)) ; +.. versionadded:: + The ``priority`` attribute of the ``twig.extension`` tag was introduced in + Symfony 4.1. + For information on how to create the actual Twig Extension class, see `Twig's documentation`_ on the topic or read the :doc:`/templating/twig_extension` article.