votestack and comment add

This commit is contained in:
Tykayn 2021-04-29 11:48:38 +02:00 committed by tykayn
parent 80abd003ae
commit d885a3b947
1 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace App\Controller\api;
use App\Controller\EmailsController;
use App\Entity\Comment;
use App\Entity\Owner;
use App\Entity\Poll;
use App\Entity\StackOfVotes;
@ -78,6 +79,13 @@ class VoteController extends EmailsController {
// TODO manage new comment
$emChoice = $choice_repository;
$newComment = new Comment();
$newComment->setPseudo($data ['pseudo'])
->setPoll($poll)
->setText($data['comment']);
$owner->addComment($newComment);
$em->persist($newComment);
foreach ( $data[ 'votes' ] as $vote ) {
if(!$vote[ 'value' ]){