mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
disable csrf_protection on first step new event form
This commit is contained in:
parent
2ff22a73fa
commit
b2b6cb6d6a
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* Chill is a software for social workers
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS,
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -36,7 +36,6 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Chill\EventBundle\Form\Type\PickCenterType;
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
@ -62,11 +61,13 @@ class EventController extends Controller
|
|||||||
* @var FormFactoryInterface
|
* @var FormFactoryInterface
|
||||||
*/
|
*/
|
||||||
protected $formFactoryInterface;
|
protected $formFactoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EventController constructor.
|
* EventController constructor.
|
||||||
*
|
*
|
||||||
* @param EventDispatcherInterface $eventDispatcher
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
|
* @param AuthorizationHelper $authorizationHelper
|
||||||
|
* @param FormFactoryInterface $formFactoryInterface
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
@ -95,7 +96,9 @@ class EventController extends Controller
|
|||||||
{
|
{
|
||||||
$role = new Role('CHILL_EVENT_CREATE');
|
$role = new Role('CHILL_EVENT_CREATE');
|
||||||
|
|
||||||
/** @var Center $centers */
|
/**
|
||||||
|
* @var Center $centers
|
||||||
|
*/
|
||||||
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role);
|
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(), $role);
|
||||||
|
|
||||||
if (count($centers) === 1)
|
if (count($centers) === 1)
|
||||||
@ -106,7 +109,9 @@ class EventController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->formFactoryInterface
|
$form = $this->formFactoryInterface
|
||||||
->createNamedBuilder(null)
|
->createNamedBuilder(null, FormType::class, null, array(
|
||||||
|
'csrf_protection' => false
|
||||||
|
))
|
||||||
->setMethod('GET')
|
->setMethod('GET')
|
||||||
->setAction(
|
->setAction(
|
||||||
$this->generateUrl('chill_event__event_new'))
|
$this->generateUrl('chill_event__event_new'))
|
||||||
@ -114,8 +119,7 @@ class EventController extends Controller
|
|||||||
'class' => Center::class,
|
'class' => Center::class,
|
||||||
'choices' => $centers,
|
'choices' => $centers,
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'label' => 'To which centre should the event be associated ?',
|
'label' => 'To which centre should the event be associated ?'
|
||||||
'csrf_protection' => false // works ?!
|
|
||||||
))
|
))
|
||||||
->add('submit', SubmitType::class, array(
|
->add('submit', SubmitType::class, array(
|
||||||
'label' => 'Next step'
|
'label' => 'Next step'
|
||||||
@ -132,8 +136,7 @@ class EventController extends Controller
|
|||||||
* Creates a form to create a Event entity.
|
* Creates a form to create a Event entity.
|
||||||
*
|
*
|
||||||
* @param Event $entity The entity
|
* @param Event $entity The entity
|
||||||
*
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
*/
|
||||||
private function createCreateForm(Event $entity)
|
private function createCreateForm(Event $entity)
|
||||||
{
|
{
|
||||||
@ -188,13 +191,15 @@ class EventController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Finds and displays a Event entity.
|
* Finds and displays a Event entity.
|
||||||
*
|
*
|
||||||
|
* @param $event_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function showAction($event_id)
|
public function showAction($event_id)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
|
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Event entity.');
|
throw $this->createNotFoundException('Unable to find Event entity.');
|
||||||
}
|
}
|
||||||
@ -212,7 +217,8 @@ class EventController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* create a form to add a participation with a person
|
* create a form to add a participation with a person
|
||||||
*
|
*
|
||||||
|
* @param Event $event
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
protected function createAddParticipationByPersonForm(Event $event)
|
protected function createAddParticipationByPersonForm(Event $event)
|
||||||
@ -251,6 +257,8 @@ class EventController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing Event entity.
|
* Displays a form to edit an existing Event entity.
|
||||||
*
|
*
|
||||||
|
* @param $event_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function editAction($event_id)
|
public function editAction($event_id)
|
||||||
{
|
{
|
||||||
@ -271,12 +279,11 @@ class EventController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to edit a Event entity.
|
* Creates a form to edit a Event entity.
|
||||||
*
|
*
|
||||||
* @param Event $entity The entity
|
* @param Event $entity
|
||||||
*
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
* @return \Symfony\Component\Form\Form The form
|
*/
|
||||||
*/
|
|
||||||
private function createEditForm(Event $entity)
|
private function createEditForm(Event $entity)
|
||||||
{
|
{
|
||||||
$form = $this->createForm(EventType::class, $entity, array(
|
$form = $this->createForm(EventType::class, $entity, array(
|
||||||
@ -292,9 +299,13 @@ class EventController extends Controller
|
|||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing Event entity.
|
* Edits an existing Event entity.
|
||||||
*
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param $event_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, $event_id)
|
public function updateAction(Request $request, $event_id)
|
||||||
{
|
{
|
||||||
@ -326,7 +337,9 @@ class EventController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List events subscriptions for a person
|
* List events subscriptions for a person
|
||||||
|
*
|
||||||
* @param $person_id
|
* @param $person_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function listByPersonAction($person_id)
|
public function listByPersonAction($person_id)
|
||||||
{
|
{
|
||||||
@ -356,7 +369,9 @@ class EventController extends Controller
|
|||||||
->setParameter(':person_id', $person_id)
|
->setParameter(':person_id', $person_id)
|
||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
|
|
||||||
/* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */
|
/**
|
||||||
|
* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory
|
||||||
|
*/
|
||||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||||
$paginator = $paginatorFactory->create($total);
|
$paginator = $paginatorFactory->create($total);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user