- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
100 lines
3.5 KiB
PHP
100 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\View;
|
|
|
|
use App\Framework\Cache\Cache;
|
|
use App\Framework\Core\PathProvider;
|
|
use App\Framework\DI\DefaultContainer;
|
|
use App\Framework\DI\Initializer;
|
|
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
|
use App\Framework\Performance\PerformanceService;
|
|
use App\Framework\Template\Processing\DomProcessor;
|
|
use App\Framework\Template\Processing\StringProcessor;
|
|
use App\Framework\View\Loading\TemplateLoader;
|
|
use App\Framework\View\Processors\AssetInjector;
|
|
use App\Framework\View\Processors\CommentStripProcessor;
|
|
use App\Framework\View\Processors\ComponentProcessor;
|
|
use App\Framework\View\Processors\FormProcessor;
|
|
use App\Framework\View\Processors\ForProcessor;
|
|
use App\Framework\View\Processors\HoneypotProcessor;
|
|
use App\Framework\View\Processors\IfProcessor;
|
|
use App\Framework\View\Processors\LayoutTagProcessor;
|
|
use App\Framework\View\Processors\MetaManipulator;
|
|
use App\Framework\View\Processors\PlaceholderReplacer;
|
|
use App\Framework\View\Processors\RemoveEmptyLinesProcessor;
|
|
use App\Framework\View\Processors\VoidElementsSelfClosingProcessor;
|
|
|
|
final readonly class TemplateRendererInitializer
|
|
{
|
|
public function __construct(
|
|
private DefaultContainer $container,
|
|
#private FileScanner $scanner,
|
|
#private PathProvider $pathProvider,
|
|
private DiscoveryRegistry $results,
|
|
) {
|
|
}
|
|
|
|
#[Initializer]
|
|
public function __invoke(): TemplateRenderer
|
|
{
|
|
$doms = [
|
|
ComponentProcessor::class,
|
|
LayoutTagProcessor::class,
|
|
MetaManipulator::class,
|
|
IfProcessor::class,
|
|
ForProcessor::class,
|
|
AssetInjector::class,
|
|
CommentStripProcessor::class,
|
|
RemoveEmptyLinesProcessor::class,
|
|
FormProcessor::class,
|
|
HoneypotProcessor::class,
|
|
];
|
|
|
|
$strings = [
|
|
PlaceholderReplacer::class,
|
|
#SingleLineHtmlProcessor::class,
|
|
VoidElementsSelfClosingProcessor::class,
|
|
# CsrfReplaceProcessor::class, // DEACTIVATED - FormDataResponseMiddleware handles form processing
|
|
];
|
|
|
|
$domImplementations = [];
|
|
foreach ($this->results->interfaces->get(DomProcessor::class) as $className) {
|
|
$domImplementations[] = $className->getFullyQualified();
|
|
}
|
|
|
|
$stringImplementations = [];
|
|
foreach ($this->results->interfaces->get(StringProcessor::class) as $className) {
|
|
$stringImplementations[] = $className->getFullyQualified();
|
|
}
|
|
|
|
$templateProcessor = new TemplateProcessor(
|
|
[ComponentProcessor::class, ...$domImplementations],
|
|
$stringImplementations,
|
|
$this->container,
|
|
);
|
|
|
|
$templateProcessor = new TemplateProcessor($doms, $strings, $this->container);
|
|
|
|
$this->container->singleton(TemplateProcessor::class, $templateProcessor);
|
|
|
|
$pathProvider = $this->container->get(PathProvider::class);
|
|
$cache = $this->container->get(Cache::class);
|
|
$performanceService = $this->container->get(PerformanceService::class);
|
|
|
|
$loader = new TemplateLoader(pathProvider: $pathProvider, cache: $cache, discoveryRegistry: $this->results/*, templates: $templates*/);
|
|
|
|
$this->container->singleton(TemplateLoader::class, $loader);
|
|
|
|
return new Engine(
|
|
$loader,
|
|
$pathProvider,
|
|
$performanceService,
|
|
processor: $templateProcessor,
|
|
container: $this->container,
|
|
cache: $cache,
|
|
);
|
|
}
|
|
}
|