mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: connector on watchlist
This commit is contained in:
@@ -56,16 +56,16 @@ class Connector
|
||||
private array $authData = [];
|
||||
|
||||
/**
|
||||
* @var Collection<int, WatchListTrigger>
|
||||
* @var Collection<int, WatchList>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: WatchListTrigger::class, mappedBy: 'connector')]
|
||||
private Collection $watchListTriggers;
|
||||
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')]
|
||||
private Collection $watchLists;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::v4();
|
||||
$this->watchListTriggers = new ArrayCollection();
|
||||
$this->watchLists = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?string
|
||||
@@ -97,36 +97,6 @@ class Connector
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, WatchListTrigger>
|
||||
*/
|
||||
public function getWatchListTriggers(): Collection
|
||||
{
|
||||
return $this->watchListTriggers;
|
||||
}
|
||||
|
||||
public function addWatchListTrigger(WatchListTrigger $watchListTrigger): static
|
||||
{
|
||||
if (!$this->watchListTriggers->contains($watchListTrigger)) {
|
||||
$this->watchListTriggers->add($watchListTrigger);
|
||||
$watchListTrigger->setConnector($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeWatchListTrigger(WatchListTrigger $watchListTrigger): static
|
||||
{
|
||||
if ($this->watchListTriggers->removeElement($watchListTrigger)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($watchListTrigger->getConnector() === $this) {
|
||||
$watchListTrigger->setConnector(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProvider(): ?ConnectorProvider
|
||||
{
|
||||
return $this->provider;
|
||||
@@ -139,4 +109,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ class WatchList
|
||||
#[SerializedName("triggers")]
|
||||
private Collection $watchListTriggers;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'watchLists')]
|
||||
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
|
||||
private ?Connector $connector = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->token = Uuid::v4();
|
||||
@@ -146,4 +151,16 @@ class WatchList
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnector(): ?Connector
|
||||
{
|
||||
return $this->connector;
|
||||
}
|
||||
|
||||
public function setConnector(?Connector $connector): static
|
||||
{
|
||||
$this->connector = $connector;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ class WatchListTrigger
|
||||
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
|
||||
private ?TriggerAction $action = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'watchListTriggers')]
|
||||
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
|
||||
private ?Connector $connector = null;
|
||||
|
||||
public function getEvent(): ?string
|
||||
{
|
||||
return $this->event;
|
||||
@@ -64,16 +60,4 @@ class WatchListTrigger
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnector(): ?Connector
|
||||
{
|
||||
return $this->connector;
|
||||
}
|
||||
|
||||
public function setConnector(?Connector $connector): static
|
||||
{
|
||||
$this->connector = $connector;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user