mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add ICANN accreditation status on domain result page
This commit is contained in:
@@ -2,15 +2,11 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\EntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\Embedded;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
@@ -20,31 +16,6 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
)]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(
|
||||
uriTemplate: '/entities/icann-accreditations',
|
||||
openapiContext: [
|
||||
'parameters' => [
|
||||
[
|
||||
'name' => 'icannAccreditation.status',
|
||||
'in' => 'query',
|
||||
'required' => true,
|
||||
'schema' => [
|
||||
'type' => 'array',
|
||||
'items' => [
|
||||
'type' => 'string',
|
||||
'enum' => ['Accredited', 'Terminated', 'Reserved'],
|
||||
],
|
||||
],
|
||||
'style' => 'form',
|
||||
'explode' => true,
|
||||
'description' => 'Filter by ICANN accreditation status',
|
||||
],
|
||||
],
|
||||
],
|
||||
description: 'ICANN Registrar IDs list',
|
||||
normalizationContext: ['groups' => ['entity:list']],
|
||||
name: 'icann_accreditations_collection'
|
||||
),
|
||||
/*
|
||||
new GetCollection(
|
||||
uriTemplate: '/entities',
|
||||
@@ -67,12 +38,6 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
*/
|
||||
]
|
||||
)]
|
||||
#[ApiFilter(
|
||||
SearchFilter::class,
|
||||
properties: [
|
||||
'icannAccreditation.status' => 'exact',
|
||||
]
|
||||
)]
|
||||
class Entity
|
||||
{
|
||||
#[ORM\Id]
|
||||
@@ -81,7 +46,7 @@ class Entity
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: true)]
|
||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
|
||||
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
||||
private ?Tld $tld = null;
|
||||
|
||||
@@ -120,7 +85,7 @@ class Entity
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
private ?array $remarks = null;
|
||||
|
||||
#[Embedded(class: IcannAccreditation::class, columnPrefix: 'icann_')]
|
||||
#[ORM\ManyToOne(inversedBy: 'entities')]
|
||||
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
||||
private ?IcannAccreditation $icannAccreditation = null;
|
||||
|
||||
@@ -129,7 +94,6 @@ class Entity
|
||||
$this->domainEntities = new ArrayCollection();
|
||||
$this->nameserverEntities = new ArrayCollection();
|
||||
$this->events = new ArrayCollection();
|
||||
$this->icannAccreditation = new IcannAccreditation();
|
||||
}
|
||||
|
||||
public function getHandle(): ?string
|
||||
@@ -284,11 +248,13 @@ class Entity
|
||||
|
||||
public function getIcannAccreditation(): ?IcannAccreditation
|
||||
{
|
||||
return null === $this->icannAccreditation->getStatus() ? null : $this->icannAccreditation;
|
||||
return $this->icannAccreditation;
|
||||
}
|
||||
|
||||
public function setIcannAccreditation(?IcannAccreditation $icannAccreditation): void
|
||||
public function setIcannAccreditation(?IcannAccreditation $icannAccreditation): static
|
||||
{
|
||||
$this->icannAccreditation = $icannAccreditation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,35 +2,92 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Config\RegistrarStatus;
|
||||
use App\Repository\IcannAccreditationRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\Embeddable;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[Embeddable]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(
|
||||
uriTemplate: '/icann-accreditations',
|
||||
openapiContext: [
|
||||
'parameters' => [
|
||||
[
|
||||
'name' => 'status',
|
||||
'in' => 'query',
|
||||
'required' => true,
|
||||
'schema' => [
|
||||
'type' => 'array',
|
||||
'items' => [
|
||||
'type' => 'string',
|
||||
'enum' => ['Accredited', 'Terminated', 'Reserved'],
|
||||
],
|
||||
],
|
||||
'style' => 'form',
|
||||
'explode' => true,
|
||||
'description' => 'Filter by ICANN accreditation status',
|
||||
],
|
||||
],
|
||||
],
|
||||
shortName: 'ICANN Accreditation',
|
||||
description: 'ICANN Registrar IDs list',
|
||||
normalizationContext: ['groups' => ['icann:list']]
|
||||
),
|
||||
]
|
||||
)]
|
||||
#[ApiFilter(
|
||||
SearchFilter::class,
|
||||
properties: [
|
||||
'status' => 'exact',
|
||||
]
|
||||
)]
|
||||
#[ORM\Entity(repositoryClass: IcannAccreditationRepository::class)]
|
||||
class IcannAccreditation
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column]
|
||||
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
|
||||
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
|
||||
private ?string $registrarName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['entity:item', 'domain:item'])]
|
||||
#[Groups(['icann:item'])]
|
||||
private ?string $rdapBaseUrl = null;
|
||||
|
||||
#[ORM\Column(nullable: true, enumType: RegistrarStatus::class)]
|
||||
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
|
||||
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
|
||||
private ?RegistrarStatus $status = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
|
||||
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
|
||||
private ?\DateTimeImmutable $updated = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)]
|
||||
#[Groups(['entity:item', 'entity:list', 'domain:item'])]
|
||||
#[Groups(['icann:item', 'icann:list', 'domain:item'])]
|
||||
private ?\DateTimeImmutable $date = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Entity>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Entity::class, mappedBy: 'icannAccreditation')]
|
||||
private Collection $entities;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->entities = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getRegistrarName(): ?string
|
||||
{
|
||||
return $this->registrarName;
|
||||
@@ -90,4 +147,46 @@ class IcannAccreditation
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?int $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->setIcannAccreditation($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->getIcannAccreditation() === $this) {
|
||||
$entity->setIcannAccreditation(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user