mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 06:14:59 +00:00
new participation: add optional return_path to POST request
This commit is contained in:
@@ -35,6 +35,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
*/
|
||||
class ParticipationController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show a form to add a participation
|
||||
*
|
||||
@@ -43,9 +44,12 @@ class ParticipationController extends Controller
|
||||
* on this, the appropriate layout and form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
dump('coucou');
|
||||
|
||||
// test the request is correct
|
||||
try {
|
||||
$this->testRequest($request);
|
||||
@@ -123,12 +127,16 @@ class ParticipationController extends Controller
|
||||
*/
|
||||
protected function newSingle(Request $request)
|
||||
{
|
||||
|
||||
$returnPath = $request->query->get('return_path') ?
|
||||
$request->query->get('return_path') : null;
|
||||
|
||||
$participation = $this->handleRequest($request, new Participation(), false);
|
||||
|
||||
$this->denyAccessUnlessGranted(ParticipationVoter::CREATE,
|
||||
$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(
|
||||
'form' => $form->createView(),
|
||||
@@ -267,9 +275,16 @@ class ParticipationController extends Controller
|
||||
'The participation was created'
|
||||
));
|
||||
|
||||
return $this->redirectToRoute('chill_event__event_show', array(
|
||||
'event_id' => $participation->getEvent()->getId()
|
||||
));
|
||||
if ($request->query->get('return_path'))
|
||||
{
|
||||
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(
|
||||
@@ -390,15 +405,17 @@ class ParticipationController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Participation $participation
|
||||
* @param null $return_path
|
||||
* @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(
|
||||
'event_type' => $participation->getEvent()->getType(),
|
||||
'action' => $this->generateUrl('chill_event_participation_create', array(
|
||||
'return_path' => $return_path,
|
||||
'event_id' => $participation->getEvent()->getId(),
|
||||
'person_id' => $participation->getPerson()->getId()
|
||||
))
|
||||
|
Reference in New Issue
Block a user