hegresphere/src/Entity/Status.php

79 lines
1.7 KiB
PHP
Raw Normal View History

2024-10-17 17:56:46 +02:00
<?php
namespace App\Entity;
use App\Repository\StatusRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: StatusRepository::class)]
class Status
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $label = null;
/**
* @var Collection<int, Announcement>
*/
#[ORM\OneToMany(targetEntity: Announcement::class, mappedBy: 'status')]
private Collection $announcements;
public function __construct()
{
$this->announcements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
/**
* @return Collection<int, Announcement>
*/
public function getAnnouncements(): Collection
{
return $this->announcements;
}
public function addAnnouncement(Announcement $announcement): static
{
if (!$this->announcements->contains($announcement)) {
$this->announcements->add($announcement);
$announcement->setStatus($this);
}
return $this;
}
public function removeAnnouncement(Announcement $announcement): static
{
if ($this->announcements->removeElement($announcement)) {
// set the owning side to null (unless already changed)
if ($announcement->getStatus() === $this) {
$announcement->setStatus(null);
}
}
return $this;
}
}