Extract duplicated slug regex into SLUG_PATTERN constant in HomeController
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
private const SLUG_PATTERN = '[a-z0-9-]+';
|
||||
private const BREADCRUMB_HOME = ['name' => 'Accueil', 'url' => '/'];
|
||||
private const BREADCRUMB_ORGANIZERS = ['name' => 'Organisateurs', 'url' => '/organisateurs'];
|
||||
|
||||
@@ -123,7 +124,7 @@ class HomeController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/organisateur/{id}-{slug}', name: 'app_organizer_detail', requirements: ['id' => '\d+', 'slug' => '[a-z0-9-]+'])]
|
||||
#[Route('/organisateur/{id}-{slug}', name: 'app_organizer_detail', requirements: ['id' => '\d+', 'slug' => self::SLUG_PATTERN])]
|
||||
public function organizerDetail(int $id, string $slug, EntityManagerInterface $em): Response
|
||||
{
|
||||
$organizer = $em->getRepository(User::class)->find($id);
|
||||
@@ -155,7 +156,7 @@ class HomeController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/evenement/{orgaSlug}/{id}-{eventSlug}', name: 'app_event_detail', requirements: ['id' => '\d+', 'orgaSlug' => '[a-z0-9-]+', 'eventSlug' => '[a-z0-9-]+'])]
|
||||
#[Route('/evenement/{orgaSlug}/{id}-{eventSlug}', name: 'app_event_detail', requirements: ['id' => '\d+', 'orgaSlug' => self::SLUG_PATTERN, 'eventSlug' => self::SLUG_PATTERN])]
|
||||
public function eventDetail(int $id, string $orgaSlug, string $eventSlug, EntityManagerInterface $em): Response
|
||||
{
|
||||
$event = $em->getRepository(Event::class)->find($id);
|
||||
|
||||
Reference in New Issue
Block a user