mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
splitting function in order to prepare single/multiple adding association
ref #6
This commit is contained in:
parent
9cdbd8303a
commit
93a5568aee
@ -21,6 +21,7 @@ namespace Chill\EventBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\EventBundle\Form\ParticipationType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
@ -33,7 +34,33 @@ use Chill\EventBundle\Security\Authorization\ParticipationVoter;
|
||||
*/
|
||||
class ParticipationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a form to add a participation
|
||||
*
|
||||
* This function parse the person_id / persons_ids query argument
|
||||
* and decide if it should process a single or multiple participation
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$single = $request->query->getInt('person_id', null);
|
||||
$multiple = $request->query->get('persons_ids', null);
|
||||
|
||||
if ($single !== NULL AND $multiple !== NULL) {
|
||||
// we are not allowed to have both person_id and persons_ids
|
||||
return (new Response())
|
||||
->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setContent("You are not allow to provide both 'person_id' and "
|
||||
. "'persons_ids' simulaneously");
|
||||
}
|
||||
|
||||
if ($single !== NULL) {
|
||||
return $this->newSingleAction($request);
|
||||
}
|
||||
}
|
||||
|
||||
protected function newSingleAction(Request $request)
|
||||
{
|
||||
$participation = $this->handleRequest($request, new Participation());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user