2019-11-06 14:54:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
2019-11-12 11:26:19 +01:00
|
|
|
use DateTimeInterface;
|
2019-11-06 14:54:04 +01:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2020-01-20 17:27:59 +01:00
|
|
|
use JMS\Serializer\Annotation as Serializer;
|
2019-11-06 14:54:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\CommentRepository")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\ExclusionPolicy("all")
|
2019-11-06 14:54:04 +01:00
|
|
|
*/
|
|
|
|
class Comment {
|
|
|
|
/**
|
|
|
|
* @ORM\Id()
|
|
|
|
* @ORM\GeneratedValue()
|
|
|
|
* @ORM\Column(type="integer")
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
2019-11-27 11:26:21 +01:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="comments")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Type("App\Entity\Owner")
|
|
|
|
* @Serializer\Expose()
|
2019-11-06 14:54:04 +01:00
|
|
|
*/
|
|
|
|
private $owner;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="text")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Type("string")
|
|
|
|
* @Serializer\Expose()
|
2019-11-06 14:54:04 +01:00
|
|
|
*/
|
|
|
|
private $text;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="datetime")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Type("datetime")
|
|
|
|
* @Serializer\Expose()
|
2019-11-06 14:54:04 +01:00
|
|
|
*/
|
|
|
|
private $createdAt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="comments")
|
|
|
|
*/
|
|
|
|
private $poll;
|
|
|
|
|
2020-01-21 10:32:56 +01:00
|
|
|
function display() {
|
|
|
|
return [
|
2020-01-21 11:10:18 +01:00
|
|
|
'id' => $this->getId(),
|
|
|
|
'text' => $this->getText(),
|
|
|
|
'pseudo' => $this->getOwner()->getPseudo(),
|
|
|
|
'date' => $this->getCreatedAt(),
|
2020-01-21 10:32:56 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-11-27 16:14:49 +01:00
|
|
|
function __construct() {
|
2019-11-27 16:39:52 +01:00
|
|
|
$this->setCreatedAt( new \DateTime() );
|
2019-11-27 16:14:49 +01:00
|
|
|
}
|
|
|
|
|
2019-11-06 14:54:04 +01:00
|
|
|
public function getId(): ?int {
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOwner(): ?Owner {
|
|
|
|
return $this->owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOwner( ?Owner $owner ): self {
|
|
|
|
$this->owner = $owner;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getText(): ?string {
|
|
|
|
return $this->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setText( string $text ): self {
|
|
|
|
$this->text = $text;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2019-11-12 11:26:19 +01:00
|
|
|
public function getCreatedAt(): ?DateTimeInterface {
|
2019-11-06 14:54:04 +01:00
|
|
|
return $this->createdAt;
|
|
|
|
}
|
|
|
|
|
2019-11-12 11:26:19 +01:00
|
|
|
public function setCreatedAt( DateTimeInterface $createdAt ): self {
|
2019-11-06 14:54:04 +01:00
|
|
|
$this->createdAt = $createdAt;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPoll(): ?Poll {
|
|
|
|
return $this->poll;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPoll( ?Poll $poll ): self {
|
|
|
|
$this->poll = $poll;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|