Files
domain-watchdog/src/Entity/Tld.php

242 lines
5.9 KiB
PHP
Raw Normal View History

2024-07-19 18:59:21 +02:00
<?php
namespace App\Entity;
2024-07-24 20:00:26 +02:00
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
2024-07-19 20:40:30 +02:00
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
2024-07-24 18:52:19 +02:00
use App\Config\TldType;
2024-07-19 18:59:21 +02:00
use App\Repository\TldRepository;
2025-05-21 13:14:38 +02:00
use App\Service\RDAPService;
2024-07-19 18:59:21 +02:00
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
2024-07-19 20:40:30 +02:00
use Symfony\Component\Serializer\Attribute\Groups;
2024-07-19 18:59:21 +02:00
2024-07-19 20:40:30 +02:00
#[ApiResource(
shortName: 'Top Level Domain',
operations: [
new GetCollection(
uriTemplate: '/tld',
normalizationContext: ['groups' => ['tld:list']]
),
new Get(
uriTemplate: '/tld/{tld}',
normalizationContext: ['groups' => ['tld:item']]
2024-08-02 23:24:52 +02:00
),
2024-07-19 20:40:30 +02:00
]
)]
2024-07-24 20:00:26 +02:00
#[ApiFilter(SearchFilter::class)]
2024-07-19 18:59:21 +02:00
#[ORM\Entity(repositoryClass: TldRepository::class)]
class Tld
{
#[ORM\Id]
#[ORM\Column(length: 63)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:list', 'tld:item'])]
2024-07-19 18:59:21 +02:00
private ?string $tld = null;
/**
* @var Collection<int, RdapServer>
*/
#[ORM\OneToMany(targetEntity: RdapServer::class, mappedBy: 'tld', orphanRemoval: true)]
private Collection $rdapServers;
#[ORM\Column(nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:list', 'tld:item'])]
2024-07-19 18:59:21 +02:00
private ?bool $contractTerminated = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $dateOfContractSignature = null;
2024-07-19 18:59:21 +02:00
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $delegationDate = null;
2024-07-19 18:59:21 +02:00
#[ORM\Column(length: 255, nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:list', 'tld:item'])]
2024-07-19 18:59:21 +02:00
private ?string $registryOperator = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:item'])]
private ?\DateTimeImmutable $removalDate = null;
2024-07-19 18:59:21 +02:00
#[ORM\Column(nullable: true)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:list', 'tld:item'])]
2024-07-19 18:59:21 +02:00
private ?bool $specification13 = null;
2024-07-24 22:17:54 +02:00
#[ORM\Column(length: 10, enumType: TldType::class)]
2024-08-02 23:24:52 +02:00
#[Groups(['tld:item'])]
2024-07-24 18:52:19 +02:00
private ?TldType $type = null;
2025-02-18 01:29:29 +01:00
/**
* @var Collection<int, Entity>
*/
#[ORM\OneToMany(targetEntity: Entity::class, mappedBy: 'tld')]
private Collection $entities;
2024-07-19 18:59:21 +02:00
public function __construct()
{
$this->rdapServers = new ArrayCollection();
2025-02-18 01:29:29 +01:00
$this->entities = new ArrayCollection();
2024-07-19 18:59:21 +02:00
}
/**
* @return Collection<int, RdapServer>
*/
public function getRdapServers(): Collection
{
return $this->rdapServers;
}
public function addRdapServer(RdapServer $rdapServer): static
{
if (!$this->rdapServers->contains($rdapServer)) {
$this->rdapServers->add($rdapServer);
$rdapServer->setTld($this);
}
return $this;
}
public function removeRdapServer(RdapServer $rdapServer): static
{
if ($this->rdapServers->removeElement($rdapServer)) {
// set the owning side to null (unless already changed)
if ($rdapServer->getTld() === $this) {
$rdapServer->setTld(null);
}
}
return $this;
}
public function getTld(): ?string
{
2024-12-20 17:43:35 +01:00
return '' === $this->tld ? '.' : $this->tld;
2024-07-19 18:59:21 +02:00
}
public function setTld(string $tld): static
{
2025-05-21 13:14:38 +02:00
$this->tld = RDAPService::convertToIdn($tld);
2024-07-19 18:59:21 +02:00
return $this;
}
public function isContractTerminated(): ?bool
{
return $this->contractTerminated;
}
public function setContractTerminated(?bool $contractTerminated): static
{
$this->contractTerminated = $contractTerminated;
return $this;
}
2024-08-02 23:24:52 +02:00
public function getDateOfContractSignature(): ?\DateTimeImmutable
2024-07-19 18:59:21 +02:00
{
return $this->dateOfContractSignature;
}
2024-08-02 23:24:52 +02:00
public function setDateOfContractSignature(?\DateTimeImmutable $dateOfContractSignature): static
2024-07-19 18:59:21 +02:00
{
$this->dateOfContractSignature = $dateOfContractSignature;
return $this;
}
2024-08-02 23:24:52 +02:00
public function getDelegationDate(): ?\DateTimeImmutable
2024-07-19 18:59:21 +02:00
{
return $this->delegationDate;
}
2024-08-02 23:24:52 +02:00
public function setDelegationDate(?\DateTimeImmutable $delegationDate): static
2024-07-19 18:59:21 +02:00
{
$this->delegationDate = $delegationDate;
return $this;
}
public function getRegistryOperator(): ?string
{
return $this->registryOperator;
}
public function setRegistryOperator(?string $registryOperator): static
{
$this->registryOperator = $registryOperator;
return $this;
}
2024-08-02 23:24:52 +02:00
public function getRemovalDate(): ?\DateTimeImmutable
2024-07-19 18:59:21 +02:00
{
return $this->removalDate;
}
2024-08-02 23:24:52 +02:00
public function setRemovalDate(?\DateTimeImmutable $removalDate): static
2024-07-19 18:59:21 +02:00
{
$this->removalDate = $removalDate;
return $this;
}
public function isSpecification13(): ?bool
{
return $this->specification13;
}
public function setSpecification13(?bool $specification13): static
{
$this->specification13 = $specification13;
return $this;
}
2024-07-24 18:52:19 +02:00
public function getType(): ?TldType
{
return $this->type;
}
2024-12-20 17:43:35 +01:00
public function setType(?TldType $type): static
2024-07-24 18:52:19 +02:00
{
$this->type = $type;
2024-12-20 17:43:35 +01:00
return $this;
2024-07-24 18:52:19 +02:00
}
2025-02-18 01:29:29 +01:00
/**
* @return Collection<int, Entity>
*/
public function getEntities(): Collection
{
return $this->entities;
}
public function addEntity(Entity $entity): static
{
if (!$this->entities->contains($entity)) {
$this->entities->add($entity);
$entity->setTld($this);
}
return $this;
}
public function removeEntity(Entity $entity): static
{
if ($this->entities->removeElement($entity)) {
// set the owning side to null (unless already changed)
if ($entity->getTld() === $this) {
$entity->setTld(null);
}
}
return $this;
}
2024-07-19 18:59:21 +02:00
}