2021-08-05 13:51:44 +02:00
|
|
|
<?php
|
|
|
|
|
2022-04-26 14:57:59 +02:00
|
|
|
namespace App\Controller;
|
2021-08-05 13:51:44 +02:00
|
|
|
|
2023-10-13 09:22:40 +02:00
|
|
|
use App\Service\Page;
|
2022-04-26 14:57:59 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2021-08-05 13:51:44 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2023-06-27 12:10:51 +02:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2021-08-05 13:51:44 +02:00
|
|
|
|
2022-04-26 14:57:59 +02:00
|
|
|
class DefaultController extends AbstractController
|
2021-08-05 13:51:44 +02:00
|
|
|
{
|
2023-06-27 12:10:51 +02:00
|
|
|
#[Route('/{slug}', name: 'default', requirements: ['slug' => '[a-zA-Z0-9\/]+'])]
|
2023-10-13 09:22:40 +02:00
|
|
|
public function DefaultAction(Page $page, string $slug = 'index')
|
2021-08-05 13:51:44 +02:00
|
|
|
{
|
2023-10-13 09:22:40 +02:00
|
|
|
$return = $page->getPage($slug);
|
2022-04-26 14:57:59 +02:00
|
|
|
$response = new Response('', (int)$return['status']);
|
2023-03-23 11:32:46 +01:00
|
|
|
return $this->render('/page.html.twig', $return, $response);
|
2021-08-05 13:51:44 +02:00
|
|
|
}
|
2021-08-06 12:30:00 +02:00
|
|
|
|
2023-06-27 12:10:51 +02:00
|
|
|
#[Route('/error/{status}', name: 'error', requirements: ['status' => '[0-9]{3}'], priority: 2)]
|
2023-10-13 09:22:40 +02:00
|
|
|
public function ErrorAction(Page $page, string $status = '404')
|
2021-08-06 12:30:00 +02:00
|
|
|
{
|
2023-10-13 09:22:40 +02:00
|
|
|
$return = $page->getPage('error/' . $status);
|
2022-04-26 14:57:59 +02:00
|
|
|
$response = new Response('', (int)$status);
|
2023-03-23 11:32:46 +01:00
|
|
|
return $this->render('/page.html.twig', $return, $response);
|
2021-08-06 12:30:00 +02:00
|
|
|
}
|
2022-04-26 14:57:59 +02:00
|
|
|
}
|