mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
reorganize displays
This commit is contained in:
parent
dd1de88635
commit
7c1fbf7347
@ -101,18 +101,27 @@ class PollController extends EmailsController {
|
||||
}
|
||||
|
||||
$comments = $poll->getComments();
|
||||
$stacks = $poll->getStacksOfVotes();
|
||||
|
||||
$displayedComments = [];
|
||||
foreach ( $comments as $comment ) {
|
||||
$displayedComments[] = $comment->display();
|
||||
}
|
||||
$displayedStackOfVotes = [];
|
||||
foreach ( $stacks as $stack ) {
|
||||
$displayedStackOfVotes[] = $stack->display();
|
||||
}
|
||||
$pass = $poll->getPassword();
|
||||
|
||||
$returnedPoll = [
|
||||
'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,
|
||||
|
||||
'poll' => $poll->display(),
|
||||
// TODO do not render sub objects of owner, it returns too many thing
|
||||
'stacks_count' => count( $poll->getStacksOfVotes() ),
|
||||
'stacks' => $poll->getStacksOfVotes(),
|
||||
'stacks' => $displayedStackOfVotes,
|
||||
'choices_count' => $poll->computeAnswers(),
|
||||
'choices' => $poll->getChoices(),
|
||||
'comments' => $comments,
|
||||
'comments' => $displayedComments,
|
||||
'comments_count' => count( $comments ),
|
||||
];
|
||||
|
||||
@ -129,8 +138,8 @@ class PollController extends EmailsController {
|
||||
} else {
|
||||
// free access to poll
|
||||
// return $this->returnPollData( $poll, $serializer );
|
||||
// return $this->json($returnedPoll);
|
||||
return $this->json($poll);
|
||||
return $this->json($returnedPoll);
|
||||
// return $this->json($poll);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,7 @@
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'date' => $this->getDateTime(),
|
||||
'text' => $this->getName(),
|
||||
'name' => $this->getName(),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
}
|
||||
|
@ -241,7 +241,8 @@ class Poll {
|
||||
|
||||
public function display() {
|
||||
return [
|
||||
'poll' => $this,
|
||||
'config' => $this,
|
||||
'password_protected' => $this->getPassword() ? 'yes' : 'no',
|
||||
'answers' => $this->computeAnswers(),
|
||||
];
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class StackOfVotes {
|
||||
public function display() {
|
||||
$tab = [
|
||||
'id' => $this->getId(),
|
||||
'modifier_token' => $this->getOwner()->getModifierToken(),
|
||||
// 'modifier_token' => $this->getOwner()->getModifierToken(),
|
||||
'pseudo' => '',
|
||||
'creation_date' => '',
|
||||
'votes' => [],
|
||||
@ -55,13 +55,14 @@ class StackOfVotes {
|
||||
foreach ( $this->getPoll()->getChoices() as $choice ) {
|
||||
$tab[ 'votes' ][ $choice->getId() ] = [
|
||||
'choice_id' => $choice->getId(),
|
||||
'name' => $choice->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
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[ 'pseudo' ] = $this->getOwner()->getPseudo();
|
||||
$tab[ 'pseudo' ] = $this->getPseudo();
|
||||
$tab[ 'creation_date' ] = $vote->getCreationDate();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user