diff --git a/src/Entity/Entity.php b/src/Entity/Entity.php index b976339..de6fcc9 100644 --- a/src/Entity/Entity.php +++ b/src/Entity/Entity.php @@ -87,13 +87,15 @@ class Entity private ?array $remarks = null; #[Embedded(class: IanaAccreditation::class, columnPrefix: 'iana_')] - private ?IanaAccreditation $ianaAccreditation; + #[Groups(['entity:item', 'domain:item'])] + private IanaAccreditation $ianaAccreditation; public function __construct() { $this->domainEntities = new ArrayCollection(); $this->nameserverEntities = new ArrayCollection(); $this->events = new ArrayCollection(); + $this->ianaAccreditation = new IanaAccreditation(); } public function getHandle(): ?string @@ -246,12 +248,12 @@ class Entity return $this; } - public function getIanaAccreditation(): ?IanaAccreditation + public function getIanaAccreditation(): IanaAccreditation { return $this->ianaAccreditation; } - public function setIanaAccreditation(?IanaAccreditation $ianaAccreditation): void + public function setIanaAccreditation(IanaAccreditation $ianaAccreditation): void { $this->ianaAccreditation = $ianaAccreditation; } diff --git a/src/Entity/IanaAccreditation.php b/src/Entity/IanaAccreditation.php index e2f3b82..72928f1 100644 --- a/src/Entity/IanaAccreditation.php +++ b/src/Entity/IanaAccreditation.php @@ -6,23 +6,29 @@ use App\Config\RegistrarStatus; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\Embeddable; +use Symfony\Component\Serializer\Attribute\Groups; #[Embeddable] class IanaAccreditation { #[ORM\Column(length: 255, nullable: true)] + #[Groups(['entity:item', 'domain:item'])] private ?string $registrarName = null; #[ORM\Column(length: 255, nullable: true)] + #[Groups(['entity:item', 'domain:item'])] private ?string $rdapBaseUrl = null; #[ORM\Column(nullable: true, enumType: RegistrarStatus::class)] + #[Groups(['entity:item', 'domain:item'])] private ?RegistrarStatus $status = null; #[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)] + #[Groups(['entity:item', 'domain:item'])] private ?\DateTimeImmutable $updated = null; #[ORM\Column(type: Types::DATE_IMMUTABLE, nullable: true)] + #[Groups(['entity:item', 'domain:item'])] private ?\DateTimeImmutable $date = null; public function getRegistrarName(): ?string diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index a9df2d0..d6b684d 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -14,7 +14,6 @@ use App\Entity\DomainEvent; use App\Entity\DomainStatus; use App\Entity\Entity; use App\Entity\EntityEvent; -use App\Entity\IanaAccreditation; use App\Entity\Nameserver; use App\Entity\NameserverEntity; use App\Entity\RdapServer; @@ -568,11 +567,11 @@ readonly class RDAPService $entity->setHandle($rdapEntity['handle']); - if (isset($rdapEntity['remarks']) && is_array($rdapEntity['remarks']) && null === $entity->getIanaAccreditation()) { + if (isset($rdapEntity['remarks']) && is_array($rdapEntity['remarks']) && null === $entity->getIanaAccreditation()->getStatus()) { $entity->setRemarks($rdapEntity['remarks']); } - if (isset($rdapEntity['vcardArray']) && null === $entity->getIanaAccreditation()) { + if (isset($rdapEntity['vcardArray']) && null === $entity->getIanaAccreditation()->getStatus()) { if (empty($entity->getJCard())) { if (!array_key_exists('elements', $rdapEntity['vcardArray'])) { $entity->setJCard($rdapEntity['vcardArray']); @@ -606,7 +605,7 @@ readonly class RDAPService } } - if ($isIANAid || !isset($rdapEntity['events']) || null !== $entity->getIanaAccreditation()) { + if ($isIANAid || !isset($rdapEntity['events']) || null !== $entity->getIanaAccreditation()->getStatus()) { return $entity; } @@ -826,17 +825,13 @@ readonly class RDAPService ->setHandle($registrar->value) ->setTld(null) ->setJCard(['vcard', [['version', [], 'text', '4.0'], ['fn', [], 'text', $registrar->name]]]) - ->setRemarks(null); - - if (null === $entity->getIanaAccreditation()) { - $entity->setIanaAccreditation(new IanaAccreditation()); - } - $entity->getIanaAccreditation() - ->setRegistrarName($registrar->name) - ->setStatus(RegistrarStatus::from($registrar->status)) - ->setRdapBaseUrl($registrar->rdapurl->count() ? ($registrar->rdapurl->server) : null) - ->setUpdated(null !== $registrar->attributes()->updated ? new \DateTimeImmutable($registrar->attributes()->updated) : null) - ->setDate(null !== $registrar->attributes()->date ? new \DateTimeImmutable($registrar->attributes()->date) : null); + ->setRemarks(null) + ->getIanaAccreditation() + ->setRegistrarName($registrar->name) + ->setStatus(RegistrarStatus::from($registrar->status)) + ->setRdapBaseUrl($registrar->rdapurl->count() ? ($registrar->rdapurl->server) : null) + ->setUpdated(null !== $registrar->attributes()->updated ? new \DateTimeImmutable($registrar->attributes()->updated) : null) + ->setDate(null !== $registrar->attributes()->date ? new \DateTimeImmutable($registrar->attributes()->date) : null); $this->em->persist($entity); }