From b0e984c8d410638570071340cf85796885ed8693 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 4 Mar 2018 10:34:46 +0100 Subject: [PATCH] Twig Extension runtimes are autoconfigured --- templating/twig_extension.rst | 48 +++-------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index 73abcea485a..ab90a501f8e 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -134,51 +134,9 @@ previous ``priceFilter()`` method:: } } -Register the Lazy-Loaded Extension as a Service -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Finally, register your new class as a service and tag it with ``twig.runtime`` -(and optionally inject any service needed by the Twig extension runtime): - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/services.yml - services: - app.twig_runtime: - class: AppBundle\Twig\AppRuntime - public: false - tags: - - { name: twig.runtime } - - .. code-block:: xml - - - - - - - - - - - - - .. code-block:: php - - // app/config/services.php - use AppBundle\Twig\AppExtension; - - $container - ->register('app.twig_runtime', AppRuntime::class) - ->setPublic(false) - ->addTag('twig.runtime'); +If you're using the default ``services.yaml`` configuration, this will already +work! Otherwise, :ref:`create a service ` +for this class and :doc:`tag your service ` with ``twig.runtime``. .. _`official Twig extensions`: https://github.com/twigphp/Twig-extensions .. _`Twig extensions documentation`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension