<?php
namespace App\Entity;
use App\Repository\SubjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass=SubjectRepository::class)
* @Serializer\ExclusionPolicy("ALL")
*/
class Subject extends BaseEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Expose
* @Serializer\Groups({"ligth_list"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
* @Serializer\Groups({"ligth_list"})
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
* @Serializer\Expose
* @Serializer\Groups({"ligth_list"})
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity=Module::class, inversedBy="subjects")
*/
private $module;
/**
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(length=191)
*/
private $slug;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="subject", orphanRemoval=true, fetch="EXTRA_LAZY")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity=SavedSubject::class, mappedBy="subject", orphanRemoval=true, fetch="EXTRA_LAZY")
*/
private $savedSubjects;
/**
* @ORM\OneToMany(targetEntity=SubjectLike::class, mappedBy="subject", orphanRemoval=true, fetch="EXTRA_LAZY")
* @Serializer\Expose
* @Serializer\Groups({"ligth_list"})
*/
private $subjectLikes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tags;
/**
* @ORM\ManyToMany(targetEntity=SubjectTag::class, mappedBy="subjects", cascade={"persist"})
* @Serializer\Expose
* @Serializer\Groups({"ligth_list"})
*/
private $subjectTags;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="subject", orphanRemoval=true, fetch="EXTRA_LAZY")
*/
private $notifications;
public function __construct()
{
$this->comments = new ArrayCollection();
$this->savedSubjects = new ArrayCollection();
$this->subjectLikes = new ArrayCollection();
$this->subjectTags = new ArrayCollection();
$this->notifications = 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 getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getModule(): ?Module
{
return $this->module;
}
public function setModule(?Module $module): self
{
$this->module = $module;
return $this;
}
/**
* Get the value of slug
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set the value of slug
*
* @return self
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Comment>
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setSubject($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getSubject() === $this) {
$comment->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, SavedSubject>
*/
public function getSavedSubjects(): Collection
{
return $this->savedSubjects;
}
public function addSavedSubject(SavedSubject $savedSubject): self
{
if (!$this->savedSubjects->contains($savedSubject)) {
$this->savedSubjects[] = $savedSubject;
$savedSubject->setSubject($this);
}
return $this;
}
public function removeSavedSubject(SavedSubject $savedSubject): self
{
if ($this->savedSubjects->removeElement($savedSubject)) {
// set the owning side to null (unless already changed)
if ($savedSubject->getSubject() === $this) {
$savedSubject->setSubject(null);
}
}
return $this;
}
/**
* @return Collection<int, SubjectLike>
*/
public function getSubjectLikes(): Collection
{
return $this->subjectLikes;
}
public function addSubjectLike(SubjectLike $subjectLike): self
{
if (!$this->subjectLikes->contains($subjectLike)) {
$this->subjectLikes[] = $subjectLike;
$subjectLike->setSubject($this);
}
return $this;
}
public function removeSubjectLike(SubjectLike $subjectLike): self
{
if ($this->subjectLikes->removeElement($subjectLike)) {
// set the owning side to null (unless already changed)
if ($subjectLike->getSubject() === $this) {
$subjectLike->setSubject(null);
}
}
return $this;
}
public function getTags(): ?string
{
return $this->tags;
}
public function setTags(?string $tags): self
{
$this->tags = $tags;
return $this;
}
/**
* @return Collection<int, SubjectTag>
*/
public function getSubjectTags(): Collection
{
return $this->subjectTags;
}
public function addSubjectTag(SubjectTag $subjectTag): self
{
if (!$this->subjectTags->contains($subjectTag)) {
$this->subjectTags[] = $subjectTag;
$subjectTag->addSubject($this);
}
return $this;
}
public function removeSubjectTag(SubjectTag $subjectTag): self
{
if ($this->subjectTags->removeElement($subjectTag)) {
$subjectTag->removeSubject($this);
}
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setSubject($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getSubject() === $this) {
$notification->setSubject(null);
}
}
return $this;
}
}