Skip to content

Commit

Permalink
minor #4338 ESI Variable Details Continuation (Farkie, weaverryan)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weaverryan committed Oct 19, 2014
2 parents e8964f4 + ded7577 commit 3da0776
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -915,20 +915,20 @@ matter), Symfony uses the standard ``render`` helper to configure ESI tags:
.. code-block:: jinja
{# you can use a controller reference #}
{{ render_esi(controller('...:news', { 'max': 5 })) }}
{{ render_esi(controller('...:news', { 'maxPerPage': 5 })) }}
{# ... or a URL #}
{{ render_esi(url('latest_news', { 'max': 5 })) }}
{{ render_esi(url('latest_news', { 'maxPerPage': 5 })) }}
.. code-block:: html+php

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

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

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

.. tip::

As you'll see below, the ``maxPerPage`` variable you pass is available
as an argument to your controller (i.e. ``$maxPerPage``). The variables
passed through ``render_esi`` also become part of the cache key so that
you have unique caches for each combination of variables and values.

When using the default ``render`` function (or setting the renderer to
``inline``), Symfony merges the included page content into the main one
before sending the response to the client. But if you use the ``esi`` renderer
Expand All @@ -958,7 +965,7 @@ of the master page.

.. code-block:: php
public function newsAction($max)
public function newsAction($maxPerPage)
{
// ...
Expand Down

0 comments on commit 3da0776

Please sign in to comment.