@@ -41,6 +41,7 @@ Tag Name Usage
4141`translation.dumper `_ Register a custom service that dumps translation messages
4242`twig.extension `_ Register a custom Twig Extension
4343`twig.loader `_ Register a custom service that loads Twig templates
44+ `twig.runtime `_ Register a lazy-loaded Twig Extension
4445`validator.constraint_validator `_ Create your own custom validation constraint
4546`validator.initializer `_ Register a service that initializes objects before validation
4647======================================== ========================================================================
@@ -1175,6 +1176,55 @@ also register it manually:
11751176 The ``priority `` value is optional and defaults to ``0 ``.
11761177 The higher priority loaders are tried first.
11771178
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+
11781228validator.constraint_validator
11791229------------------------------
11801230
0 commit comments