feat: add Connector to Watchlist

This commit is contained in:
Maël Gangloff
2024-07-28 23:28:03 +02:00
parent 15b2068d9e
commit 1f5c1f812b
3 changed files with 94 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Entity;
use App\Config\ConnectorProvider;
use App\Repository\ConnectorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
@@ -29,6 +31,17 @@ class Connector
#[ORM\Column]
private array $authData = [];
/**
* @var Collection<int, WatchList>
*/
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')]
private Collection $watchLists;
public function __construct()
{
$this->watchLists = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
@@ -70,4 +83,34 @@ class Connector
return $this;
}
/**
* @return Collection<int, WatchList>
*/
public function getWatchLists(): Collection
{
return $this->watchLists;
}
public function addWatchList(WatchList $watchList): static
{
if (!$this->watchLists->contains($watchList)) {
$this->watchLists->add($watchList);
$watchList->setConnector($this);
}
return $this;
}
public function removeWatchList(WatchList $watchList): static
{
if ($this->watchLists->removeElement($watchList)) {
// set the owning side to null (unless already changed)
if ($watchList->getConnector() === $this) {
$watchList->setConnector(null);
}
}
return $this;
}
}