Skip to content

Commit 3da0776

Browse files
committed
minor #4338 ESI Variable Details Continuation (Farkie, weaverryan)
This PR was merged into the 2.3 branch. Discussion ---------- ESI Variable Details Continuation This continues #4098. | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | 2.3+ | Fixed tickets | n/a Thanks! Commits ------- ded7577 Clarifying a bit more that you're passing variables into your controller 5877d02 Update http_cache.rst
2 parents e8964f4 + ded7577 commit 3da0776

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: book/http_cache.rst

+12-5
Original file line numberDiff line numberDiff line change
@@ -915,20 +915,20 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
915915
.. code-block:: jinja
916916
917917
{# you can use a controller reference #}
918-
{{ render_esi(controller('...:news', { 'max': 5 })) }}
918+
{{ render_esi(controller('...:news', { 'maxPerPage': 5 })) }}
919919
920920
{# ... or a URL #}
921-
{{ render_esi(url('latest_news', { 'max': 5 })) }}
921+
{{ render_esi(url('latest_news', { 'maxPerPage': 5 })) }}
922922
923923
.. code-block:: html+php
924924

925925
<?php echo $view['actions']->render(
926-
new \Symfony\Component\HttpKernel\Controller\ControllerReference('...:news', array('max' => 5)),
926+
new \Symfony\Component\HttpKernel\Controller\ControllerReference('...:news', array('maxPerPage' => 5)),
927927
array('strategy' => 'esi'))
928928
?>
929929

930930
<?php echo $view['actions']->render(
931-
$view['router']->generate('latest_news', array('max' => 5), true),
931+
$view['router']->generate('latest_news', array('maxPerPage' => 5), true),
932932
array('strategy' => 'esi'),
933933
) ?>
934934

@@ -938,6 +938,13 @@ wondering why you would want to use a helper instead of just writing the ESI
938938
tag yourself. That's because using a helper makes your application work even
939939
if there is no gateway cache installed.
940940

941+
.. tip::
942+
943+
As you'll see below, the ``maxPerPage`` variable you pass is available
944+
as an argument to your controller (i.e. ``$maxPerPage``). The variables
945+
passed through ``render_esi`` also become part of the cache key so that
946+
you have unique caches for each combination of variables and values.
947+
941948
When using the default ``render`` function (or setting the renderer to
942949
``inline``), Symfony merges the included page content into the main one
943950
before sending the response to the client. But if you use the ``esi`` renderer
@@ -958,7 +965,7 @@ of the master page.
958965

959966
.. code-block:: php
960967
961-
public function newsAction($max)
968+
public function newsAction($maxPerPage)
962969
{
963970
// ...
964971

0 commit comments

Comments
 (0)