<?php
namespace App\Controller;
use App\Entity\Page;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class PageController extends AbstractController
{
#[Route(path: '/{slug}', name: 'custom_page_show', priority: -200)]
public function showAction(string $slug, Request $request, ManagerRegistry $managerRegistry): Response
{
$company = $request->get('companyInner');
$page = $managerRegistry->getRepository(Page::class)->getOneActiveBySlugAndCompany($slug, $company);
if (!$page) {
throw $this->createNotFoundException('Page not found');
}
return $this->render('pages/custom_page/custom_page.html.twig', [
'customPage' => $page,
'metaInfo' => $page,
]);
}
}