mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add groups on properties
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user