src/Entity/ReseauSociaux/NotificationType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ReseauSociaux;
  3. use App\Repository\ReseauSociaux\NotificationTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=NotificationTypeRepository::class)
  10.  */
  11. class NotificationType
  12. {
  13.     const INVITATION_ESPACE 'invitationespace';
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Groups("notif:read")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      * @Groups("notif:read")
  24.      */
  25.     private $label;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="type")
  28.      */
  29.     private $notifications;
  30.     public function __construct()
  31.     {
  32.         $this->notifications = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getLabel(): ?string
  39.     {
  40.         return $this->label;
  41.     }
  42.     public function setLabel(string $label): self
  43.     {
  44.         $this->label $label;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection<int, Notifications>
  49.      */
  50.     public function getNotifications(): Collection
  51.     {
  52.         return $this->notifications;
  53.     }
  54.     public function addNotification(Notifications $notification): self
  55.     {
  56.         if (!$this->notifications->contains($notification)) {
  57.             $this->notifications[] = $notification;
  58.             $notification->setType($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeNotification(Notifications $notification): self
  63.     {
  64.         if ($this->notifications->removeElement($notification)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($notification->getType() === $this) {
  67.                 $notification->setType(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72. }