environment = $environment; $this->tocNode = $tocNode; $this->templateRenderer = $templateRenderer; } public function render(): string { $tocItems = []; foreach ($this->tocNode->getFiles() as $file) { $reference = $this->environment->resolve('doc', $file); if ($reference === null) { continue; } $url = $this->environment->relativeUrl($reference->getUrl()); $tocItems[] = ['url' => $url]; } return $this->templateRenderer->render('toc.tex.twig', [ 'tocNode' => $this->tocNode, 'tocItems' => $tocItems, ]); } }