<?php
namespace App\Entity;
use App\Repository\NotificationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass=NotificationRepository::class)
* @Serializer\ExclusionPolicy("ALL")
*/
class Notification extends BaseEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Expose
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="notifications")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $receiver;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose
*/
private $message;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $objectType;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $objectId;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Expose
*/
private $isRead = false;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $topics = [];
/**
* @ORM\OneToMany(targetEntity=NotificationReceiver::class, mappedBy="notification", cascade={"remove"}, fetch="EXTRA_LAZY"))
*/
private $notificationReceivers;
/**
* @ORM\ManyToOne(targetEntity=Comment::class, inversedBy="notifications")
*/
private $comment;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose
*/
private $action;
/**
* @ORM\ManyToOne(targetEntity=Module::class, inversedBy="notifications")
* @Serializer\Expose
*/
private $module;
/**
* @ORM\ManyToOne(targetEntity=Subject::class, inversedBy="notifications")
*/
private $subject;
public function __construct()
{
$this->notificationReceivers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getReceiver(): ?User
{
return $this->receiver;
}
public function setReceiver(?User $receiver): self
{
$this->receiver = $receiver;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(string $message): self
{
$this->message = $message;
return $this;
}
public function getObjectType(): ?string
{
return $this->objectType;
}
public function setObjectType(?string $objectType): self
{
$this->objectType = $objectType;
return $this;
}
public function getObjectId(): ?int
{
return $this->objectId;
}
public function setObjectId(?int $objectId): self
{
$this->objectId = $objectId;
return $this;
}
public function isIsRead(): ?bool
{
return $this->isRead;
}
public function setIsRead(?bool $isRead): self
{
$this->isRead = $isRead;
return $this;
}
public function getTopics(): ?array
{
return $this->topics;
}
public function setTopics(?array $topics): self
{
$this->topics = $topics;
return $this;
}
/**
* @return Collection<int, NotificationReceiver>
*/
public function getNotificationReceivers(): Collection
{
return $this->notificationReceivers;
}
public function addNotificationReceiver(NotificationReceiver $notificationReceiver): self
{
if (!$this->notificationReceivers->contains($notificationReceiver)) {
$this->notificationReceivers[] = $notificationReceiver;
$notificationReceiver->setNotification($this);
}
return $this;
}
public function removeNotificationReceiver(NotificationReceiver $notificationReceiver): self
{
if ($this->notificationReceivers->removeElement($notificationReceiver)) {
// set the owning side to null (unless already changed)
if ($notificationReceiver->getNotification() === $this) {
$notificationReceiver->setNotification(null);
}
}
return $this;
}
public function getComment(): ?Comment
{
return $this->comment;
}
public function setComment(?Comment $comment): self
{
$this->comment = $comment;
return $this;
}
public function getAction(): ?string
{
return $this->action;
}
public function setAction(?string $action): self
{
$this->action = $action;
return $this;
}
public function getModule(): ?Module
{
return $this->module;
}
public function setModule(?Module $module): self
{
$this->module = $module;
return $this;
}
public function getSubject(): ?Subject
{
return $this->subject;
}
public function setSubject(?Subject $subject): self
{
$this->subject = $subject;
return $this;
}
}