mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
adapt display of choice for timeslice
This commit is contained in:
parent
9ff5429051
commit
723c774d51
@ -480,28 +480,14 @@ class PollController extends EmailsController {
|
||||
if ( $pollFound ) {
|
||||
|
||||
$poll = $pollFound;
|
||||
$comments = $poll->getComments();
|
||||
$stacks = $poll->getStacksOfVotes();
|
||||
|
||||
$returnedPoll = [
|
||||
'message' => 'your poll config',
|
||||
'poll' => $poll,
|
||||
'stacks_count' => count( $stacks ),
|
||||
'stacks' => $stacks,
|
||||
'choices_count' => $poll->computeAnswers(),
|
||||
'choices' => $poll->getChoices(),
|
||||
'comments' => $comments,
|
||||
'comments_count' => count( $comments ),
|
||||
'token' => $token,
|
||||
'poll' => $poll->displayForAdmin(),
|
||||
];
|
||||
|
||||
$jsonResponse = $serializer->serialize( $returnedPoll, 'json' );
|
||||
|
||||
$response = new Response( $jsonResponse );
|
||||
$response->headers->set( 'Content-Type', 'application/json' );
|
||||
$response->setStatusCode( 200 );
|
||||
|
||||
return $response;
|
||||
return $this->json( $returnedPoll,
|
||||
200 );;
|
||||
}
|
||||
|
||||
return $this->json( [
|
||||
|
@ -67,15 +67,6 @@ class Choice {
|
||||
'name' => $this->getName(),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
if ( $kind === 'date' ) {
|
||||
try {
|
||||
$date = new DateTime( $this->getName() );
|
||||
} catch ( \Exception $e ) {
|
||||
die($e);
|
||||
}
|
||||
$fields[ 'name' ] = $date->format( 'c' );
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@
|
||||
}
|
||||
$displayedChoices = [];
|
||||
foreach ( $this->getChoices() as $choice ) {
|
||||
$displayedChoices[] = $choice->display();
|
||||
$displayedChoices[] = $choice->display($this->getKind());
|
||||
}
|
||||
$displayedComments = [];
|
||||
foreach ( $this->getComments() as $comment ) {
|
||||
|
Loading…
Reference in New Issue
Block a user