@@ -41,6 +41,7 @@ Tag Name Usage
41
41
`translation.dumper `_ Register a custom service that dumps translation messages
42
42
`twig.extension `_ Register a custom Twig Extension
43
43
`twig.loader `_ Register a custom service that loads Twig templates
44
+ `twig.runtime `_ Register a lazy-loaded Twig Extension
44
45
`validator.constraint_validator `_ Create your own custom validation constraint
45
46
`validator.initializer `_ Register a service that initializes objects before validation
46
47
======================================== ========================================================================
@@ -1175,6 +1176,55 @@ also register it manually:
1175
1176
The ``priority `` value is optional and defaults to ``0 ``.
1176
1177
The higher priority loaders are tried first.
1177
1178
1179
+ .. _reference-dic-tags-twig-runtime :
1180
+
1181
+ twig.runtime
1182
+ --------------
1183
+
1184
+ **Purpose **: To register a custom Lazy-Loaded Twig Extension
1185
+
1186
+ To enable a Lazy Loaded Twig extension, add it as a regular service in one of your
1187
+ configuration and tag it with ``twig.runtime ``. If you're using the
1188
+ :ref: `default services.yaml configuration <service-container-services-load-example >`,
1189
+ the service is auto-registered and auto-tagged. But, you can also register it manually:
1190
+
1191
+ .. configuration-block ::
1192
+
1193
+ .. code-block :: yaml
1194
+
1195
+ services :
1196
+ App\Twig\AppExtension :
1197
+ tags : [twig.runtime]
1198
+
1199
+ .. code-block :: xml
1200
+
1201
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1202
+ <container xmlns =" http://symfony.com/schema/dic/services"
1203
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1204
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1205
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
1206
+
1207
+ <services >
1208
+ <service id =" App\Twig\AppExtension" >
1209
+ <tag name =" twig.runtime" />
1210
+ </service >
1211
+ </services >
1212
+ </container >
1213
+
1214
+ .. code-block :: php
1215
+
1216
+ use App\Twig\AppExtension;
1217
+ use App\Twig\AnotherExtension;
1218
+
1219
+ $container
1220
+ ->register(AppExtension::class)
1221
+ ->addTag('twig.runtime')
1222
+ ;
1223
+
1224
+ For information on how to create the actual Runtime Twig Extension class, see
1225
+ `Twig's documentation `_ on the topic or read the
1226
+ :ref: `Creating Lazy-Loaded Twig Extensions <lazy-loaded-twig-extensions >` article.
1227
+
1178
1228
validator.constraint_validator
1179
1229
------------------------------
1180
1230
0 commit comments