chore: complete update
This commit is contained in:
@@ -4,8 +4,10 @@ namespace App\Framework\View\Processors;
|
||||
|
||||
use App\Framework\View\DomProcessor;
|
||||
use App\Framework\View\DomTemplateParser;
|
||||
use App\Framework\View\DomWrapper;
|
||||
use App\Framework\View\Loading\TemplateLoader;
|
||||
use App\Framework\View\RenderContext;
|
||||
use App\Framework\View\TemplateLoader;
|
||||
use Dom\HTMLDocument;
|
||||
|
||||
final readonly class IncludeProcessor implements DomProcessor
|
||||
{
|
||||
@@ -14,16 +16,14 @@ final readonly class IncludeProcessor implements DomProcessor
|
||||
private DomTemplateParser $parser = new DomTemplateParser()
|
||||
) {}
|
||||
|
||||
public function process(\DOMDocument $dom, RenderContext $context): void
|
||||
public function process(DomWrapper $dom, RenderContext $context): DomWrapper
|
||||
{
|
||||
$xpath = new \DOMXPath($dom);
|
||||
|
||||
foreach ($xpath->query('//include[@file]') as $includeNode) {
|
||||
foreach ($dom->querySelectorAll('include[file]') as $includeNode) {
|
||||
$file = $includeNode->getAttribute('file');
|
||||
|
||||
try {
|
||||
$html = $this->loader->load($file);
|
||||
$includedDom = $this->parser->parse($html);
|
||||
$includedDom = $this->parser->parseFile($html);
|
||||
|
||||
$fragment = $dom->createDocumentFragment();
|
||||
foreach ($includedDom->documentElement->childNodes as $child) {
|
||||
@@ -37,5 +37,7 @@ final readonly class IncludeProcessor implements DomProcessor
|
||||
$includeNode->parentNode?->replaceChild($error, $includeNode);
|
||||
}
|
||||
}
|
||||
|
||||
return $dom;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user