mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
chore: rename Bookmark WatchList
This commit is contained in:
@@ -52,10 +52,8 @@ class TestController extends AbstractController
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
return new Response(null, Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
/**
|
||||
* Création du domaine
|
||||
*/
|
||||
$domain = $em->getRepository(Domain::class)->findOneBy(["handle" => $res['handle']]);
|
||||
|
||||
$domain = $domainRepository->findOneBy(["handle" => $res['handle']]);
|
||||
if ($domain === null) $domain = new Domain();
|
||||
|
||||
$domain->setLdhName($res['ldhName'])
|
||||
@@ -64,9 +62,6 @@ class TestController extends AbstractController
|
||||
->setWhoisStatus($res['whoisStatus']);
|
||||
|
||||
|
||||
/**
|
||||
* Hydratation des événements
|
||||
*/
|
||||
foreach ($res['events'] as $rdapEvent) {
|
||||
$event = $domainEventRepository->findOneBy([
|
||||
"action" => EventAction::from($rdapEvent["eventAction"]),
|
||||
@@ -81,9 +76,7 @@ class TestController extends AbstractController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydratation des entités
|
||||
*/
|
||||
|
||||
foreach ($res['entities'] as $rdapEntity) {
|
||||
$entity = $entityRepository->findOneBy([
|
||||
"handle" => $rdapEntity['handle']
|
||||
@@ -187,4 +180,5 @@ class TestController extends AbstractController
|
||||
|
||||
return new Response(null, Response::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,10 +38,10 @@ class Domain
|
||||
private array $status = [];
|
||||
|
||||
/**
|
||||
* @var Collection<int, BookmarkList>
|
||||
* @var Collection<int, WatchList>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: BookmarkList::class, mappedBy: 'domains', cascade: ['persist'])]
|
||||
private Collection $bookmarkLists;
|
||||
#[ORM\ManyToMany(targetEntity: WatchList::class, mappedBy: 'domains', cascade: ['persist'])]
|
||||
private Collection $watchLists;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Nameserver>
|
||||
@@ -57,7 +57,7 @@ class Domain
|
||||
{
|
||||
$this->events = new ArrayCollection();
|
||||
$this->domainEntities = new ArrayCollection();
|
||||
$this->bookmarkLists = new ArrayCollection();
|
||||
$this->watchLists = new ArrayCollection();
|
||||
$this->nameservers = new ArrayCollection();
|
||||
}
|
||||
|
||||
@@ -173,27 +173,27 @@ class Domain
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BookmarkList>
|
||||
* @return Collection<int, WatchList>
|
||||
*/
|
||||
public function getBookmarkLists(): Collection
|
||||
public function getWatchLists(): Collection
|
||||
{
|
||||
return $this->bookmarkLists;
|
||||
return $this->watchLists;
|
||||
}
|
||||
|
||||
public function addBookmarkList(BookmarkList $bookmarkList): static
|
||||
public function addWatchList(WatchList $watchList): static
|
||||
{
|
||||
if (!$this->bookmarkLists->contains($bookmarkList)) {
|
||||
$this->bookmarkLists->add($bookmarkList);
|
||||
$bookmarkList->addDomain($this);
|
||||
if (!$this->watchLists->contains($watchList)) {
|
||||
$this->watchLists->add($watchList);
|
||||
$watchList->addDomain($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBookmarkList(BookmarkList $bookmarkList): static
|
||||
public function removeWatchList(WatchList $watchList): static
|
||||
{
|
||||
if ($this->bookmarkLists->removeElement($bookmarkList)) {
|
||||
$bookmarkList->removeDomain($this);
|
||||
if ($this->watchLists->removeElement($watchList)) {
|
||||
$watchList->removeDomain($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -34,14 +34,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
private ?string $password = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, BookmarkList>
|
||||
* @var Collection<int, WatchList>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: BookmarkList::class, mappedBy: 'user', orphanRemoval: true)]
|
||||
private Collection $bookmarkDomainLists;
|
||||
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'user', orphanRemoval: true)]
|
||||
private Collection $watchLists;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->bookmarkDomainLists = new ArrayCollection();
|
||||
$this->watchLists = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -121,29 +121,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BookmarkList>
|
||||
* @return Collection<int, WatchList>
|
||||
*/
|
||||
public function getBookmarkDomainLists(): Collection
|
||||
public function getWatchLists(): Collection
|
||||
{
|
||||
return $this->bookmarkDomainLists;
|
||||
return $this->watchLists;
|
||||
}
|
||||
|
||||
public function addBookmarkDomainList(BookmarkList $bookmarkDomainList): static
|
||||
public function addWatchList(WatchList $watchList): static
|
||||
{
|
||||
if (!$this->bookmarkDomainLists->contains($bookmarkDomainList)) {
|
||||
$this->bookmarkDomainLists->add($bookmarkDomainList);
|
||||
$bookmarkDomainList->setUser($this);
|
||||
if (!$this->watchLists->contains($watchList)) {
|
||||
$this->watchLists->add($watchList);
|
||||
$watchList->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBookmarkDomainList(BookmarkList $bookmarkDomainList): static
|
||||
public function removeWatchList(WatchList $watchList): static
|
||||
{
|
||||
if ($this->bookmarkDomainLists->removeElement($bookmarkDomainList)) {
|
||||
if ($this->watchLists->removeElement($watchList)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($bookmarkDomainList->getUser() === $this) {
|
||||
$bookmarkDomainList->setUser(null);
|
||||
if ($watchList->getUser() === $this) {
|
||||
$watchList->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,29 +2,29 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\BookmarkListRepository;
|
||||
use App\Repository\WatchListRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BookmarkListRepository::class)]
|
||||
class BookmarkList
|
||||
#[ORM\Entity(repositoryClass: WatchListRepository::class)]
|
||||
class WatchList
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(length: 36)]
|
||||
private string $token;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'bookmarkDomainLists')]
|
||||
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchLists')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $user = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Domain>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'bookmarkLists')]
|
||||
#[ORM\JoinTable(name: 'bookmark_lists_domains',
|
||||
joinColumns: [new ORM\JoinColumn(name: 'bookmark_token', referencedColumnName: 'token')],
|
||||
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchLists')]
|
||||
#[ORM\JoinTable(name: 'watch_lists_domains',
|
||||
joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')],
|
||||
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_handle', referencedColumnName: 'handle')])]
|
||||
private Collection $domains;
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\BookmarkList;
|
||||
use App\Entity\WatchList;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<BookmarkList>
|
||||
* @extends ServiceEntityRepository<WatchList>
|
||||
*/
|
||||
class BookmarkListRepository extends ServiceEntityRepository
|
||||
class WatchListRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, BookmarkList::class);
|
||||
parent::__construct($registry, WatchList::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return BookmarkList[] Returns an array of BookmarkList objects
|
||||
// * @return WatchList[] Returns an array of WatchList objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
@@ -31,7 +31,7 @@ class BookmarkListRepository extends ServiceEntityRepository
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?BookmarkList
|
||||
// public function findOneBySomeField($value): ?WatchList
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
Reference in New Issue
Block a user