From 2b93b7d04194c5d6fb2af7aadb48e5c557febbca Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 14 Nov 2017 13:09:39 +0100 Subject: [PATCH 1/2] Reworded the explanation about service tags --- service_container/tags.rst | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/service_container/tags.rst b/service_container/tags.rst index c1b7515e90c..5da06cd6066 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -5,10 +5,15 @@ How to Work with Service Tags ============================= -In the same way that a blog post on the web might be tagged with things such -as "Symfony" or "PHP", services configured in your container can also be -tagged. In the service container, a tag implies that the service is meant -to be used for a specific purpose. Take the following example: +Some container services require to be registered or used in some special way. +Consider for example the :doc:`Twig extensions `: +they are PHP classes that must be added to the main Twig object before using +them. If you define those exensions as regular Symfony services, Twig will +ignore them and an exception will be thrown when using them in templates. + +**Service tags** are a way to tell Symfony or other third-party bundles that +your service should be registered in some special way. Take the following +example: .. configuration-block:: @@ -51,14 +56,10 @@ to be used for a specific purpose. Take the following example: ->setPublic(false) ->addTag('twig.extension'); -The ``twig.extension`` tag is a special tag that the TwigBundle uses -during configuration. By giving the service this ``twig.extension`` tag, -the bundle knows that the ``app.twig_extension`` service should be registered -as a Twig extension with Twig. In other words, Twig finds all services tagged -with ``twig.extension`` and automatically registers them as extensions. - -Tags, then, are a way to tell Symfony or other third-party bundles that -your service should be registered or used in some special way by the bundle. +Services tagged with the ``twig.extension`` tag are collected during the +initialization of TwigBundle to enable them as Twig extensions. In this example, +that's why Symfony knows that the ``app.twig_extension`` service should be +registered as a Twig extension. For a list of all the tags available in the core Symfony Framework, check out :doc:`/reference/dic_tags`. Each of these has a different effect on your From c03b5e3617a69a0ce7cabbdcbd6af38497e991aa Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 16 Nov 2017 16:22:09 +0100 Subject: [PATCH 2/2] Removed lots of redundant contents --- service_container/tags.rst | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/service_container/tags.rst b/service_container/tags.rst index 5da06cd6066..5b74450fc18 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -5,12 +5,6 @@ How to Work with Service Tags ============================= -Some container services require to be registered or used in some special way. -Consider for example the :doc:`Twig extensions `: -they are PHP classes that must be added to the main Twig object before using -them. If you define those exensions as regular Symfony services, Twig will -ignore them and an exception will be thrown when using them in templates. - **Service tags** are a way to tell Symfony or other third-party bundles that your service should be registered in some special way. Take the following example: @@ -57,14 +51,12 @@ example: ->addTag('twig.extension'); Services tagged with the ``twig.extension`` tag are collected during the -initialization of TwigBundle to enable them as Twig extensions. In this example, -that's why Symfony knows that the ``app.twig_extension`` service should be -registered as a Twig extension. - -For a list of all the tags available in the core Symfony Framework, check -out :doc:`/reference/dic_tags`. Each of these has a different effect on your -service and many tags require additional arguments (beyond just the ``name`` -parameter). +initialization of TwigBundle and added to Twig as extensions. + +Other tags are used to integrate your services into other systems. For a list of +all the tags available in the core Symfony Framework, check out +:doc:`/reference/dic_tags`. Each of these has a different effect on your service +and many tags require additional arguments (beyond just the ``name`` parameter). Creating custom Tags --------------------