| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | #[Route('/pages')] |
||
| 15 | class PageController extends AbstractController |
||
| 16 | { |
||
| 17 | public function __construct( |
||
| 18 | private readonly AccessUrlHelper $accessUrlHelper |
||
| 19 | ) {} |
||
| 20 | |||
| 21 | #[Route('/{slug}', name: 'public_page_show', methods: ['GET'])] |
||
| 22 | public function show(string $slug, PageRepository $pageRepo): Response |
||
| 23 | { |
||
| 24 | $accessUrl = $this->accessUrlHelper->getCurrent(); |
||
| 25 | |||
| 26 | $page = $pageRepo->findOneBy([ |
||
| 27 | 'slug' => $slug, |
||
| 28 | 'enabled' => true, |
||
| 29 | 'url' => $accessUrl, |
||
| 30 | ]); |
||
| 31 | |||
| 32 | if (!$page) { |
||
| 33 | throw $this->createNotFoundException('Page not found or not available for this access URL'); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $this->render('@ChamiloCore/Page/show.html.twig', [ |
||
| 37 | 'page' => $page, |
||
| 38 | ]); |
||
| 39 | } |
||
| 40 | |||
| 41 | #[Route('/{id}/preview', name: 'admin_page_preview', methods: ['GET'])] |
||
| 53 | ]); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |