mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
new participation: add optional return_path to POST request
This commit is contained in:
parent
bd19110ecd
commit
8c3c9c4a1f
@ -171,10 +171,11 @@ class EventController extends Controller
|
|||||||
$entity = new Event();
|
$entity = new Event();
|
||||||
$entity->setCenter($center);
|
$entity->setCenter($center);
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity);
|
$form = $this->createCreateForm($entity);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid())
|
||||||
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
@ -425,7 +426,14 @@ class EventController extends Controller
|
|||||||
$builder->add('person_id', HiddenType::class, array(
|
$builder->add('person_id', HiddenType::class, array(
|
||||||
'data' => $person->getId()
|
'data' => $person->getId()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$builder->add('return_path', HiddenType::class, array(
|
||||||
|
'data' => $this->generateUrl('chill_event__list_by_person', array(
|
||||||
|
'person_id' => $person->getId()
|
||||||
|
))
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
$builder->add('submit', SubmitType::class,
|
$builder->add('submit', SubmitType::class,
|
||||||
array(
|
array(
|
||||||
'label' => 'Subscribe an event'
|
'label' => 'Subscribe an event'
|
||||||
|
@ -35,6 +35,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
|||||||
*/
|
*/
|
||||||
class ParticipationController extends Controller
|
class ParticipationController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a form to add a participation
|
* Show a form to add a participation
|
||||||
*
|
*
|
||||||
@ -43,9 +44,12 @@ class ParticipationController extends Controller
|
|||||||
* on this, the appropriate layout and form.
|
* on this, the appropriate layout and form.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function newAction(Request $request)
|
public function newAction(Request $request)
|
||||||
{
|
{
|
||||||
|
dump('coucou');
|
||||||
|
|
||||||
// test the request is correct
|
// test the request is correct
|
||||||
try {
|
try {
|
||||||
$this->testRequest($request);
|
$this->testRequest($request);
|
||||||
@ -123,12 +127,16 @@ class ParticipationController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function newSingle(Request $request)
|
protected function newSingle(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$returnPath = $request->query->get('return_path') ?
|
||||||
|
$request->query->get('return_path') : null;
|
||||||
|
|
||||||
$participation = $this->handleRequest($request, new Participation(), false);
|
$participation = $this->handleRequest($request, new Participation(), false);
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(ParticipationVoter::CREATE,
|
$this->denyAccessUnlessGranted(ParticipationVoter::CREATE,
|
||||||
$participation, 'The user is not allowed to create this participation');
|
$participation, 'The user is not allowed to create this participation');
|
||||||
|
|
||||||
$form = $this->createCreateForm($participation);
|
$form = $this->createCreateForm($participation, $returnPath);
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Participation:new.html.twig', array(
|
return $this->render('ChillEventBundle:Participation:new.html.twig', array(
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
@ -267,9 +275,16 @@ class ParticipationController extends Controller
|
|||||||
'The participation was created'
|
'The participation was created'
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_event__event_show', array(
|
if ($request->query->get('return_path'))
|
||||||
'event_id' => $participation->getEvent()->getId()
|
{
|
||||||
));
|
return $this->redirect($request->query->get('return_path'));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->redirectToRoute('chill_event__event_show', array(
|
||||||
|
'event_id' => $participation->getEvent()->getId()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillEventBundle:Participation:new.html.twig', array(
|
return $this->render('ChillEventBundle:Participation:new.html.twig', array(
|
||||||
@ -390,15 +405,17 @@ class ParticipationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Participation $participation
|
* @param Participation $participation
|
||||||
|
* @param null $return_path
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
public function createCreateForm(Participation $participation)
|
public function createCreateForm(Participation $participation, $return_path = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$form = $this->createForm(ParticipationType::class, $participation, array(
|
$form = $this->createForm(ParticipationType::class, $participation, array(
|
||||||
'event_type' => $participation->getEvent()->getType(),
|
'event_type' => $participation->getEvent()->getType(),
|
||||||
'action' => $this->generateUrl('chill_event_participation_create', array(
|
'action' => $this->generateUrl('chill_event_participation_create', array(
|
||||||
|
'return_path' => $return_path,
|
||||||
'event_id' => $participation->getEvent()->getId(),
|
'event_id' => $participation->getEvent()->getId(),
|
||||||
'person_id' => $participation->getPerson()->getId()
|
'person_id' => $participation->getPerson()->getId()
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user