@@ -33,10 +33,10 @@ class EmbeddedShortcodeHandler
3333
3434 /**
3535 * @param FragmentHandler $fragmentHandler
36- * @param string $controllerName
37- * @param string $renderer
36+ * @param string $controllerName
37+ * @param string $renderer
3838 * @param LoggerInterface $logger
39- * @param RequestStack $requestStack
39+ * @param RequestStack $requestStack
4040 */
4141 public function __construct (
4242 FragmentHandler $ fragmentHandler ,
@@ -70,12 +70,31 @@ public function __invoke(ShortcodeInterface $shortcode)
7070 ]
7171 );
7272
73- return $ this ->fragmentHandler ->render (
74- new ControllerReference (
75- $ this ->controllerName ,
76- array_merge (['request ' => $ this ->requestStack ->getCurrentRequest ()], $ shortcode ->getParameters ())
77- ),
78- $ this ->renderer
79- );
73+ try {
74+ return $ this ->fragmentHandler ->render (
75+ new ControllerReference (
76+ $ this ->controllerName ,
77+ array_merge (['request ' => $ this ->requestStack ->getCurrentRequest ()], $ shortcode ->getParameters ())
78+ ),
79+ $ this ->renderer
80+ );
81+ } catch (\InvalidArgumentException $ exception ) {
82+ if ($ this ->renderer === 'esi ' ) {
83+ throw new \InvalidArgumentException (
84+ 'An InvalidArgumentException occured while trying to render the shortcode '
85+ .$ shortcode ->getShortcodeText ().'. You \'ve probably tried to use the ESI rendering strategy for '
86+ .'your shortcodes while handling a request that contained non-scalar values as part of URI '
87+ .'attributes. This can happen e.g. when using Param Converters for your original controller '
88+ .'action, as the request (containing the conversion result) is automatically passed to the call of '
89+ .'the shortcode controller to allow context sensitive shortcodes. You could use '
90+ .'webfactory.shortcode.embed_inline_for_shortcode_handler as parent in your shortcode \'s service '
91+ .'defintion, so that the inline instead of ESI rendering strategy will be used. ' ,
92+ 0 ,
93+ $ exception
94+ );
95+ }
96+
97+ throw $ exception ;
98+ }
8099 }
81100}
0 commit comments