mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
start vote stack adding votes
This commit is contained in:
parent
272588d000
commit
1bc69f56ad
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user