start vote stack adding votes

This commit is contained in:
tykayn 2021-04-28 18:49:40 +02:00 committed by Baptiste Lemoine
parent 272588d000
commit 1bc69f56ad
3 changed files with 8 additions and 12 deletions

View File

@ -59,16 +59,20 @@
$data = json_decode( $data, true );
// $data = $data['data'];
$owner = new Owner();
$owner->addPoll($poll);
$newStack = new StackOfVotes();
$newStack
->setPseudo( $data[ 'pseudo' ] )
->setOwner( new Owner() );
->setOwner($owner );
// TODO manage new comment
$emChoice = $choice_repository;
foreach ( $data[ 'votes' ] as $vote ) {
$newVote = new Vote();
$newVote->setPoll($poll);
$newStack->addVote( $newVote );
$choiceFound = $emChoice->find( $vote[ 'choice_id' ] );
if ( $choiceFound ) {
@ -82,6 +86,7 @@
throw new NotFoundHttpException( 'no choice of id' . $vote[ 'choice_id' ] );
}
$poll->addVote($newVote);
$em->persist( $newVote );
}
$newStack

View File

@ -21,13 +21,13 @@ class Owner {
* @Serializer\Type("string")
* @Serializer\Expose()
*/
public $pseudo;
public $pseudo = 'anonyme';
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
* @Serializer\Expose()
*/
public $email;
public $email = "anonyme@anonyme.com";
/**
* @ORM\Id()
* @ORM\GeneratedValue()

View File

@ -108,15 +108,6 @@ class Vote {
return $this;
}
public function getCreationDate(): ?DateTimeInterface {
return $this->creationDate;
}
public function setCreationDate( DateTimeInterface $creationDate ): self {
$this->creationDate = $creationDate;
return $this;
}
public function getStacksOfVotes(): ?StackOfVotes {
return $this->stacksOfVotes;