diff --git a/src/Twig/Runtime/SuluRuntime.php b/src/Twig/Runtime/SuluRuntime.php index fbc108d..fffc341 100644 --- a/src/Twig/Runtime/SuluRuntime.php +++ b/src/Twig/Runtime/SuluRuntime.php @@ -64,16 +64,16 @@ public function renderSuluBlocksWithType(array $blocks, string $type, ?string $d public function renderSuluBlockWithType(array $blocks, string $type): string { - $blocks = array_filter($blocks, fn (array $block) => $block['type'] === $type); - if (count($blocks) > 1) { - $blocks = $blocks[0]; + $blocks = array_values(array_filter($blocks, fn (array $block) => $block['type'] === $type)); + + if (0 === count($blocks)) { + return ''; } - $content = ''; + $block = $blocks[0]; - foreach ($blocks as $block) { - $content .= $this->blockRendererStrategy->renderBlock($block); - } + $content = ''; + $content .= $this->blockRendererStrategy->renderBlock($block); return $content; }