2024-07-10 23:30:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
2024-07-17 00:19:27 +02:00
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
2024-07-10 23:30:59 +02:00
|
|
|
use App\Repository\EntityRepository;
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2025-09-10 22:17:19 +02:00
|
|
|
use Doctrine\ORM\Mapping\Embedded;
|
2024-07-17 00:19:27 +02:00
|
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
2024-07-21 02:25:37 +02:00
|
|
|
use Symfony\Component\Serializer\Attribute\SerializedName;
|
2024-07-10 23:30:59 +02:00
|
|
|
|
|
|
|
|
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
2025-02-18 01:29:29 +01:00
|
|
|
#[ORM\UniqueConstraint(
|
|
|
|
|
columns: ['tld_id', 'handle']
|
|
|
|
|
)]
|
2024-07-17 00:19:27 +02:00
|
|
|
#[ApiResource(
|
|
|
|
|
operations: [
|
2024-12-27 15:29:16 +01:00
|
|
|
/*
|
2024-07-17 00:19:27 +02:00
|
|
|
new GetCollection(
|
|
|
|
|
uriTemplate: '/entities',
|
|
|
|
|
normalizationContext: ['groups' => ['entity:list', 'event:list']]
|
|
|
|
|
),
|
2025-02-18 01:50:38 +01:00
|
|
|
|
2024-07-17 00:19:27 +02:00
|
|
|
new Get(
|
2025-02-18 01:29:29 +01:00
|
|
|
uriTemplate: '/entities/{id}',
|
2024-07-17 00:19:27 +02:00
|
|
|
normalizationContext: [
|
|
|
|
|
'groups' => [
|
|
|
|
|
'event:list',
|
|
|
|
|
'entity:item',
|
|
|
|
|
'domain-entity:domain',
|
2024-07-20 10:11:49 +02:00
|
|
|
'domain:list',
|
|
|
|
|
'nameserver-entity:nameserver',
|
2024-08-02 23:24:52 +02:00
|
|
|
'nameserver:list',
|
|
|
|
|
],
|
2024-07-17 00:19:27 +02:00
|
|
|
]
|
2024-08-02 23:24:52 +02:00
|
|
|
),
|
2025-02-18 01:50:38 +01:00
|
|
|
*/
|
2024-07-17 00:19:27 +02:00
|
|
|
]
|
|
|
|
|
)]
|
2024-07-10 23:30:59 +02:00
|
|
|
class Entity
|
|
|
|
|
{
|
2024-07-13 17:04:29 +02:00
|
|
|
#[ORM\Id]
|
2025-02-18 01:29:29 +01:00
|
|
|
#[ORM\GeneratedValue]
|
|
|
|
|
#[ORM\Column]
|
|
|
|
|
private ?int $id = null;
|
|
|
|
|
|
|
|
|
|
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
|
|
|
|
|
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: true)]
|
|
|
|
|
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
|
|
|
|
private ?Tld $tld = null;
|
|
|
|
|
|
2024-07-10 23:30:59 +02:00
|
|
|
#[ORM\Column(length: 255)]
|
2024-07-27 16:45:20 +02:00
|
|
|
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
2024-07-10 23:30:59 +02:00
|
|
|
private ?string $handle = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Collection<int, DomainEntity>
|
|
|
|
|
*/
|
|
|
|
|
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'entity', orphanRemoval: true)]
|
2024-07-17 00:19:27 +02:00
|
|
|
#[Groups(['entity:item'])]
|
2024-07-21 02:25:37 +02:00
|
|
|
#[SerializedName('domains')]
|
2024-07-10 23:30:59 +02:00
|
|
|
private Collection $domainEntities;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Collection<int, NameserverEntity>
|
|
|
|
|
*/
|
|
|
|
|
#[ORM\OneToMany(targetEntity: NameserverEntity::class, mappedBy: 'entity')]
|
2024-07-17 00:19:27 +02:00
|
|
|
#[Groups(['entity:item'])]
|
2024-07-21 02:25:37 +02:00
|
|
|
#[SerializedName('nameservers')]
|
2024-07-10 23:30:59 +02:00
|
|
|
private Collection $nameserverEntities;
|
|
|
|
|
|
2024-07-11 18:29:22 +02:00
|
|
|
/**
|
2024-07-12 00:50:30 +02:00
|
|
|
* @var Collection<int, EntityEvent>
|
2024-07-11 18:29:22 +02:00
|
|
|
*/
|
2024-07-12 00:50:30 +02:00
|
|
|
#[ORM\OneToMany(targetEntity: EntityEvent::class, mappedBy: 'entity', cascade: ['persist'], orphanRemoval: true)]
|
2024-07-27 16:45:20 +02:00
|
|
|
#[Groups(['entity:list', 'entity:item', 'entity:list', 'domain:item'])]
|
2024-07-11 18:29:22 +02:00
|
|
|
private Collection $events;
|
|
|
|
|
|
2024-07-12 15:38:24 +02:00
|
|
|
#[ORM\Column]
|
2024-07-27 16:45:20 +02:00
|
|
|
#[Groups(['entity:item', 'domain:item'])]
|
2024-07-12 15:38:24 +02:00
|
|
|
private array $jCard = [];
|
|
|
|
|
|
2024-12-28 19:26:25 +01:00
|
|
|
#[ORM\Column(nullable: true)]
|
|
|
|
|
#[Groups(['entity:item', 'domain:item'])]
|
|
|
|
|
private ?array $remarks = null;
|
|
|
|
|
|
2025-09-10 22:17:19 +02:00
|
|
|
#[Embedded(class: IanaAccreditation::class, columnPrefix: 'iana_')]
|
2025-09-10 22:26:02 +02:00
|
|
|
#[Groups(['entity:item', 'domain:item'])]
|
|
|
|
|
private IanaAccreditation $ianaAccreditation;
|
2025-09-10 21:35:43 +02:00
|
|
|
|
2024-07-10 23:30:59 +02:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->domainEntities = new ArrayCollection();
|
|
|
|
|
$this->nameserverEntities = new ArrayCollection();
|
2024-07-11 18:29:22 +02:00
|
|
|
$this->events = new ArrayCollection();
|
2025-09-10 22:26:02 +02:00
|
|
|
$this->ianaAccreditation = new IanaAccreditation();
|
2024-07-10 23:30:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-07-11 18:29:22 +02:00
|
|
|
|
|
|
|
|
/**
|
2024-07-12 00:50:30 +02:00
|
|
|
* @return Collection<int, EntityEvent>
|
2024-07-11 18:29:22 +02:00
|
|
|
*/
|
|
|
|
|
public function getEvents(): Collection
|
|
|
|
|
{
|
|
|
|
|
return $this->events;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 00:50:30 +02:00
|
|
|
public function addEvent(EntityEvent $event): static
|
2024-07-11 18:29:22 +02:00
|
|
|
{
|
|
|
|
|
if (!$this->events->contains($event)) {
|
|
|
|
|
$this->events->add($event);
|
|
|
|
|
$event->setEntity($this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 00:50:30 +02:00
|
|
|
public function removeEvent(EntityEvent $event): static
|
2024-07-11 18:29:22 +02:00
|
|
|
{
|
|
|
|
|
if ($this->events->removeElement($event)) {
|
|
|
|
|
// set the owning side to null (unless already changed)
|
|
|
|
|
if ($event->getEntity() === $this) {
|
|
|
|
|
$event->setEntity(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:38:24 +02:00
|
|
|
public function getJCard(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->jCard;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setJCard(array $jCard): static
|
|
|
|
|
{
|
|
|
|
|
$this->jCard = $jCard;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2024-12-28 19:26:25 +01:00
|
|
|
|
|
|
|
|
public function getRemarks(): ?array
|
|
|
|
|
{
|
|
|
|
|
return $this->remarks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setRemarks(?array $remarks): static
|
|
|
|
|
{
|
|
|
|
|
$this->remarks = $remarks;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2025-02-18 01:29:29 +01:00
|
|
|
|
|
|
|
|
public function getId(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setId(int $id): static
|
|
|
|
|
{
|
|
|
|
|
$this->id = $id;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getTld(): ?Tld
|
|
|
|
|
{
|
|
|
|
|
return $this->tld;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setTld(?Tld $tld): static
|
|
|
|
|
{
|
|
|
|
|
$this->tld = $tld;
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2025-09-10 21:35:43 +02:00
|
|
|
|
2025-09-10 22:26:02 +02:00
|
|
|
public function getIanaAccreditation(): IanaAccreditation
|
2025-09-10 21:35:43 +02:00
|
|
|
{
|
2025-09-10 22:17:19 +02:00
|
|
|
return $this->ianaAccreditation;
|
2025-09-10 21:35:43 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-10 22:26:02 +02:00
|
|
|
public function setIanaAccreditation(IanaAccreditation $ianaAccreditation): void
|
2025-09-10 21:35:43 +02:00
|
|
|
{
|
2025-09-10 22:17:19 +02:00
|
|
|
$this->ianaAccreditation = $ianaAccreditation;
|
2025-09-10 21:35:43 +02:00
|
|
|
}
|
2024-07-10 23:30:59 +02:00
|
|
|
}
|