Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
PagesController
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 display
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace App\Controller;
4
5use App\Entity\Pages;
6use App\Repository\PagesRepository;
7use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8use Symfony\Component\HttpFoundation\Response;
9use Symfony\Component\Routing\Annotation\Route;
10
11class PagesController extends AbstractController
12{
13    #[Route(path: '/pages/{slug}', name: 'pages_display')]
14    public function display(PagesRepository $pagesRepository, string $slug): Response
15    {
16        $page = $pagesRepository->findOneBy(criteria: [
17            'slug' => $slug,
18        ]);
19
20        if (!$page) {
21            $page = new Pages();
22            $page->setName(name: 'Not Found');
23            $page->setContent(content: '404 - The requested page was not found.');
24        }
25
26        return $this->render(view: '@default/pages/index.html.twig', parameters: [
27            'page' => $page,
28        ]);
29    }
30}