chore: lots of changes

This commit is contained in:
2025-05-24 07:09:22 +02:00
parent 77ee769d5e
commit 899227b0a4
178 changed files with 5145 additions and 53 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Framework\View\Processors;
use App\Framework\View\DomProcessor;
use App\Framework\View\RenderContext;
/*
<component name="card">
<slot name="header">Default Header</slot>
<slot>Main Content</slot>
</component>
*/
final readonly class SlotProcessor implements DomProcessor
{
public function process(\DOMDocument $dom, RenderContext $context): void
{
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//slot[@name]') as $slotNode) {
$slotName = $slotNode->getAttribute('name');
$html = $context->slots[$slotName] ?? null;
$replacement = $dom->createDocumentFragment();
if ($html !== null) {
@$replacement->appendXML($html);
} else {
// Fallback-Inhalt erhalten (die inneren Nodes des slot-Tags)
foreach ($slotNode->childNodes as $child) {
$replacement->appendChild($child->cloneNode(true));
}
}
$slotNode->parentNode?->replaceChild($replacement, $slotNode);
}
}
}