projectDirectory = $projectDirectory; } /** * @Route(path="/", defaults={"chapter": "README"}, name="help", methods={"GET"}) * @Route(path="/{chapter}", requirements={"chapter": "[a-zA-Z]*"}, name="help_chapter", methods={"GET"}) * * @param string $chapter * @return \Symfony\Component\HttpFoundation\Response */ public function indexAction(string $chapter) { $breadcrumb = [self::README]; if (self::README !== $chapter) { $breadcrumb[] = $chapter; } $chapterFile = $this->getFilenameForChapter($chapter); if (!file_exists($chapterFile)) { throw $this->createNotFoundException('Documentation chapter not found: ' . $chapter); } $content = file_get_contents($chapterFile); return $this->render('help/index.html.twig', [ 'breadcrumb' => $breadcrumb, 'chapter' => $chapter, 'documentation' => $content, 'github' => Constants::GITHUB ]); } /** * @param string $chapter * @return string */ protected function getFilenameForChapter(string $chapter) { return $this->projectDirectory . DIRECTORY_SEPARATOR . self::DOCS_DIR . $chapter . '.md'; } }