@@ -134,51 +134,9 @@ previous ``priceFilter()`` method::
134
134
}
135
135
}
136
136
137
- Register the Lazy-Loaded Extension as a Service
138
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
-
140
- Finally, register your new class as a service and tag it with ``twig.runtime ``
141
- (and optionally inject any service needed by the Twig extension runtime):
142
-
143
- .. configuration-block ::
144
-
145
- .. code-block :: yaml
146
-
147
- # app/config/services.yml
148
- services :
149
- app.twig_runtime :
150
- class : AppBundle\Twig\AppRuntime
151
- public : false
152
- tags :
153
- - { name: twig.runtime }
154
-
155
- .. code-block :: xml
156
-
157
- <!-- app/config/services.xml -->
158
- <?xml version =" 1.0" encoding =" UTF-8" ?>
159
- <container xmlns =" http://symfony.com/schema/dic/services"
160
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
161
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
162
- http://symfony.com/schema/dic/services/services-1.0.xsd" >
163
-
164
- <services >
165
- <service id =" app.twig_runtime"
166
- class =" AppBundle\Twig\AppRuntime"
167
- public =" false" >
168
- <tag name =" twig.runtime" />
169
- </service >
170
- </services >
171
- </container >
172
-
173
- .. code-block :: php
174
-
175
- // app/config/services.php
176
- use AppBundle\Twig\AppExtension;
177
-
178
- $container
179
- ->register('app.twig_runtime', AppRuntime::class)
180
- ->setPublic(false)
181
- ->addTag('twig.runtime');
137
+ If you're using the default ``services.yaml `` configuration, this will already
138
+ work! Otherwise, :ref: `create a service <service-container-creating-service >`
139
+ for this class and :doc: `tag your service </service_container/tags >` with ``twig.runtime ``.
182
140
183
141
.. _`official Twig extensions` : https://github.com/twigphp/Twig-extensions
184
142
.. _`Twig extensions documentation` : http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
0 commit comments