Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
PagesController | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
display | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\Controller; |
4 | |
5 | use App\Entity\Pages; |
6 | use App\Repository\PagesRepository; |
7 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
8 | use Symfony\Component\HttpFoundation\Response; |
9 | use Symfony\Component\Routing\Annotation\Route; |
10 | |
11 | class 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 | } |