diff --git a/src/Controller/api/PollController.php b/src/Controller/api/PollController.php index ecf1538..fd3b134 100644 --- a/src/Controller/api/PollController.php +++ b/src/Controller/api/PollController.php @@ -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( [ diff --git a/src/Entity/Choice.php b/src/Entity/Choice.php index 399a7db..6e00c37 100755 --- a/src/Entity/Choice.php +++ b/src/Entity/Choice.php @@ -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; } diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index f2f9492..c6838b2 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -244,7 +244,7 @@ } $displayedChoices = []; foreach ( $this->getChoices() as $choice ) { - $displayedChoices[] = $choice->display(); + $displayedChoices[] = $choice->display($this->getKind()); } $displayedComments = []; foreach ( $this->getComments() as $comment ) {