start vote stack adding votes
This commit is contained in:
parent
272588d000
commit
1bc69f56ad
|
@ -59,16 +59,20 @@
|
||||||
$data = json_decode( $data, true );
|
$data = json_decode( $data, true );
|
||||||
// $data = $data['data'];
|
// $data = $data['data'];
|
||||||
|
|
||||||
|
$owner = new Owner();
|
||||||
|
$owner->addPoll($poll);
|
||||||
$newStack = new StackOfVotes();
|
$newStack = new StackOfVotes();
|
||||||
$newStack
|
$newStack
|
||||||
->setPseudo( $data[ 'pseudo' ] )
|
->setPseudo( $data[ 'pseudo' ] )
|
||||||
->setOwner( new Owner() );
|
->setOwner($owner );
|
||||||
|
|
||||||
// TODO manage new comment
|
// TODO manage new comment
|
||||||
$emChoice = $choice_repository;
|
$emChoice = $choice_repository;
|
||||||
|
|
||||||
foreach ( $data[ 'votes' ] as $vote ) {
|
foreach ( $data[ 'votes' ] as $vote ) {
|
||||||
$newVote = new Vote();
|
$newVote = new Vote();
|
||||||
|
$newVote->setPoll($poll);
|
||||||
|
|
||||||
$newStack->addVote( $newVote );
|
$newStack->addVote( $newVote );
|
||||||
$choiceFound = $emChoice->find( $vote[ 'choice_id' ] );
|
$choiceFound = $emChoice->find( $vote[ 'choice_id' ] );
|
||||||
if ( $choiceFound ) {
|
if ( $choiceFound ) {
|
||||||
|
@ -82,6 +86,7 @@
|
||||||
throw new NotFoundHttpException( 'no choice of id' . $vote[ 'choice_id' ] );
|
throw new NotFoundHttpException( 'no choice of id' . $vote[ 'choice_id' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$poll->addVote($newVote);
|
||||||
$em->persist( $newVote );
|
$em->persist( $newVote );
|
||||||
}
|
}
|
||||||
$newStack
|
$newStack
|
||||||
|
|
|
@ -21,13 +21,13 @@ class Owner {
|
||||||
* @Serializer\Type("string")
|
* @Serializer\Type("string")
|
||||||
* @Serializer\Expose()
|
* @Serializer\Expose()
|
||||||
*/
|
*/
|
||||||
public $pseudo;
|
public $pseudo = 'anonyme';
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @Serializer\Type("string")
|
* @Serializer\Type("string")
|
||||||
* @Serializer\Expose()
|
* @Serializer\Expose()
|
||||||
*/
|
*/
|
||||||
public $email;
|
public $email = "anonyme@anonyme.com";
|
||||||
/**
|
/**
|
||||||
* @ORM\Id()
|
* @ORM\Id()
|
||||||
* @ORM\GeneratedValue()
|
* @ORM\GeneratedValue()
|
||||||
|
|
|
@ -108,15 +108,6 @@ class Vote {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreationDate(): ?DateTimeInterface {
|
|
||||||
return $this->creationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
|
||||||
$this->creationDate = $creationDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStacksOfVotes(): ?StackOfVotes {
|
public function getStacksOfVotes(): ?StackOfVotes {
|
||||||
return $this->stacksOfVotes;
|
return $this->stacksOfVotes;
|
||||||
|
|
Loading…
Reference in New Issue