start to expose fields of poll

This commit is contained in:
Baptiste Lemoine 2019-11-05 17:31:07 +01:00
parent d282bbca3b
commit 2c2c24b1bb
3 changed files with 13 additions and 3 deletions

View File

@ -10,6 +10,8 @@ fos_rest:
# App\Exception\MyException: 403
# messages:
# App\Exception\MyException: Forbidden area.
routing_loader:
default_format: json
format_listener:
rules:
- { path: '^/',

View File

@ -60,12 +60,12 @@ class DefaultController extends AbstractController {
*/
public function getAllPollsAction() {
$repository = $this->getDoctrine()->getRepository( Poll::class );
$polls = $repository->findall();
$data = $repository->findall();
return $this->json( [
'message' => 'here are your polls',
'data' => $polls,
'data' => $data,
] );
}

View File

@ -5,39 +5,47 @@ namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass="App\Repository\PollRepository")
* @Serializer\ExclusionPolicy("ALL")
*/
class Poll {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Serializer\Expose
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
*/
private $customUrl;
/**
* vote restricted by a password
* vote restricted by a password in md5 format
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", length=1000)
* @Serializer\Expose
*/
private $description;
/**
* @ORM\Column(type="datetime")
* @Serializer\Expose
*/
private $creationDate;