Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8f9334

Browse filesBrowse 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
Copy full SHA for e8f9334

File tree

Expand file treeCollapse file tree

1 file changed

+3
-45
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-45
lines changed

‎templating/twig_extension.rst

Copy file name to clipboardExpand all lines: templating/twig_extension.rst
+3-45Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.