mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
Compare commits
2 Commits
dd1de88635
...
1d72bfe684
Author | SHA1 | Date | |
---|---|---|---|
1d72bfe684 | |||
7c1fbf7347 |
@ -101,19 +101,31 @@ class PollController extends EmailsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$comments = $poll->getComments();
|
$comments = $poll->getComments();
|
||||||
$pass = $poll->getPassword();
|
$stacks = $poll->getStacksOfVotes();
|
||||||
|
|
||||||
|
$displayedComments = [];
|
||||||
|
foreach ( $comments as $comment ) {
|
||||||
|
$displayedComments[] = $comment->display();
|
||||||
|
}
|
||||||
|
$displayedStackOfVotes = [];
|
||||||
|
foreach ( $stacks as $stack ) {
|
||||||
|
$displayedStackOfVotes[] = $stack->display();
|
||||||
|
}
|
||||||
|
$displayedChoices = [];
|
||||||
|
foreach ( $poll->getChoices() as $choice
|
||||||
|
) {
|
||||||
|
$displayedChoices[] = $choice->display();
|
||||||
|
}
|
||||||
|
$pass = $poll->getPassword();
|
||||||
|
|
||||||
$returnedPoll = [
|
$returnedPoll = [
|
||||||
'message' => 'your poll config for ' . $poll->getTitle(),
|
'message' => 'your poll config for ' . $poll->getTitle(),
|
||||||
'password_protected' => $pass ? 'yes' : 'no',
|
|
||||||
// TODO do not render sub objects of owner, it returns too many things
|
'poll' => $poll->display(),
|
||||||
'poll' => $poll,
|
// TODO do not render sub objects of owner, it returns too many thing
|
||||||
'stacks_count' => count( $poll->getStacksOfVotes() ),
|
'stacks' => $displayedStackOfVotes,
|
||||||
'stacks' => $poll->getStacksOfVotes(),
|
'choices' => $displayedChoices,
|
||||||
'choices_count' => $poll->computeAnswers(),
|
'comments' => $displayedComments,
|
||||||
'choices' => $poll->getChoices(),
|
|
||||||
'comments' => $comments,
|
|
||||||
'comments_count' => count( $comments ),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,8 +141,8 @@ class PollController extends EmailsController {
|
|||||||
} else {
|
} else {
|
||||||
// free access to poll
|
// free access to poll
|
||||||
// return $this->returnPollData( $poll, $serializer );
|
// return $this->returnPollData( $poll, $serializer );
|
||||||
// return $this->json($returnedPoll);
|
return $this->json( $returnedPoll );
|
||||||
return $this->json($poll);
|
// return $this->json($poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
return [
|
return [
|
||||||
'id' => $this->getId(),
|
'id' => $this->getId(),
|
||||||
'date' => $this->getDateTime(),
|
'date' => $this->getDateTime(),
|
||||||
'text' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'url' => $this->getUrl(),
|
'url' => $this->getUrl(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,6 @@ class Poll {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'counts' => $computedArray,
|
'counts' => $computedArray,
|
||||||
'maxScore' => $maxScore,
|
'maxScore' => $maxScore,
|
||||||
@ -241,7 +240,8 @@ class Poll {
|
|||||||
|
|
||||||
public function display() {
|
public function display() {
|
||||||
return [
|
return [
|
||||||
'poll' => $this,
|
'config' => $this,
|
||||||
|
'password_protected' => $this->getPassword() ? 'yes' : 'no',
|
||||||
'answers' => $this->computeAnswers(),
|
'answers' => $this->computeAnswers(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class StackOfVotes {
|
|||||||
public function display() {
|
public function display() {
|
||||||
$tab = [
|
$tab = [
|
||||||
'id' => $this->getId(),
|
'id' => $this->getId(),
|
||||||
'modifier_token' => $this->getOwner()->getModifierToken(),
|
// 'modifier_token' => $this->getOwner()->getModifierToken(),
|
||||||
'pseudo' => '',
|
'pseudo' => '',
|
||||||
'creation_date' => '',
|
'creation_date' => '',
|
||||||
'votes' => [],
|
'votes' => [],
|
||||||
@ -55,13 +55,14 @@ class StackOfVotes {
|
|||||||
foreach ( $this->getPoll()->getChoices() as $choice ) {
|
foreach ( $this->getPoll()->getChoices() as $choice ) {
|
||||||
$tab[ 'votes' ][ $choice->getId() ] = [
|
$tab[ 'votes' ][ $choice->getId() ] = [
|
||||||
'choice_id' => $choice->getId(),
|
'choice_id' => $choice->getId(),
|
||||||
|
'name' => $choice->getName(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $this->getVotes() as $vote ) {
|
foreach ( $this->getVotes() as $vote ) {
|
||||||
$tab[ 'votes' ][ $vote->getChoice()->getId() ] = $vote->display();
|
// $tab[ 'votes' ][ $vote->getChoice()->getId() ] = $vote->display();
|
||||||
$tab[ 'votes' ][ $vote->getChoice()->getId() ][ 'stack_id' ] = $this->getId();
|
$tab[ 'votes' ][ $vote->getChoice()->getId() ][ 'stack_id' ] = $this->getId();
|
||||||
$tab[ 'pseudo' ] = $this->getOwner()->getPseudo();
|
$tab[ 'pseudo' ] = $this->getPseudo();
|
||||||
$tab[ 'creation_date' ] = $vote->getCreationDate();
|
$tab[ 'creation_date' ] = $vote->getCreationDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user