|null $blocks gespeicherte Bausteine (Altformat oder Hülle) */ public function renderAll(?array $blocks, RenderContext $context): HtmlString { $html = ''; $position = 0; foreach (array_values($blocks ?? []) as $block) { if (! is_array($block)) { continue; } $widget = $this->registry->upcast($block); if ($widget === null) { if ($context->preview) { $html .= '

Unbekannter Baustein „'.e((string) ($block['type'] ?? '')).'“ wird öffentlich nicht angezeigt.

'; } continue; } $rendered = $this->renderWidget($widget, $context, $position === 0); if ($rendered !== '') { $html .= $rendered; $position++; } } return new HtmlString($html); } /** * Rendert eine Instanz samt Abschnittshülle. Liefert '' wenn das Widget nichts darzustellen hat. * * @param array $widget aktuelle Hülle */ public function renderWidget(array $widget, RenderContext $context, bool $first = false): string { $type = $this->registry->get($widget['type']); $inner = trim(view($type->view(), [ 'widget' => $widget, 'data' => $widget['data'], 'refs' => $widget['refs'], 'variant' => $widget['variant'], 'settings' => $widget['settings'], 'height' => $type->height($widget), 'first' => $first, 'context' => $context, ] + $type->resolve($widget, $context))->render()); if ($inner === '') { return ''; } $id = is_string($widget['id'] ?? null) ? ' id="abschnitt-'.e($widget['id']).'"' : ''; // Gemeinsamer Layoutvertrag (ADR-38): Höhe als Klasse an der Hülle, nur wenn die Art Höhen anbietet. $height = $type->height($widget); $heightClass = $height !== null ? ' widget-height-'.e($height) : ''; return '
' .$inner .'
'; } }