diff --git a/src/Entity/Choice.php b/src/Entity/Choice.php index 395d691..b87ad40 100755 --- a/src/Entity/Choice.php +++ b/src/Entity/Choice.php @@ -67,13 +67,19 @@ class Choice { return $this; } - public function display() { - return [ + public function display( $kind = 'text' ) { + $fields = [ 'id' => $this->getId(), 'created_at' => $this->getCreatedAtAsString(), 'name' => $this->getName(), 'url' => $this->getUrl(), ]; + if ( $kind === 'date' ) { + $date = new DateTime( $this->getName() ); + $fields[ 'name' ] = $date->format( 'c' ); + } + + return $fields; } public function getId(): ?int { diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index 98612c5..5f3641a 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -290,7 +290,7 @@ class Poll { // first, prefill all choices foreach ( $this->getChoices() as $choice ) { - $computedArray[ $choice->getId() ] = array_merge($scoreInfos, $choice->display()); + $computedArray[ $choice->getId() ] = array_merge($scoreInfos, $choice->display($this->getKind())); } // then, compute stack of votes scores on each choice foreach ( $this->getStacksOfVotes() as $stack_of_vote ) {