10000 Merge remote-tracking branch 'upstream/6.2' into 6.2 · symfony/symfony-docs@c690164 · GitHub
[go: up one dir, main page]

Skip to content

Commit c690164

Browse files
committed
Merge remote-tracking branch 'upstream/6.2' into 6.2
* upstream/6.2: [Twig] Update the docs of the twig.debug option [HttpCache] Explain how to extend the HttpCache class
2 parents 2ebdecc + 9d1de6d commit c690164

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

http_cache/cache_invalidation.rst

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ the word "PURGE" is a convention, technically this can be any string) instead
4747
of ``GET`` and make the cache proxy detect this and remove the data from the
4848
cache instead of going to the application to get a response.
4949

50-
Here is how you can configure the Symfony reverse proxy (See :doc:`/http_cache`)
51-
to support the ``PURGE`` HTTP method::
50+
Here is how you can configure the :ref:`Symfony reverse proxy <symfony-gateway-cache>`
51+
to support the ``PURGE`` HTTP method. First create a caching kernel that overrides the
52+
:method:`Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache::invalidate` method::
5253

5354
// src/CacheKernel.php
5455
namespace App;
@@ -84,6 +85,58 @@ to support the ``PURGE`` HTTP method::
8485
}
8586
}
8687

88+
Then, register the class as a service that :doc:`decorates </service_container/service_decoration>`
89+
``http_cache``::
90+
91+
.. configuration-block::
92+
93+
.. code-block:: yaml
94+
95+
# config/services.yaml
96+
services:
97+
App\CacheKernel:
98+
decorates: http_cache
99+
arguments:
100+
- '@kernel'
101+
- '@http_cache.store'
102+
- '@?esi'
103+
104+
.. code-block:: xml
105+
106+
<!-- config/services.xml -->
107+
<?xml version="1.0" encoding="UTF-8" ?>
108+
<container xmlns="http://symfony.com/schema/dic/services"
109+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
110+
xsi:schemaLocation="http://symfony.com/schema/dic/services
111+
https://symfony.com/schema/dic/services/services-1.0.xsd"
112+
>
113+
<service id="App\CacheKernel" decorates="http_cache">
114+
<argument type="service" id="kernel"/>
115+
<argument type="service" id="http_cache.store"/>
116+
<argument type="service" id="esi" on-invalid="null"/>
117+
</service>
118+
</container>
119+
120+
.. code-block:: php
121+
122+
// config/services.php
123+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
124+
125+
use App\CacheKernel;
126+
127+
return function (ContainerConfigurator $containerConfigurator) {
128+
$services = $containerConfigurator->services();
129+
130+
$services->set(CacheKernel::class)
131+
->decorate('http_cache')
132+
->args([
133+
service('kernel'),
134+
service('http_cache.store'),
135+
service('esi')->nullOnInvalid(),
136+
])
137+
;
138+
};
139+
87140
.. caution::
88141

89142
You must protect the ``PURGE`` HTTP method somehow to avoid random people

reference/configuration/twig.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ debug
160160
If ``true``, the compiled templates include a ``__toString()`` method that can
161161
be used to display their nodes.
162162

163+
This option also controls the behavior of :ref:`the Twig dump utilities <twig-dump-utilities>`.
164+
If this option is ``false``, the ``dump()`` function doesn't output any contents.
165+
163166
.. _config-twig-default-path:
164167

165168
default_path

templates.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,8 @@ and also to check the Twig features added when :ref:`installing packages <symfon
818818
# pass a template path to show the physical file which will be loaded
819819
$ php bin/console debug:twig @Twig/Exception/error.html.twig
820820
821+
.. _twig-dump-utilities:
822+
821823
The Dump Twig Utilities
822824
~~~~~~~~~~~~~~~~~~~~~~~
823825

0 commit comments

Comments
 (0)
0