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( [
|
return $this->json( [
|
||||||
'message' => 'you created a comment',
|
'message' => 'you created a comment',
|
||||||
'data' => [
|
'data' => [
|
||||||
'your_comment' => $comment->display(),
|
'your_comment' => $comment->display(),
|
||||||
'poll_comments' => $poll->getComments(),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
201 );
|
201 );
|
||||||
@ -444,6 +443,7 @@ class DefaultController extends AbstractController {
|
|||||||
} else {
|
} else {
|
||||||
$existingOwner = true;
|
$existingOwner = true;
|
||||||
}
|
}
|
||||||
|
// TODO anti flood
|
||||||
$foundOwner
|
$foundOwner
|
||||||
->setModifierToken( $poll->generateAdminKey() );
|
->setModifierToken( $poll->generateAdminKey() );
|
||||||
$stack = new StackOfVotes();
|
$stack = new StackOfVotes();
|
||||||
@ -483,7 +483,8 @@ class DefaultController extends AbstractController {
|
|||||||
|
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'message' => 'you created a vote stack' . $precision,
|
'message' => 'you created a vote stack' . $precision,
|
||||||
'vote_stack' => $stack,
|
'vote_stack' => $stack->display(),
|
||||||
|
'vote_count' => count( $poll->getStacksOfVotes() ),
|
||||||
'owner_modifier_token' => $foundOwner->getModifierToken(),
|
'owner_modifier_token' => $foundOwner->getModifierToken(),
|
||||||
'json_you_sent' => $data,
|
'json_you_sent' => $data,
|
||||||
],
|
],
|
||||||
|
@ -41,6 +41,21 @@ class StackOfVotes {
|
|||||||
*/
|
*/
|
||||||
private $owner;
|
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() {
|
public function __construct() {
|
||||||
$this->votes = new ArrayCollection();
|
$this->votes = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user