From 83ac942bbd4da671f48b56f4639df37659782282 Mon Sep 17 00:00:00 2001 From: Audrey Jensen Date: Thu, 29 Jun 2023 19:00:54 +0000 Subject: [PATCH] route to safety topic pages --- src/Controller/SafetyController.php | 29 ++++++++++++++++++- .../Training/Safety/safetyHome.html.twig | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Controller/SafetyController.php b/src/Controller/SafetyController.php index 524d299..1ff48af 100644 --- a/src/Controller/SafetyController.php +++ b/src/Controller/SafetyController.php @@ -10,9 +10,11 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Psr\Log\LoggerInterface; +use function PHPUnit\Framework\containsIdentical; + class SafetyController extends AbstractController { - #[Route('/training/safety')] + #[Route('/training/safety', name: 'safetyHome')] public function Index() : Response { $headerFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); @@ -46,4 +48,29 @@ class SafetyController extends AbstractController } return $this->render('Training/Safety/SafetyQuiz.html.twig',['header' => $headerFile, 'quiz'=>$form]); } + #[Route('/Training/Safety/Topics/{topic?}')] + public function Topics(?string $topic) : Response + { + //We want to show the safety homepage if this is blank + if($topic == null) + { + return $this->redirectToRoute('safetyHome'); + } + $headerFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); + $topicsFile = Yaml::parseFile('../config/safetyLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); + $topic = strtolower($topic); + return $this->render('Training/Safety/Topics/'.$topic.".html.twig", ['headerFile'=> $headerFile]); + /* //Scan through each link file If we see what we need, then let's get it. + foreach($topicsFile['Cards'] as $card) + { + foreach($card as $item) + { + if($item['url']== $topic) + { + return $this->render('Training/Safety/Topics/'.$topic.".html.twig", ['headerFile'=> $headerFile]); + } + } + + } */ + } } \ No newline at end of file diff --git a/templates/Training/Safety/safetyHome.html.twig b/templates/Training/Safety/safetyHome.html.twig index 75cdd3f..b68947f 100644 --- a/templates/Training/Safety/safetyHome.html.twig +++ b/templates/Training/Safety/safetyHome.html.twig @@ -37,7 +37,7 @@