From 1bc69f56adfe11fccfc42a644ba4d0416ee8615e Mon Sep 17 00:00:00 2001 From: tykayn Date: Wed, 28 Apr 2021 18:49:40 +0200 Subject: [PATCH] start vote stack adding votes --- src/Controller/api/VoteController.php | 7 ++++++- src/Entity/Owner.php | 4 ++-- src/Entity/Vote.php | 9 --------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Controller/api/VoteController.php b/src/Controller/api/VoteController.php index dfdb04c..664ccf4 100644 --- a/src/Controller/api/VoteController.php +++ b/src/Controller/api/VoteController.php @@ -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 diff --git a/src/Entity/Owner.php b/src/Entity/Owner.php index d14fd15..79a5e9c 100755 --- a/src/Entity/Owner.php +++ b/src/Entity/Owner.php @@ -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() diff --git a/src/Entity/Vote.php b/src/Entity/Vote.php index 2ab8b56..47fb84b 100755 --- a/src/Entity/Vote.php +++ b/src/Entity/Vote.php @@ -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;