Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Classes/Fluid/ViewHelper/ComponentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ protected function initializeComponentParams()
protected function extractContentViewHelpers(NodeInterface $node, RenderingContext $renderingContext): array
{
return array_reduce(
$this->extractViewHelpers($node, ContentViewHelper::class),
$this->extractViewHelpers($node, ContentViewHelper::class, false),
function (array $nodes, ViewHelperNode $node) use ($renderingContext) {
$slotArgument = $node->getArguments()['slot'] ?? null;
$slotName = ($slotArgument) ? $slotArgument->evaluate($renderingContext) : self::DEFAULT_SLOT;
Expand All @@ -569,7 +569,7 @@ function (array $nodes, ViewHelperNode $node) use ($renderingContext) {
* @param string $viewHelperClassName
* @return array
*/
protected function extractViewHelpers(NodeInterface $node, string $viewHelperClassName): array
protected function extractViewHelpers(NodeInterface $node, string $viewHelperClassName, bool $recursive = true): array
{
$viewHelperNodes = [];

Expand All @@ -581,9 +581,12 @@ protected function extractViewHelpers(NodeInterface $node, string $viewHelperCla
$viewHelperNodes[] = $node;
} else {
foreach ($node->getChildNodes() as $childNode) {
if ($recursive === false && $childNode instanceof ViewHelperNode && ($childNode->getViewHelperClassName() === ComponentViewHelper::class || $childNode->getUninitializedViewHelper() instanceof ComponentRenderer)) {
continue;
}
$viewHelperNodes = array_merge(
$viewHelperNodes,
$this->extractViewHelpers($childNode, $viewHelperClassName)
$this->extractViewHelpers($childNode, $viewHelperClassName, $recursive)
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions Tests/Functional/SlotParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public function renderDataProvider(): \Generator
'<test:contentSlot><fc:content><b>some html</b></fc:content></test:contentSlot><test:contentSlot><b>other html</b></test:contentSlot>',
"<b>some html</b>\n<b>other html</b>\n"
];
yield 'two nested component calls with named slots' => [
'<test:contentSlot><b>some html</b><test:contentSlot><fc:content><b>other html</b></fc:content></test:contentSlot></test:contentSlot>',
"<b>some html</b><b>other html</b>\n"
];
yield 'two different nested component calls with named slots' => [
'<test:contentSlot><fc:content><b>some html</b><test:twoSlotsAndContent><fc:content slot="slot1"><b>slot 1 html</b></fc:content><fc:content slot="slot2"><b>slot 2 html</b></fc:content>slot content</test:twoSlotsAndContent></fc:content></test:contentSlot>',
"<b>some html</b><b>slot 1 html</b>|<b>slot 2 html</b>|slot content\n"
];

// Check if slot object behaves correct for if statements
yield 'unspecified slot parameter' => [
Expand Down