mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add entities
This commit is contained in:
115
src/Entity/Entity.php
Normal file
115
src/Entity/Entity.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\EntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
||||
class Entity
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $handle = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, DomainEntity>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'entity', orphanRemoval: true)]
|
||||
private Collection $domainEntities;
|
||||
|
||||
/**
|
||||
* @var Collection<int, NameserverEntity>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'entity')]
|
||||
private Collection $nameserverEntities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->domainEntities = new ArrayCollection();
|
||||
$this->nameserverEntities = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getHandle(): ?string
|
||||
{
|
||||
return $this->handle;
|
||||
}
|
||||
|
||||
public function setHandle(string $handle): static
|
||||
{
|
||||
$this->handle = $handle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, DomainEntity>
|
||||
*/
|
||||
public function getDomainEntities(): Collection
|
||||
{
|
||||
return $this->domainEntities;
|
||||
}
|
||||
|
||||
public function addDomainEntity(DomainEntity $domainEntity): static
|
||||
{
|
||||
if (!$this->domainEntities->contains($domainEntity)) {
|
||||
$this->domainEntities->add($domainEntity);
|
||||
$domainEntity->setEntity($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDomainEntity(DomainEntity $domainEntity): static
|
||||
{
|
||||
if ($this->domainEntities->removeElement($domainEntity)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($domainEntity->getEntity() === $this) {
|
||||
$domainEntity->setEntity(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, NameserverEntity>
|
||||
*/
|
||||
public function getNameserverEntities(): Collection
|
||||
{
|
||||
return $this->nameserverEntities;
|
||||
}
|
||||
|
||||
public function addNameserverEntity(NameserverEntity $nameserverEntity): static
|
||||
{
|
||||
if (!$this->nameserverEntities->contains($nameserverEntity)) {
|
||||
$this->nameserverEntities->add($nameserverEntity);
|
||||
$nameserverEntity->setEntity($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeNameserverEntity(NameserverEntity $nameserverEntity): static
|
||||
{
|
||||
if ($this->nameserverEntities->removeElement($nameserverEntity)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($nameserverEntity->getEntity() === $this) {
|
||||
$nameserverEntity->setEntity(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user