src/Entity/GuestbookEntry.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use JMS\Serializer\Annotation\Groups;
  5. /**
  6.  * @ORM\HasLifecycleCallbacks()
  7.  *
  8.  * @ORM\Table("GuestbookEntry")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\GuestbookEntryRepository")
  11.  */
  12. class GuestbookEntry
  13. {
  14.     /**
  15.      * @Groups({"guestbookindex", "timelineindex"})
  16.      *
  17.      * @ORM\Id()
  18.      *
  19.      * @ORM\GeneratedValue()
  20.      *
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @Groups({"guestbookindex", "timelineindex"})
  26.      *
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\Member")
  28.      *
  29.      * @ORM\JoinColumn(name="sender_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  30.      */
  31.     private $sender;
  32.     /**
  33.      * @Groups({"adminindex", "guestbookindex", "timelineindex"})
  34.      *
  35.      * @ORM\ManyToOne(targetEntity="App\Entity\Member")
  36.      *
  37.      * @ORM\JoinColumn(name="recipient_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  38.      */
  39.     private $recipient;
  40.     /**
  41.      * @Groups({"adminindex", "guestbookindex"})
  42.      *
  43.      * @ORM\Column(type="boolean", options={"default" = 0})
  44.      */
  45.     private $is_spam false;
  46.     /**
  47.      * @Groups({"guestbookindex", "timelineindex"})
  48.      *
  49.      * @ORM\Column(type="boolean", options={"default" = 1})
  50.      */
  51.     private $is_hidden true;
  52.     /**
  53.      * @Groups({"guestbookindex", "timelineindex"})
  54.      *
  55.      * @ORM\Column(type="text")
  56.      */
  57.     private $message;
  58.     /**
  59.      * @Groups({"guestbookindex", "timelineindex"})
  60.      *
  61.      * @ORM\Column(type="text", nullable=true)
  62.      */
  63.     private $comment;
  64.     /**
  65.      * @Groups({"guestbookindex", "timelineindex"})
  66.      *
  67.      * @ORM\Column(type="datetime")
  68.      */
  69.     private $createdAt;
  70.     /**
  71.      * @Groups({"guestbookindex", "timelineindex"})
  72.      *
  73.      * @ORM\Column(type="datetime", nullable=true)
  74.      */
  75.     private $commentedAt;
  76.     /**
  77.      * @ORM\PrePersist
  78.      */
  79.     public function prePersistSetValues()
  80.     {
  81.         if (!$this->getCreatedAt()) {
  82.             $this->setCreatedAt(new \DateTime());
  83.         }
  84.     }
  85.     public function getId()
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getSender(): ?Member
  90.     {
  91.         return $this->sender;
  92.     }
  93.     public function setSender(Member $sender): self
  94.     {
  95.         $this->sender $sender;
  96.         return $this;
  97.     }
  98.     public function getRecipient(): ?Member
  99.     {
  100.         return $this->recipient;
  101.     }
  102.     public function setRecipient(Member $recipient): self
  103.     {
  104.         $this->recipient $recipient;
  105.         return $this;
  106.     }
  107.     public function getIsSpam(): ?bool
  108.     {
  109.         return $this->is_spam;
  110.     }
  111.     public function setIsSpam(bool $is_spam): self
  112.     {
  113.         $this->is_spam $is_spam;
  114.         return $this;
  115.     }
  116.     public function getIsHidden(): ?bool
  117.     {
  118.         return $this->is_hidden;
  119.     }
  120.     public function setIsHidden(bool $is_hidden): self
  121.     {
  122.         $this->is_hidden $is_hidden;
  123.         return $this;
  124.     }
  125.     public function getMessage(): ?string
  126.     {
  127.         return $this->message;
  128.     }
  129.     public function setMessage(string $message): self
  130.     {
  131.         $this->message $message;
  132.         return $this;
  133.     }
  134.     public function getComment(): ?string
  135.     {
  136.         return $this->comment;
  137.     }
  138.     public function setComment(?string $comment): self
  139.     {
  140.         $this->comment $comment;
  141.         if (null === $comment) {
  142.             $this->commentedAt null;
  143.         }
  144.         if (null !== $comment && null === $this->commentedAt) {
  145.             $this->commentedAt = new \DateTime();
  146.         }
  147.         return $this;
  148.     }
  149.     public function getCreatedAt(): ?\DateTimeInterface
  150.     {
  151.         return $this->createdAt;
  152.     }
  153.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  154.     {
  155.         $this->createdAt $createdAt;
  156.         return $this;
  157.     }
  158.     public function getCommentedAt(): ?\DateTimeInterface
  159.     {
  160.         return $this->commentedAt;
  161.     }
  162.     public function setCommentedAt(?\DateTimeInterface $commentedAt): self
  163.     {
  164.         $this->commentedAt $commentedAt;
  165.         return $this;
  166.     }
  167. }