chore: rename WatchList to Watchlist

This commit is contained in:
Maël Gangloff
2025-10-25 17:26:56 +02:00
parent ff90477695
commit 5243b3c2dd
32 changed files with 278 additions and 199 deletions

View File

@@ -61,10 +61,10 @@ class Connector
private array $authData = [];
/**
* @var Collection<int, WatchList>
* @var Collection<int, Watchlist>
*/
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'connector')]
private Collection $watchLists;
#[ORM\OneToMany(targetEntity: Watchlist::class, mappedBy: 'connector')]
private Collection $watchlists;
#[Groups(['connector:list', 'watchlist:list'])]
#[ORM\Column]
@@ -76,7 +76,7 @@ class Connector
public function __construct()
{
$this->id = Uuid::v4();
$this->watchLists = new ArrayCollection();
$this->watchlists = new ArrayCollection();
}
public function getId(): ?string
@@ -121,29 +121,29 @@ class Connector
}
/**
* @return Collection<int, WatchList>
* @return Collection<int, Watchlist>
*/
public function getWatchLists(): Collection
public function getWatchlists(): Collection
{
return $this->watchLists;
return $this->watchlists;
}
public function addWatchList(WatchList $watchList): static
public function addWatchlist(Watchlist $watchlist): static
{
if (!$this->watchLists->contains($watchList)) {
$this->watchLists->add($watchList);
$watchList->setConnector($this);
if (!$this->watchlists->contains($watchlist)) {
$this->watchlists->add($watchlist);
$watchlist->setConnector($this);
}
return $this;
}
public function removeWatchList(WatchList $watchList): static
public function removeWatchlist(Watchlist $watchlist): static
{
if ($this->watchLists->removeElement($watchList)) {
if ($this->watchlists->removeElement($watchlist)) {
// set the owning side to null (unless already changed)
if ($watchList->getConnector() === $this) {
$watchList->setConnector(null);
if ($watchlist->getConnector() === $this) {
$watchlist->setConnector(null);
}
}
@@ -164,6 +164,6 @@ class Connector
public function getWatchlistCount(): ?int
{
return $this->watchLists->count();
return $this->watchlists->count();
}
}

View File

@@ -82,10 +82,10 @@ class Domain
private array $status = [];
/**
* @var Collection<int, WatchList>
* @var Collection<int, Watchlist>
*/
#[ORM\ManyToMany(targetEntity: WatchList::class, mappedBy: 'domains', cascade: ['persist'])]
private Collection $watchLists;
#[ORM\ManyToMany(targetEntity: Watchlist::class, mappedBy: 'domains', cascade: ['persist'])]
private Collection $watchlists;
/**
* @var Collection<int, Nameserver>
@@ -154,7 +154,7 @@ class Domain
{
$this->events = new ArrayCollection();
$this->domainEntities = new ArrayCollection();
$this->watchLists = new ArrayCollection();
$this->watchlists = new ArrayCollection();
$this->nameservers = new ArrayCollection();
$this->updatedAt = new \DateTimeImmutable('now');
$this->createdAt = $this->updatedAt;
@@ -263,27 +263,27 @@ class Domain
}
/**
* @return Collection<int, WatchList>
* @return Collection<int, Watchlist>
*/
public function getWatchLists(): Collection
public function getWatchlists(): Collection
{
return $this->watchLists;
return $this->watchlists;
}
public function addWatchList(WatchList $watchList): static
public function addWatchlists(Watchlist $watchlist): static
{
if (!$this->watchLists->contains($watchList)) {
$this->watchLists->add($watchList);
$watchList->addDomain($this);
if (!$this->watchlists->contains($watchlist)) {
$this->watchlists->add($watchlist);
$watchlist->addDomain($this);
}
return $this;
}
public function removeWatchList(WatchList $watchList): static
public function removeWatchlists(Watchlist $watchlist): static
{
if ($this->watchLists->removeElement($watchList)) {
$watchList->removeDomain($this);
if ($this->watchlists->removeElement($watchlist)) {
$watchlist->removeDomain($this);
}
return $this;

View File

@@ -66,10 +66,10 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private ?string $password = null;
/**
* @var Collection<int, WatchList>
* @var Collection<int, Watchlist>
*/
#[ORM\OneToMany(targetEntity: WatchList::class, mappedBy: 'user', orphanRemoval: true)]
private Collection $watchLists;
#[ORM\OneToMany(targetEntity: Watchlist::class, mappedBy: 'user', orphanRemoval: true)]
private Collection $watchlists;
/**
* @var Collection<int, Connector>
@@ -91,7 +91,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
public function __construct()
{
$this->watchLists = new ArrayCollection();
$this->watchlists = new ArrayCollection();
$this->connectors = new ArrayCollection();
}
@@ -168,29 +168,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
}
/**
* @return Collection<int, WatchList>
* @return Collection<int, Watchlist>
*/
public function getWatchLists(): Collection
public function getWatchlists(): Collection
{
return $this->watchLists;
return $this->watchlists;
}
public function addWatchList(WatchList $watchList): static
public function addWatchlist(Watchlist $watchlist): static
{
if (!$this->watchLists->contains($watchList)) {
$this->watchLists->add($watchList);
$watchList->setUser($this);
if (!$this->watchlists->contains($watchlist)) {
$this->watchlists->add($watchlist);
$watchlist->setUser($this);
}
return $this;
}
public function removeWatchList(WatchList $watchList): static
public function removeWatchlist(Watchlist $watchlist): static
{
if ($this->watchLists->removeElement($watchList)) {
if ($this->watchlists->removeElement($watchlist)) {
// set the owning side to null (unless already changed)
if ($watchList->getUser() === $this) {
$watchList->setUser(null);
if ($watchlist->getUser() === $this) {
$watchlist->setUser(null);
}
}

View File

@@ -8,8 +8,8 @@ use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Repository\WatchListRepository;
use App\State\WatchListUpdateProcessor;
use App\Repository\WatchlistRepository;
use App\State\WatchlistUpdateProcessor;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
@@ -19,7 +19,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: WatchListRepository::class)]
#[ORM\Entity(repositoryClass: WatchlistRepository::class)]
#[ApiResource(
shortName: 'Watchlist',
operations: [
@@ -87,13 +87,13 @@ use Symfony\Component\Validator\Constraints as Assert;
new Post(
normalizationContext: ['groups' => 'watchlist:list'],
denormalizationContext: ['groups' => 'watchlist:create'],
processor: WatchListUpdateProcessor::class,
processor: WatchlistUpdateProcessor::class,
),
new Put(
normalizationContext: ['groups' => 'watchlist:list'],
denormalizationContext: ['groups' => ['watchlist:update']],
security: 'object.getUser() == user',
processor: WatchListUpdateProcessor::class,
processor: WatchlistUpdateProcessor::class,
),
new Delete(
security: 'object.getUser() == user'
@@ -146,9 +146,9 @@ use Symfony\Component\Validator\Constraints as Assert;
),
],
)]
class WatchList
class Watchlist
{
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchLists')]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'watchlists')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
public ?User $user = null;
@@ -160,14 +160,14 @@ class WatchList
/**
* @var Collection<int, Domain>
*/
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchLists')]
#[ORM\JoinTable(name: 'watch_lists_domains',
joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token', onDelete: 'CASCADE')],
#[ORM\ManyToMany(targetEntity: Domain::class, inversedBy: 'watchlists')]
#[ORM\JoinTable(name: 'watchlist_domains',
joinColumns: [new ORM\JoinColumn(name: 'watchlist_token', referencedColumnName: 'token', onDelete: 'CASCADE')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name', onDelete: 'CASCADE')])]
#[Groups(['watchlist:create', 'watchlist:list', 'watchlist:item', 'watchlist:update'])]
private Collection $domains;
#[ORM\ManyToOne(inversedBy: 'watchLists')]
#[ORM\ManyToOne(inversedBy: 'watchlists')]
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
private ?Connector $connector = null;