Skip to content

Commit b6ea76a

Browse files
authored
Use inline renderer examples, explain problems with ESI rendering
1 parent 80f789b commit b6ea76a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ public function registerBundles()
6363
The easiest way is to add one service for each shortcode in your services definition:
6464

6565
```xml
66-
<service id="webfactory.shortcode.your-shortcode-name" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
66+
<service id="webfactory.shortcode.your-shortcode-name" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
6767
<argument index="1">reference-to-your-replacement-controller</argument>
6868
<tag name="webfactory.shortcode" shortcode="your-shortcode-name"/>
6969
</service>
7070
```
7171

72-
The parent ```Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi``` will use [ESI rendering](https://symfony.com/doc/current/http_cache/esi.html)
73-
(which may be nice for caching), while the parent ```Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline``` will use
74-
inline rendering.
72+
The parent ```Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline``` will use
73+
inline rendering while the parent ```Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi``` will use [ESI rendering](https://symfony.com/doc/current/http_cache/esi.html).
74+
75+
ESI may be nice for caching but comes with a problem: ESI embeds controller actions by calling a special internal `_fragment`-URL and needs to somehow serialize all parameters for an action in this URL. This works well for scalar values but neither for objects nor arrays of scalar values. But for context sensitive shortcodes, we pass the request attributes to the embedded controller action. And these request attributes might contain objects, e.g. the result object of a ParamConverter. This can lead to hard to debug errors, especially when recursion comes into play.
76+
77+
Also, logging needs more configuration (explained in the Logging section) with ESI.
7578

7679
The ```reference-to-your-replacement-controller``` could be a string like ```AppBundle\Controller\EmbeddedImageController::showAction```
7780
or if use controllers as services, something like ```AppBundle\Controller\EmbeddedImageController:showAction```. We recommend
@@ -102,7 +105,7 @@ Then, write a service definition like this:
102105

103106
<!-- ... -->
104107

105-
<service id="webfactory.shortcode.image" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
108+
<service id="webfactory.shortcode.image" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
106109
<argument index="1">AppBundle\Controller\EmbeddedImageController:showAction</argument>
107110
<tag name="webfactory.shortcode" shortcode="image"/>
108111
</service>
@@ -199,7 +202,7 @@ Finally, enrich your shortcode tags with description and example attributes for
199202
<!-- import guide.xml -->
200203

201204
<services>
202-
<service id="webfactory.shortcode.image" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.esi" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
205+
<service id="webfactory.shortcode.image" parent="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler.inline" class="Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler">
203206
<argument index="1">AppBundle\Controller\EmbeddedImageController:showAction</argument>
204207
<tag
205208
name="webfactory.shortcode"

0 commit comments

Comments
 (0)