|
5 | 5 | How to Work with Service Tags |
6 | 6 | ============================= |
7 | 7 |
|
8 | | -In the same way that a blog post on the web might be tagged with things such |
9 | | -as "Symfony" or "PHP", services configured in your container can also be |
10 | | -tagged. In the service container, a tag implies that the service is meant |
11 | | -to be used for a specific purpose. Take the following example: |
| 8 | +**Service tags** are a way to tell Symfony or other third-party bundles that |
| 9 | +your service should be registered in some special way. Take the following |
| 10 | +example: |
12 | 11 |
|
13 | 12 | .. configuration-block:: |
14 | 13 |
|
@@ -51,19 +50,13 @@ to be used for a specific purpose. Take the following example: |
51 | 50 | ->setPublic(false) |
52 | 51 | ->addTag('twig.extension'); |
53 | 52 |
|
54 | | -The ``twig.extension`` tag is a special tag that the TwigBundle uses |
55 | | -during configuration. By giving the service this ``twig.extension`` tag, |
56 | | -the bundle knows that the ``app.twig_extension`` service should be registered |
57 | | -as a Twig extension with Twig. In other words, Twig finds all services tagged |
58 | | -with ``twig.extension`` and automatically registers them as extensions. |
| 53 | +Services tagged with the ``twig.extension`` tag are collected during the |
| 54 | +initialization of TwigBundle and added to Twig as extensions. |
59 | 55 |
|
60 | | -Tags, then, are a way to tell Symfony or other third-party bundles that |
61 | | -your service should be registered or used in some special way by the bundle. |
62 | | - |
63 | | -For a list of all the tags available in the core Symfony Framework, check |
64 | | -out :doc:`/reference/dic_tags`. Each of these has a different effect on your |
65 | | -service and many tags require additional arguments (beyond just the ``name`` |
66 | | -parameter). |
| 56 | +Other tags are used to integrate your services into other systems. For a list of |
| 57 | +all the tags available in the core Symfony Framework, check out |
| 58 | +:doc:`/reference/dic_tags`. Each of these has a different effect on your service |
| 59 | +and many tags require additional arguments (beyond just the ``name`` parameter). |
67 | 60 |
|
68 | 61 | Creating custom Tags |
69 | 62 | -------------------- |
|
0 commit comments