src/Compatibility/ViewHandler.php line 10
<?phpnamespace App\Compatibility;use Parsedown;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Twig\Environment;class ViewHandler{public const PAGE_ATTRIBUTE = 'page';public function __construct(private readonly Environment $twig,private readonly NavigationRepository $navigationRepository,) {}public function __invoke(Request $request): Response{$page = $request->attributes->get(self::PAGE_ATTRIBUTE);if (!$markdown = $this->readMarkdownFile($page)) {return new Response($this->twig->render('404.html.twig'),404);}preg_match('/^# (.+)/', $markdown, $matches);return new Response($this->twig->render('compatibility.html.twig', ['page' => (new Parsedown())->text($markdown),'title' => $matches[1],'navigation' => $this->navigationRepository->getPageGroups(),]));}private function readMarkdownFile(mixed $page): ?string{$filename = __DIR__ . '/markdown/' . $page . '.md';if (!is_readable($filename)) {return null;}return file_get_contents($filename);}}