8000 minor #9388 Twig Extension runtimes are autoconfigured (javiereguiluz) · symfony/symfony-docs@e8f9334 · GitHub
[go: up one dir, main page]

Skip to content

Commit e8f9334

Browse files
committed
minor #9388 Twig Extension runtimes are autoconfigured (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Twig Extension runtimes are autoconfigured Commits ------- b0e984c Twig Extension runtimes are autoconfigured
2 parents 1e32c42 + b0e984c commit e8f9334

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

templating/twig_extension.rst

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,51 +134,9 @@ previous ``priceFilter()`` method::
134134
}
135135
}
136136

137-
Register the Lazy-Loaded Extension as a Service
138-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139-
140-
Finally, register your new class as a service and tag it with ``twig.runtime``
141-
(and optionally inject any service needed by the Twig extension runtime):
142-
143-
.. configuration-block::
144-
145-
.. code-block:: yaml
146-
147-
# app/config/services.yml
148-
services:
149-
app.twig_runtime:
150-
class: AppBundle\Twig\AppRuntime
151-
public: false
152-
tags:
153-
- { name: twig.runtime }
154-
155-
.. code-block:: xml
156-
157-
<!-- app/config/services.xml -->
158-
<?xml version="1.0" encoding="UTF-8" ?>
159-
<container xmlns="http://symfony.com/schema/dic/services"
160-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
161-
xsi:schemaLocation="http://symfony.com/schema/dic/services
162-
http://symfony.com/schema/dic/services/services-1.0.xsd">
163-
164-
<services>
165-
<service id="app.twig_runtime"
166-
class="AppBundle\Twig\AppRuntime"
167-
public="false">
168-
<tag name="twig.runtime" />
169-
</service>
170-
</services>
171-
</container>
172-
173-
.. code-block:: php
174-
175-
// app/config/services.php
176-
use AppBundle\Twig\AppExtension;
177-
178-
$container
179-
->register('app.twig_runtime', AppRuntime::class)
180-
->setPublic(false)
181-
->addTag('twig.runtime');
137+
If you're using the default ``services.yaml`` configuration, this will already
138+
work! Otherwise, :ref:`create a service <service-container-creating-service>`
139+
for this class and :doc:`tag your service </service_container/tags>` with ``twig.runtime``.
182140

183141
.. _`official Twig extensions`: https://github.com/twigphp/Twig-extensions
184142
.. _`Twig extensions documentation`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension

0 commit comments

Comments
 (0)
0