Skip to content

Commit 0d5df29

Browse files
committed
Pass embedding request to the shortcode rendering controller
Traditionally, you have self-contained shortcodes that carry all information necessary to render them as parameters. But sometimes, the information is in the context of the embedding entity. E.g. if you want to embed a list of the child nodes of the current node in a tree, it's more comfortable to use a short code like [children] than [children id-of-current-node]. By passing the embedding request to the shortcode rendering controllers, we allow them to become context sensitive.
1 parent 831def6 commit 0d5df29

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Handler/EmbeddedShortcodeHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function __invoke(ShortcodeInterface $shortcode)
7171
);
7272

7373
return $this->fragmentHandler->render(
74-
new ControllerReference($this->controllerName, $shortcode->getParameters()),
74+
new ControllerReference(
75+
$this->controllerName,
76+
array_merge(['request' => $this->requestStack->getCurrentRequest()], $shortcode->getParameters())
77+
),
7578
$this->renderer
7679
);
7780
}

0 commit comments

Comments
 (0)