fix: update table scheme

This commit is contained in:
Maël Gangloff
2024-07-11 02:29:08 +02:00
parent 9cc575ff09
commit fbb14df399
14 changed files with 711 additions and 56 deletions

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Entity;
use App\Repository\BookmarkDomainListRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: BookmarkDomainListRepository::class)]
class BookmarkDomainList
{
#[ORM\Id]
#[ORM\Column(length: 36)]
private string $token;
#[ORM\ManyToOne(inversedBy: 'bookmarkDomainLists')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
/**
* @var Collection<int, Domain>
*/
#[ORM\ManyToMany(targetEntity: Domain::class, mappedBy: 'ldhname')]
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;
}
}

View File

@@ -18,7 +18,7 @@ class Domain
#[ORM\Column(length: 255)]
private ?string $handle = null;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $status = [];
/**

View File

@@ -11,15 +11,15 @@ class DomainEntity
{
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'domainEntities')]
#[ORM\JoinColumn(nullable: false, referencedColumnName: 'ldhname')]
#[ORM\JoinColumn(referencedColumnName: 'ldhname', nullable: false)]
private ?Domain $domain = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'domainEntities')]
#[ORM\JoinColumn(nullable: false, referencedColumnName: 'handle')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $roles = [];
public function getDomain(): ?Domain

View File

@@ -18,7 +18,7 @@ class Event
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'events')]
#[ORM\JoinColumn(nullable: false, referencedColumnName: 'ldhname')]
#[ORM\JoinColumn(referencedColumnName: 'ldhname', nullable: false)]
private ?Domain $domain = null;
public function getAction(): ?string

View File

@@ -11,18 +11,18 @@ class NameserverEntity
{
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(nullable: false, referencedColumnName: 'handle')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Nameserver $nameserver = null;
#[ORM\Id]
#[ORM\ManyToOne(inversedBy: 'nameserverEntities')]
#[ORM\JoinColumn(nullable: false, referencedColumnName: 'handle')]
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
private ?Entity $entity = null;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $roles = [];
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $status = [];
public function getNameserver(): ?Nameserver

151
src/Entity/User.php Normal file
View File

@@ -0,0 +1,151 @@
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180)]
private ?string $email = null;
/**
* @var list<string> The user roles
*/
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
/**
* @var Collection<int, BookmarkDomainList>
*/
#[ORM\OneToMany(targetEntity: BookmarkDomainList::class, mappedBy: 'user', orphanRemoval: true)]
private Collection $bookmarkDomainLists;
public function __construct()
{
$this->bookmarkDomainLists = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*
* @return list<string>
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* @param list<string> $roles
*/
public function setRoles(array $roles): static
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials(): void
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, BookmarkDomainList>
*/
public function getBookmarkDomainLists(): Collection
{
return $this->bookmarkDomainLists;
}
public function addBookmarkDomainList(BookmarkDomainList $bookmarkDomainList): static
{
if (!$this->bookmarkDomainLists->contains($bookmarkDomainList)) {
$this->bookmarkDomainLists->add($bookmarkDomainList);
$bookmarkDomainList->setUser($this);
}
return $this;
}
public function removeBookmarkDomainList(BookmarkDomainList $bookmarkDomainList): static
{
if ($this->bookmarkDomainLists->removeElement($bookmarkDomainList)) {
// set the owning side to null (unless already changed)
if ($bookmarkDomainList->getUser() === $this) {
$bookmarkDomainList->setUser(null);
}
}
return $this;
}
}