diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index e95d1b7e5cd..fc29fb8de0e 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -41,6 +41,7 @@ Tag Name Usage `translation.dumper`_ Register a custom service that dumps translation messages `twig.extension`_ Register a custom Twig Extension `twig.loader`_ Register a custom service that loads Twig templates +`twig.runtime`_ Register a lazy-loaded Twig Extension `validator.constraint_validator`_ Create your own custom validation constraint `validator.initializer`_ Register a service that initializes objects before validation ======================================== ======================================================================== @@ -1175,6 +1176,55 @@ also register it manually: The ``priority`` value is optional and defaults to ``0``. The higher priority loaders are tried first. +.. _reference-dic-tags-twig-runtime: + +twig.runtime +-------------- + +**Purpose**: To register a custom Lazy-Loaded Twig Extension + +To enable a Lazy Loaded Twig extension, add it as a regular service in one of your +configuration and tag it with ``twig.runtime``. If you're using the +:ref:`default services.yaml configuration `, +the service is auto-registered and auto-tagged. But, you can also register it manually: + +.. configuration-block:: + + .. code-block:: yaml + + services: + App\Twig\AppExtension: + tags: [twig.runtime] + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + use App\Twig\AppExtension; + use App\Twig\AnotherExtension; + + $container + ->register(AppExtension::class) + ->addTag('twig.runtime') + ; + +For information on how to create the actual Runtime Twig Extension class, see +`Twig's documentation`_ on the topic or read the +:ref:`Creating Lazy-Loaded Twig Extensions ` article. + validator.constraint_validator ------------------------------