Skip to content

Commit

Permalink
Added the missing versionadded directive
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jul 6, 2018
1 parent cb102c1 commit 4e9b044
Showing 1 changed file with 6 additions and 45 deletions.
51 changes: 6 additions & 45 deletions templating/twig_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,51 +134,12 @@ 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
<!-- app/config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="app.twig_runtime"
class="AppBundle\Twig\AppRuntime"
public="false">
<tag name="twig.runtime" />
</service>
</services>
</container>
.. code-block:: php
// app/config/services.php
use AppBundle\Twig\AppExtension;
$container
->register('app.twig_runtime', AppRuntime::class)
->setPublic(false)
->addTag('twig.runtime');
.. versionadded:: 3.4
The ``RuntimeExtensionInterface`` was introduced in Symfony 3.4.

If you're using the default ``services.yaml`` configuration, this will already
work! Otherwise, :ref:`create a service <service-container-creating-service>`
for this class and :doc:`tag your service </service_container/tags>` with ``twig.runtime``.

.. _`Twig extensions documentation`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
.. _`global variables`: http://twig.sensiolabs.org/doc/advanced.html#id1
Expand Down

0 comments on commit 4e9b044

Please sign in to comment.