display vote stack data in new vote

This commit is contained in:
Baptiste Lemoine 2020-01-21 10:46:29 +01:00
parent d8b745a1d1
commit 585bdc9f19
2 changed files with 19 additions and 3 deletions

View File

@ -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,
],

View File

@ -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();
}