<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use App\Repository\CBRCArticleRepository;
use App\Utilities\StatusUtilities;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CBRCArticleRepository::class)
*/
class CBRCArticle
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CBRCUser", inversedBy="articles")
* @ORM\JoinColumn(nullable=false)
*/
private $author;
/**
* @ORM\Column(type="string", length=255)
*/
private $status = [];
/**
* @ORM\Column(type="datetime")
*/
private $creationdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updateddate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $publisheddate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $archiveddate;
/**
* @ORM\OneToOne(targetEntity="App\Entity\CBRCArticleContent", inversedBy="article", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity=CBRCArticleCategory::class, inversedBy="articles")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $category;
/**
* @ORM\OneToMany(targetEntity=CBRCArticleComment::class, mappedBy="article", orphanRemoval=true)
*/
private $comments;
public function __construct()
{
$this->creationdate= new \DateTime('now');
$this->status=StatusUtilities::StatusArray['draft'];
$this->content=new CBRCArticleContent();
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getAuthor(): ?CBRCUser
{
return $this->author;
}
public function setAuthor(?CBRCUser $author): self
{
$this->author = $author;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
public function getUpdateddate(): ?\DateTimeInterface
{
return $this->updateddate;
}
public function setUpdateddate(?\DateTimeInterface $updateddate): self
{
$this->updateddate = $updateddate;
return $this;
}
public function getPublisheddate(): ?\DateTimeInterface
{
return $this->publisheddate;
}
public function setPublisheddate(?\DateTimeInterface $publisheddate): self
{
$this->publisheddate = $publisheddate;
return $this;
}
public function getArchiveddate(): ?\DateTimeInterface
{
return $this->archiveddate;
}
public function setArchiveddate(?\DateTimeInterface $archiveddate): self
{
$this->archiveddate = $archiveddate;
return $this;
}
public function getContent(): ?CBRCArticleContent
{
return $this->content;
}
public function setContent(CBRCArticleContent $content): self
{
$this->content = $content;
return $this;
}
public function getCategory(): ?CBRCArticleCategory
{
return $this->category;
}
public function setCategory(?CBRCArticleCategory $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection|CBRCArticleComment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(CBRCArticleComment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setArticle($this);
}
return $this;
}
public function removeComment(CBRCArticleComment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getArticle() === $this) {
$comment->setArticle(null);
}
}
return $this;
}
}