mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
Event: add more fields: documents, organizationCost, note, and location
This commit is contained in:
@@ -17,6 +17,7 @@ use Chill\EventBundle\Form\EventType;
|
||||
use Chill\EventBundle\Form\Type\PickEventType;
|
||||
use Chill\EventBundle\Security\Authorization\EventVoter;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@@ -37,6 +38,8 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
@@ -52,7 +55,8 @@ final class EventController extends AbstractController
|
||||
private readonly AuthorizationHelperInterface $authorizationHelper,
|
||||
private readonly FormFactoryInterface $formFactoryInterface,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly PaginatorFactory $paginator
|
||||
private readonly PaginatorFactory $paginator,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -202,6 +206,12 @@ final class EventController extends AbstractController
|
||||
*/
|
||||
public function newAction(?Center $center, Request $request)
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException('not a regular user. Maybe an administrator ?');
|
||||
}
|
||||
|
||||
if (null === $center) {
|
||||
$center_id = $request->query->get('center_id');
|
||||
$center = $this->getDoctrine()->getRepository(Center::class)->find($center_id);
|
||||
@@ -209,6 +219,7 @@ final class EventController extends AbstractController
|
||||
|
||||
$entity = new Event();
|
||||
$entity->setCenter($center);
|
||||
$entity->setLocation($user->getCurrentLocation());
|
||||
|
||||
$form = $this->createCreateForm($entity);
|
||||
$form->handleRequest($request);
|
||||
@@ -336,7 +347,7 @@ final class EventController extends AbstractController
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The event was updated'));
|
||||
|
||||
return $this->redirectToRoute('chill_event__event_edit', ['event_id' => $event_id]);
|
||||
return $this->redirectToRoute('chill_event__event_show', ['event_id' => $event_id]);
|
||||
}
|
||||
|
||||
return $this->render('@ChillEvent/Event/edit.html.twig', [
|
||||
|
Reference in New Issue
Block a user