mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-03-24 17:22:06 +01:00
34 lines
832 B
PHP
34 lines
832 B
PHP
<?php
|
|
|
|
|
|
namespace AppBundle\Controller;
|
|
|
|
use AppBundle\Event\Model\Event;
|
|
use AppBundle\Event\Model\Repository\EventRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
abstract class EventBaseController extends Controller
|
|
{
|
|
/**
|
|
* @param $eventSlug
|
|
* @return Event
|
|
*
|
|
* @throws NotFoundHttpException
|
|
*/
|
|
protected function checkEventSlug($eventSlug)
|
|
{
|
|
/**
|
|
* @var $eventRepository EventRepository
|
|
*/
|
|
$eventRepository = $this->get('ting')->get(EventRepository::class);
|
|
$event = $eventRepository->getOneBy(['path' => $eventSlug]);
|
|
|
|
if ($event === null) {
|
|
throw $this->createNotFoundException('Event not found');
|
|
}
|
|
|
|
return $event;
|
|
}
|
|
}
|