route to safety topic pages

This commit is contained in:
Audrey Jensen 2023-06-29 19:00:54 +00:00
parent 511975b8cd
commit 83ac942bbd
2 changed files with 29 additions and 2 deletions

View File

@ -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]);
}
}
} */
}
}

View File

@ -37,7 +37,7 @@
<div class="card-text">
<ul class="list-group list-group-flush">
{% for link in links %}
<a class="list-group-item list-group-item-action list-item" href="{{link.url}}">{{link.title}}</a>
<a class="list-group-item list-group-item-action list-item" href="/Training/Safety/Topics/{{link.url}}">{{link.title}}</a>
{% endfor %}
</ul>
</div>