2024-07-11 02:29:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
2024-07-12 15:20:24 +02:00
|
|
|
use App\Repository\WatchListRepository;
|
2024-07-11 02:29:08 +02:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
|
|
2024-07-12 15:20:24 +02:00
|
|
|
#[ORM\Entity(repositoryClass: WatchListRepository::class)]
|
|
|
|
|
class WatchList
|
2024-07-11 02:29:08 +02:00
|
|
|
{
|
|
|
|
|
#[ORM\Id]
|
|
|
|
|
#[ORM\Column(length: 36)]
|
|
|
|
|
private string $token;
|
|
|
|
|
|
2024-07-12 15:20:24 +02:00
|
|
|
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchLists')]
|
2024-07-11 02:29:08 +02:00
|
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
|
|
|
private ?User $user = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Collection<int, Domain>
|
|
|
|
|
*/
|
2024-07-12 15:20:24 +02:00
|
|
|
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchLists')]
|
|
|
|
|
#[ORM\JoinTable(name: 'watch_lists_domains',
|
|
|
|
|
joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')],
|
2024-07-13 12:49:11 +02:00
|
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')])]
|
2024-07-11 02:29:08 +02:00
|
|
|
private Collection $domains;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->token = Uuid::v4();
|
|
|
|
|
$this->domains = new ArrayCollection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getToken(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUser(): ?User
|
|
|
|
|
{
|
|
|
|
|
return $this->user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setUser(?User $user): static
|
|
|
|
|
{
|
|
|
|
|
$this->user = $user;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Collection<int, Domain>
|
|
|
|
|
*/
|
|
|
|
|
public function getDomains(): Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->domains;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addDomain(Domain $domain): static
|
|
|
|
|
{
|
|
|
|
|
if (!$this->domains->contains($domain)) {
|
|
|
|
|
$this->domains->add($domain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function removeDomain(Domain $domain): static
|
|
|
|
|
{
|
|
|
|
|
$this->domains->removeElement($domain);
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
}
|