src/Entity/CBRCArticle.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use App\Repository\CBRCArticleRepository;
  6. use App\Utilities\StatusUtilities;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CBRCArticleRepository::class)
  10.  */
  11. class CBRCArticle
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity="App\Entity\CBRCUser", inversedBy="articles")
  25.      * @ORM\JoinColumn(nullable=false)
  26.      */
  27.     private $author;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $status = [];
  32.     /**
  33.      * @ORM\Column(type="datetime")
  34.      */
  35.     private $creationdate;
  36.     /**
  37.      * @ORM\Column(type="datetime", nullable=true)
  38.      */
  39.     private $updateddate;
  40.     /**
  41.      * @ORM\Column(type="datetime", nullable=true)
  42.      */
  43.     private $publisheddate;
  44.     /**
  45.      * @ORM\Column(type="datetime", nullable=true)
  46.      */
  47.     private $archiveddate;
  48.     /**
  49.      * @ORM\OneToOne(targetEntity="App\Entity\CBRCArticleContent", inversedBy="article", cascade={"persist", "remove"})
  50.      * @ORM\JoinColumn(nullable=false)
  51.      */
  52.     private $content;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity=CBRCArticleCategory::class, inversedBy="articles")
  55.      * @ORM\JoinColumn(onDelete="SET NULL")
  56.      */
  57.     private $category;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=CBRCArticleComment::class, mappedBy="article", orphanRemoval=true)
  60.      */
  61.     private $comments;
  62.     public function __construct()
  63.     {
  64.         $this->creationdate= new \DateTime('now');
  65.         $this->status=StatusUtilities::StatusArray['draft'];
  66.         $this->content=new CBRCArticleContent();
  67.         $this->comments = new ArrayCollection();
  68.     }
  69.     public function getId(): ?int
  70.     {
  71.         return $this->id;
  72.     }
  73.     public function getTitle(): ?string
  74.     {
  75.         return $this->title;
  76.     }
  77.     public function setTitle(string $title): self
  78.     {
  79.         $this->title $title;
  80.         return $this;
  81.     }
  82.     public function getAuthor(): ?CBRCUser
  83.     {
  84.         return $this->author;
  85.     }
  86.     public function setAuthor(?CBRCUser $author): self
  87.     {
  88.         $this->author $author;
  89.         return $this;
  90.     }
  91.     public function getStatus(): ?string
  92.     {
  93.         return $this->status;
  94.     }
  95.     public function setStatus(string $status): self
  96.     {
  97.         $this->status $status;
  98.         return $this;
  99.     }
  100.     public function getCreationdate(): ?\DateTimeInterface
  101.     {
  102.         return $this->creationdate;
  103.     }
  104.     public function setCreationdate(\DateTimeInterface $creationdate): self
  105.     {
  106.         $this->creationdate $creationdate;
  107.         return $this;
  108.     }
  109.     public function getUpdateddate(): ?\DateTimeInterface
  110.     {
  111.         return $this->updateddate;
  112.     }
  113.     public function setUpdateddate(?\DateTimeInterface $updateddate): self
  114.     {
  115.         $this->updateddate $updateddate;
  116.         return $this;
  117.     }
  118.     public function getPublisheddate(): ?\DateTimeInterface
  119.     {
  120.         return $this->publisheddate;
  121.     }
  122.     public function setPublisheddate(?\DateTimeInterface $publisheddate): self
  123.     {
  124.         $this->publisheddate $publisheddate;
  125.         return $this;
  126.     }
  127.     public function getArchiveddate(): ?\DateTimeInterface
  128.     {
  129.         return $this->archiveddate;
  130.     }
  131.     public function setArchiveddate(?\DateTimeInterface $archiveddate): self
  132.     {
  133.         $this->archiveddate $archiveddate;
  134.         return $this;
  135.     }
  136.     public function getContent(): ?CBRCArticleContent
  137.     {
  138.         return $this->content;
  139.     }
  140.     public function setContent(CBRCArticleContent $content): self
  141.     {
  142.         $this->content $content;
  143.         return $this;
  144.     }
  145.     public function getCategory(): ?CBRCArticleCategory
  146.     {
  147.         return $this->category;
  148.     }
  149.     public function setCategory(?CBRCArticleCategory $category): self
  150.     {
  151.         $this->category $category;
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection|CBRCArticleComment[]
  156.      */
  157.     public function getComments(): Collection
  158.     {
  159.         return $this->comments;
  160.     }
  161.     public function addComment(CBRCArticleComment $comment): self
  162.     {
  163.         if (!$this->comments->contains($comment)) {
  164.             $this->comments[] = $comment;
  165.             $comment->setArticle($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeComment(CBRCArticleComment $comment): self
  170.     {
  171.         if ($this->comments->removeElement($comment)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($comment->getArticle() === $this) {
  174.                 $comment->setArticle(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179. }