src/Entity/Post.php line 13

  1. <?php
  2. namespace Cms\Entity;
  3. use Cms\Repository\PostRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPostRepository::class)]
  9. #[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')]
  10. class Post
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $title null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $slug null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $chapo null;
  22.     #[ORM\Column(typeTypes::TEXT)]
  23.     private ?string $content null;
  24.     #[ORM\ManyToOne(cascade: ['persist'], fetch'EAGER'inversedBy'posts')]
  25.     private ?Category $category null;
  26.     #[ORM\ManyToMany(targetEntityTag::class, inversedBy'posts'cascade: ['persist'], fetch'EAGER')]
  27.     private Collection $tags;
  28.     #[ORM\Column]
  29.     private ?\DateTimeImmutable $createdAt null;
  30.     #[ORM\Column(nullabletrue)]
  31.     private ?\DateTimeImmutable $updatedAt null;
  32.     #[ORM\Column]
  33.     private ?\DateTimeImmutable $publishedAt null;
  34.     #[ORM\ManyToOne(inversedBy'posts')]
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     private ?User $createdBy null;
  37.     #[ORM\Column]
  38.     private bool $deleted false;
  39.     #[ORM\Column]
  40.     private bool $published false;
  41.     #[ORM\Column(length5)]
  42.     private ?string $language null;
  43.     #[ORM\OneToMany(mappedBy'post'targetEntityComment::class, orphanRemovaltrue)]
  44.     private Collection $comments;
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?bool $commentsAllowed null;
  47.     public function __construct()
  48.     {
  49.         $this->tags = new ArrayCollection();
  50.         $this->comments = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getTitle(): ?string
  57.     {
  58.         return $this->title;
  59.     }
  60.     public function setTitle(string $title): self
  61.     {
  62.         $this->title $title;
  63.         return $this;
  64.     }
  65.     public function getSlug(): ?string
  66.     {
  67.         return $this->slug;
  68.     }
  69.     public function setSlug(string $slug): self
  70.     {
  71.         $this->slug $slug;
  72.         return $this;
  73.     }
  74.     public function getChapo(): ?string
  75.     {
  76.         return $this->chapo;
  77.     }
  78.     public function setChapo(?string $chapo): self
  79.     {
  80.         $this->chapo $chapo;
  81.         return $this;
  82.     }
  83.     public function getContent(): ?string
  84.     {
  85.         return $this->content;
  86.     }
  87.     public function setContent(string $content): self
  88.     {
  89.         $this->content $content;
  90.         return $this;
  91.     }
  92.     public function getCategory(): ?Category
  93.     {
  94.         return $this->category;
  95.     }
  96.     public function setCategory(?Category $category): self
  97.     {
  98.         $this->category $category;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return Collection<int, Tag>
  103.      */
  104.     public function getTags(): Collection
  105.     {
  106.         return $this->tags;
  107.     }
  108.     public function addTag(Tag $tag): self
  109.     {
  110.         if (!$this->tags->contains($tag)) {
  111.             $this->tags->add($tag);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeTag(Tag $tag): self
  116.     {
  117.         $this->tags->removeElement($tag);
  118.         return $this;
  119.     }
  120.     public function getCreatedAt(): ?\DateTimeImmutable
  121.     {
  122.         return $this->createdAt;
  123.     }
  124.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  125.     {
  126.         $this->createdAt $createdAt;
  127.         return $this;
  128.     }
  129.     public function getUpdatedAt(): ?\DateTimeImmutable
  130.     {
  131.         return $this->updatedAt;
  132.     }
  133.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  134.     {
  135.         $this->updatedAt $updatedAt;
  136.         return $this;
  137.     }
  138.     public function getPublishedAt(): ?\DateTimeImmutable
  139.     {
  140.         return $this->publishedAt;
  141.     }
  142.     public function setPublishedAt(?\DateTimeImmutable $publishedAt): self
  143.     {
  144.         $this->publishedAt $publishedAt;
  145.         return $this;
  146.     }
  147.     public function getCreatedBy(): ?User
  148.     {
  149.         return $this->createdBy;
  150.     }
  151.     public function setCreatedBy(?User $createdBy): self
  152.     {
  153.         $this->createdBy $createdBy;
  154.         return $this;
  155.     }
  156.     public function isDeleted(): bool
  157.     {
  158.         return $this->deleted;
  159.     }
  160.     public function setDeleted(bool $deleted): self
  161.     {
  162.         $this->deleted $deleted;
  163.         return $this;
  164.     }
  165.     public function isPublished(): bool
  166.     {
  167.         return $this->published;
  168.     }
  169.     public function setPublished(bool $published): self
  170.     {
  171.         $this->published $published;
  172.         return $this;
  173.     }
  174.     public function getLanguage(): ?string
  175.     {
  176.         return $this->language;
  177.     }
  178.     public function setLanguage(string $language): self
  179.     {
  180.         $this->language $language;
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection<int, Comment>
  185.      */
  186.     public function getComments(): Collection
  187.     {
  188.         return $this->comments;
  189.     }
  190.     public function addComment(Comment $comment): self
  191.     {
  192.         if (!$this->comments->contains($comment)) {
  193.             $this->comments->add($comment);
  194.             $comment->setPost($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeComment(Comment $comment): self
  199.     {
  200.         if ($this->comments->removeElement($comment)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($comment->getPost() === $this) {
  203.                 $comment->setPost(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     public function isCommentsAllowed(): ?bool
  209.     {
  210.         return $this->commentsAllowed;
  211.     }
  212.     public function setCommentsAllowed(?bool $commentsAllowed): self
  213.     {
  214.         $this->commentsAllowed $commentsAllowed;
  215.         return $this;
  216.     }
  217. }