From 3688b55174e9cb86803b8315baf365feba755d26 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 25 Jan 2018 17:59:35 +0100 Subject: [PATCH 1/2] Documented the Twig extension priority --- reference/dic_tags.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 05288a1baf3..f622b3ee48a 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. They are 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. From 40852fb69a63b645c78fb844b7da02df9a95fbf0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 27 Jan 2018 10:12:25 +0100 Subject: [PATCH 2/2] Minor tweaks --- reference/dic_tags.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index f622b3ee48a..b84e5168b67 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -1039,10 +1039,10 @@ the service is auto-registered and auto-tagged. But, you can also register it ma tags: [twig.extension] # optionally you can define the priority of the extension (default = 0). - # Extensions with higher priorities are registered earlier. They are mostly + # 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 }] + tags: [{ name: twig.extension, priority: -100 }] .. code-block:: xml @@ -1058,7 +1058,7 @@ the service is auto-registered and auto-tagged. But, you can also register it ma - + @@ -1073,7 +1073,7 @@ the service is auto-registered and auto-tagged. But, you can also register it ma ->addTag('twig.extension') ->register(AnotherExtension::class) - ->addTag('twig.extension', array('priority' => 100)) + ->addTag('twig.extension', array('priority' => -100)) ; .. versionadded::