From 06182dc23652dff917b4f62b69b72193ae84de82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Mon, 29 Jul 2024 11:37:52 +0200 Subject: [PATCH] fix: make migration --- ...28213336.php => Version20240729093649.php} | 2 +- src/Entity/Connector.php | 43 +++++++++++++++++++ src/Entity/WatchListTrigger.php | 15 +++++++ 3 files changed, 59 insertions(+), 1 deletion(-) rename migrations/{Version20240728213336.php => Version20240729093649.php} (95%) diff --git a/migrations/Version20240728213336.php b/migrations/Version20240729093649.php similarity index 95% rename from migrations/Version20240728213336.php rename to migrations/Version20240729093649.php index 021d06c..2802517 100644 --- a/migrations/Version20240728213336.php +++ b/migrations/Version20240729093649.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20240728213336 extends AbstractMigration +final class Version20240729093649 extends AbstractMigration { public function getDescription(): string { diff --git a/src/Entity/Connector.php b/src/Entity/Connector.php index dedfd5d..aee9571 100644 --- a/src/Entity/Connector.php +++ b/src/Entity/Connector.php @@ -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 + */ + #[ORM\OneToMany(targetEntity: WatchListTrigger::class, mappedBy: 'connector')] + private Collection $watchListTriggers; + + public function __construct() + { + $this->watchListTriggers = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -70,4 +83,34 @@ class Connector return $this; } + /** + * @return Collection + */ + 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; + } + } diff --git a/src/Entity/WatchListTrigger.php b/src/Entity/WatchListTrigger.php index 477669d..28e4823 100644 --- a/src/Entity/WatchListTrigger.php +++ b/src/Entity/WatchListTrigger.php @@ -25,6 +25,9 @@ class WatchListTrigger #[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])] private ?TriggerAction $action = null; + #[ORM\ManyToOne(inversedBy: 'watchListTriggers')] + private ?Connector $connector = null; + public function getEvent(): ?string { return $this->event; @@ -60,4 +63,16 @@ class WatchListTrigger return $this; } + + public function getConnector(): ?Connector + { + return $this->connector; + } + + public function setConnector(?Connector $connector): static + { + $this->connector = $connector; + + return $this; + } }