Files
domain-watchdog/src/Entity/Connector.php

117 lines
2.8 KiB
PHP
Raw Normal View History

2024-07-28 21:14:41 +02:00
<?php
namespace App\Entity;
use App\Config\ConnectorProvider;
use App\Repository\ConnectorRepository;
2024-07-29 11:37:52 +02:00
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
2024-07-28 21:14:41 +02:00
use Doctrine\ORM\Mapping as ORM;
2024-07-28 23:05:41 +02:00
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\InheritanceType;
2024-07-28 21:14:41 +02:00
#[ORM\Entity(repositoryClass: ConnectorRepository::class)]
2024-07-28 23:05:41 +02:00
#[InheritanceType('SINGLE_TABLE')]
#[DiscriminatorColumn(name: 'provider', enumType: ConnectorProvider::class)]
#[DiscriminatorMap([ConnectorProvider::OVH->value => OVHConnector::class])]
2024-07-28 21:14:41 +02:00
class Connector
{
#[ORM\Id]
2024-07-28 23:05:41 +02:00
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
private ?string $provider = null;
2024-07-28 21:14:41 +02:00
#[ORM\ManyToOne(inversedBy: 'connectors')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[ORM\Column]
private array $authData = [];
2024-07-29 11:37:52 +02:00
/**
* @var Collection<int, WatchListTrigger>
*/
#[ORM\OneToMany(targetEntity: WatchListTrigger::class, mappedBy: 'connector')]
private Collection $watchListTriggers;
public function __construct()
{
$this->watchListTriggers = new ArrayCollection();
}
2024-07-28 23:05:41 +02:00
public function getId(): ?int
{
return $this->id;
}
2024-07-28 21:14:41 +02:00
2024-07-28 23:05:41 +02:00
public function getProvider(): ?string
2024-07-28 21:14:41 +02:00
{
return $this->provider;
}
2024-07-28 23:05:41 +02:00
public function setProvider(?string $provider): static
2024-07-28 21:14:41 +02:00
{
$this->provider = $provider;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getAuthData(): array
{
return $this->authData;
}
public function setAuthData(array $authData): static
{
$this->authData = $authData;
return $this;
}
2024-07-29 11:37:52 +02:00
/**
* @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;
}
2024-07-28 21:14:41 +02:00
}