mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ display vote stack data in new vote
This commit is contained in:
parent
d8b745a1d1
commit
585bdc9f19
@ -407,8 +407,7 @@ class DefaultController extends AbstractController {
|
||||
return $this->json( [
|
||||
'message' => 'you created a comment',
|
||||
'data' => [
|
||||
'your_comment' => $comment->display(),
|
||||
'poll_comments' => $poll->getComments(),
|
||||
'your_comment' => $comment->display(),
|
||||
],
|
||||
],
|
||||
201 );
|
||||
@ -444,6 +443,7 @@ class DefaultController extends AbstractController {
|
||||
} else {
|
||||
$existingOwner = true;
|
||||
}
|
||||
// TODO anti flood
|
||||
$foundOwner
|
||||
->setModifierToken( $poll->generateAdminKey() );
|
||||
$stack = new StackOfVotes();
|
||||
@ -483,7 +483,8 @@ class DefaultController extends AbstractController {
|
||||
|
||||
return $this->json( [
|
||||
'message' => 'you created a vote stack' . $precision,
|
||||
'vote_stack' => $stack,
|
||||
'vote_stack' => $stack->display(),
|
||||
'vote_count' => count( $poll->getStacksOfVotes() ),
|
||||
'owner_modifier_token' => $foundOwner->getModifierToken(),
|
||||
'json_you_sent' => $data,
|
||||
],
|
||||
|
@ -41,6 +41,21 @@ class StackOfVotes {
|
||||
*/
|
||||
private $owner;
|
||||
|
||||
|
||||
public function display() {
|
||||
$tab = [];
|
||||
foreach ( $this->getVotes() as $vote ) {
|
||||
$tab[ $vote->getId() ] = [
|
||||
'id' => $vote->getId(),
|
||||
'value' => $vote->getValue(),
|
||||
'choice_id' => $vote->getChoice()->getId(),
|
||||
'text' => $vote->getChoice()->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
return $tab;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user